mirror of https://github.com/freeCodeCamp/devdocs
Merge pull request #2136 from Suraj-Yadav/opengl
Add Opengl documentation (gl4 + gl2.1)pull/2294/head
commit
dd553c41b6
@ -0,0 +1,32 @@
|
||||
module Docs
|
||||
class Opengl
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
return '<h1>OpenGL</h1>' if root_page?
|
||||
|
||||
@doc = at_css('.refentry') if at_css('.refentry')
|
||||
|
||||
# Remove table from function definitions
|
||||
css('.funcprototype-table').each do |node|
|
||||
node.css('td').each do |data|
|
||||
data.replace(data.children)
|
||||
end
|
||||
node.css('tr').each do |row|
|
||||
row.replace(row.children)
|
||||
end
|
||||
node.wrap('<div>')
|
||||
node.parent['id'] = node.css('.fsfunc').text
|
||||
node.replace(node.children)
|
||||
end
|
||||
|
||||
css('a').remove_attribute('target')
|
||||
|
||||
# needed for scraper's options[:attribution]
|
||||
copyright = at_css('h2:contains("Copyright")')
|
||||
copyright.parent['style'] = 'display: none' if copyright
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
module Docs
|
||||
class Opengl
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
slug.chomp('.xhtml').chomp('.xml')
|
||||
end
|
||||
|
||||
# gl4 also has documentation of GLSL, this string is present under Version Support
|
||||
def get_type
|
||||
return 'GLSL' if html.include?('OpenGL Shading Language Version')
|
||||
'OpenGL'
|
||||
end
|
||||
|
||||
# functions like glUniform1f, glUniform2f, glUniform... have the same documentation
|
||||
def additional_entries
|
||||
entries = []
|
||||
css('.fsfunc').each do |function|
|
||||
next if function.text == name
|
||||
entries << [ function.text, function.text ]
|
||||
end
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
module Docs
|
||||
class Opengl < FileScraper
|
||||
self.type = 'simple'
|
||||
self.name = 'OpenGL'
|
||||
self.root_path = 'index.php'
|
||||
self.links = {
|
||||
home: 'https://registry.khronos.org/OpenGL-Refpages/'
|
||||
}
|
||||
html_filters.push 'opengl/entries', 'opengl/clean_html'
|
||||
|
||||
# indexflat.php is a copy of index.php
|
||||
options[:skip] = %w(indexflat.php)
|
||||
|
||||
options[:attribution] = ->(filter) {
|
||||
# copyright is the last section in these pages
|
||||
return filter.css('h2:contains("Copyright") ~ p').inner_text
|
||||
}
|
||||
|
||||
version '4' do
|
||||
self.root_path = 'index.php'
|
||||
self.release = '4'
|
||||
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
|
||||
end
|
||||
|
||||
version '2.1' do
|
||||
self.root_path = 'index.html'
|
||||
self.release = '2.1'
|
||||
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 416 B |
After Width: | Height: | Size: 559 B |
@ -0,0 +1 @@
|
||||
https://www.khronos.org/legal/trademarks/
|
Loading…
Reference in new issue