Skip to content

Commit d3a731d

Browse files
committed
Update OpenGL documentation (4)
1 parent 20840ba commit d3a731d

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

assets/javascripts/news.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
[
3+
"2024-07-28",
4+
"New documentation: <a href=\"/opengl/\">OpenGL</a>"
5+
],
26
[
37
"2024-06-12",
48
"New documentations: <a href=\"/nextjs/\">Next.js</a>, <a href=\"/click/\">click</a>"

lib/docs/filters/opengl/clean_html.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ module Docs
22
class Opengl
33
class CleanHtmlFilter < Filter
44
def call
5-
# Rmeove table from function definitions
5+
return '<h1>OpenGL</h1>' if root_page?
6+
7+
@doc = at_css('.refentry') if at_css('.refentry')
8+
9+
# Remove table from function definitions
610
css('.funcprototype-table').each do |node|
711
node.css('td').each do |data|
812
data.replace(data.children)
@@ -15,6 +19,12 @@ def call
1519
node.replace(node.children)
1620
end
1721

22+
css('a').remove_attribute('target')
23+
24+
# needed for scraper's options[:attribution]
25+
copyright = at_css('h2:contains("Copyright")')
26+
copyright.parent['style'] = 'display: none' if copyright
27+
1828
doc
1929
end
2030
end

lib/docs/filters/opengl/entries.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def get_type
1515
def additional_entries
1616
entries = []
1717
css('.fsfunc').each do |function|
18+
next if function.text == name
1819
entries << [ function.text, function.text ]
1920
end
2021
entries

lib/docs/scrapers/opengl.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Docs
22
class Opengl < FileScraper
33
self.type = 'simple'
4+
self.name = 'OpenGL'
45
self.root_path = 'index.php'
56
self.links = {
67
home: 'https://registry.khronos.org/OpenGL-Refpages/'
@@ -12,18 +13,19 @@ class Opengl < FileScraper
1213

1314
options[:attribution] = ->(filter) {
1415
# copyright is the last section in these pages
15-
return filter.css('.refsect1:last-child').css('p').inner_text
16+
return filter.css('h2:contains("Copyright") ~ p').inner_text
1617
}
1718

18-
version '2.1' do
19-
self.root_path = 'index.html'
20-
self.release = '2.1'
21-
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
22-
end
2319
version '4' do
2420
self.root_path = 'index.php'
2521
self.release = '4'
2622
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
2723
end
24+
25+
version '2.1' do
26+
self.root_path = 'index.html'
27+
self.release = '2.1'
28+
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
29+
end
2830
end
2931
end

0 commit comments

Comments
 (0)