Skip to content

Commit dd553c4

Browse files
authored
Merge pull request #2136 from Suraj-Yadav/opengl
Add Opengl documentation (gl4 + gl2.1)
2 parents fe0d469 + d3a731d commit dd553c4

File tree

8 files changed

+106
-0
lines changed

8 files changed

+106
-0
lines changed

assets/javascripts/news.json

+4
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>"

docs/file-scrapers.md

+13
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ curl https://v2.ocaml.org/releases/$VERSION/ocaml-$VERSION-refman-html.tar.gz |
161161
tar xz --transform 's/htmlman/ocaml/' --directory docs/
162162
```
163163

164+
## Opengl
165+
166+
Clone https://github.com/KhronosGroup/OpenGL-Refpages.git
167+
168+
```sh
169+
DEVDOCS_ROOT=/path/to/devdocs
170+
git clone https://github.com/KhronosGroup/OpenGL-Refpages.git
171+
mkdir $DEVDOCS_ROOT/docs/opengl~4
172+
mkdir $DEVDOCS_ROOT/docs/opengl~2.1
173+
cp -r OpenGL-Refpages/gl4/html/* "$DEVDOCS_ROOT/docs/opengl~4"
174+
cp -r OpenGL-Refpages/gl2.1/xhtml/* "$DEVDOCS_ROOT/docs/opengl~2.1"
175+
```
176+
164177
## OpenJDK
165178
Search 'Openjdk' in https://www.debian.org/distrib/packages, find the `openjdk-$VERSION-doc` package,
166179
download it, extract it with `dpkg -x $PACKAGE ./` and move `./usr/share/doc/openjdk-16-jre-headless/api/`

lib/docs/filters/opengl/clean_html.rb

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module Docs
2+
class Opengl
3+
class CleanHtmlFilter < Filter
4+
def call
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
10+
css('.funcprototype-table').each do |node|
11+
node.css('td').each do |data|
12+
data.replace(data.children)
13+
end
14+
node.css('tr').each do |row|
15+
row.replace(row.children)
16+
end
17+
node.wrap('<div>')
18+
node.parent['id'] = node.css('.fsfunc').text
19+
node.replace(node.children)
20+
end
21+
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+
28+
doc
29+
end
30+
end
31+
end
32+
end

lib/docs/filters/opengl/entries.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Docs
2+
class Opengl
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
slug.chomp('.xhtml').chomp('.xml')
6+
end
7+
8+
# gl4 also has documentation of GLSL, this string is present under Version Support
9+
def get_type
10+
return 'GLSL' if html.include?('OpenGL Shading Language Version')
11+
'OpenGL'
12+
end
13+
14+
# functions like glUniform1f, glUniform2f, glUniform... have the same documentation
15+
def additional_entries
16+
entries = []
17+
css('.fsfunc').each do |function|
18+
next if function.text == name
19+
entries << [ function.text, function.text ]
20+
end
21+
entries
22+
end
23+
end
24+
end
25+
end

lib/docs/scrapers/opengl.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module Docs
2+
class Opengl < FileScraper
3+
self.type = 'simple'
4+
self.name = 'OpenGL'
5+
self.root_path = 'index.php'
6+
self.links = {
7+
home: 'https://registry.khronos.org/OpenGL-Refpages/'
8+
}
9+
html_filters.push 'opengl/entries', 'opengl/clean_html'
10+
11+
# indexflat.php is a copy of index.php
12+
options[:skip] = %w(indexflat.php)
13+
14+
options[:attribution] = ->(filter) {
15+
# copyright is the last section in these pages
16+
return filter.css('h2:contains("Copyright") ~ p').inner_text
17+
}
18+
19+
version '4' do
20+
self.root_path = 'index.php'
21+
self.release = '4'
22+
self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/"
23+
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
30+
end
31+
end

public/icons/docs/opengl/16.png

416 Bytes
Loading
559 Bytes
Loading

public/icons/docs/opengl/SOURCE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.khronos.org/legal/trademarks/

0 commit comments

Comments
 (0)