History

Merge pull request #2136 from Suraj-Yadav/opengl

Add Opengl documentation (gl4 + gl2.1)

Simon Legner committed 2 years ago

Commit dd553c42 parents fe0d469 d3a731d8 files · +104 −-2Browse files

Unified · Split

8 files
  1. assets/javascripts/news.json +4 −0
  2. docs/file-scrapers.md +13 −0
  3. lib/docs/filters/opengl/clean_html.rb +32 −0
  4. lib/docs/filters/opengl/entries.rb +25 −0
  5. lib/docs/scrapers/opengl.rb +31 −0
  6. public/icons/docs/opengl/16.png +0 −0
  7. public/icons/docs/opengl/16@2x.png +0 −0
  8. public/icons/docs/opengl/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
1[1[
2 [
3 "2024-07-28",
4 "New documentation: <a href=\"/opengl/\">OpenGL</a>"
5 ],
2 [6 [
3 "2024-06-12",7 "2024-06-12",
4 "New documentations: <a href=\"/nextjs/\">Next.js</a>, <a href=\"/click/\">click</a>"8 "New documentations: <a href=\"/nextjs/\">Next.js</a>, <a href=\"/click/\">click</a>"
docs/file-scrapers.md+13−0
@@ -161,6 +161,19 @@ curl https://v2.ocaml.org/releases/$VERSION/ocaml-$VERSION-refman-html.tar.gz | · 160 unmodified lines
161tar xz --transform 's/htmlman/ocaml/' --directory docs/161tar xz --transform 's/htmlman/ocaml/' --directory docs/
162```162```
163 163
164## Opengl
165
166Clone https://github.com/KhronosGroup/OpenGL-Refpages.git
167
168```sh
169DEVDOCS_ROOT=/path/to/devdocs
170git clone https://github.com/KhronosGroup/OpenGL-Refpages.git
171mkdir $DEVDOCS_ROOT/docs/opengl~4
172mkdir $DEVDOCS_ROOT/docs/opengl~2.1
173cp -r OpenGL-Refpages/gl4/html/* "$DEVDOCS_ROOT/docs/opengl~4"
174cp -r OpenGL-Refpages/gl2.1/xhtml/* "$DEVDOCS_ROOT/docs/opengl~2.1"
175```
176
164## OpenJDK177## OpenJDK
165Search 'Openjdk' in https://www.debian.org/distrib/packages, find the `openjdk-$VERSION-doc` package,178Search 'Openjdk' in https://www.debian.org/distrib/packages, find the `openjdk-$VERSION-doc` package,
166download it, extract it with `dpkg -x $PACKAGE ./` and move `./usr/share/doc/openjdk-16-jre-headless/api/`179download 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−0
@@ -0,0 +1,32 @@
1module 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−0
@@ -0,0 +1,25 @@
1module 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
25end
lib/docs/scrapers/opengl.rb+31−0
@@ -0,0 +1,31 @@
1module 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
31end
public/icons/docs/opengl/16.png+0−0

Binary file not shown.

public/icons/docs/opengl/16@2x.png+0−0

Binary file not shown.

public/icons/docs/opengl/SOURCE+1−0
@@ -0,0 +1 @@
1https://www.khronos.org/legal/trademarks/