From 49cb0778f26e8303b1dc056bc212411c142f1e6f Mon Sep 17 00:00:00 2001 From: Suraj Yadav Date: Sat, 20 Jan 2024 18:42:05 -0700 Subject: [PATCH 1/3] Add Opengl documentation (gl4 + gl2.1) --- docs/file-scrapers.md | 13 ++++++++++ lib/docs/filters/opengl/clean_html.rb | 22 +++++++++++++++++ lib/docs/filters/opengl/entries.rb | 24 ++++++++++++++++++ lib/docs/scrapers/opengl.rb | 34 ++++++++++++++++++++++++++ public/icons/docs/opengl/16.png | Bin 0 -> 416 bytes public/icons/docs/opengl/16@2x.png | Bin 0 -> 559 bytes public/icons/docs/opengl/SOURCE | 1 + 7 files changed, 94 insertions(+) create mode 100644 lib/docs/filters/opengl/clean_html.rb create mode 100644 lib/docs/filters/opengl/entries.rb create mode 100644 lib/docs/scrapers/opengl.rb create mode 100644 public/icons/docs/opengl/16.png create mode 100644 public/icons/docs/opengl/16@2x.png create mode 100644 public/icons/docs/opengl/SOURCE diff --git a/docs/file-scrapers.md b/docs/file-scrapers.md index 478099b4..ad035d64 100644 --- a/docs/file-scrapers.md +++ b/docs/file-scrapers.md @@ -161,6 +161,19 @@ curl https://v2.ocaml.org/releases/$VERSION/ocaml-$VERSION-refman-html.tar.gz | tar xz --transform 's/htmlman/ocaml/' --directory docs/ ``` +## Opengl + +Clone https://github.com/KhronosGroup/OpenGL-Refpages.git + +```sh +DEVDOCS_ROOT=/path/to/devdocs +git clone https://github.com/KhronosGroup/OpenGL-Refpages.git +mkdir $DEVDOCS_ROOT/docs/opengl~gl4 +mkdir $DEVDOCS_ROOT/docs/opengl~gl2.1 +cp -r OpenGL-Refpages/gl4/html/* "$DEVDOCS_ROOT/docs/opengl~gl4" +cp -r OpenGL-Refpages/gl2.1/xhtml/* "$DEVDOCS_ROOT/docs/opengl~gl2.1" +``` + ## OpenJDK Search 'Openjdk' in https://www.debian.org/distrib/packages, find the `openjdk-$VERSION-doc` package, download it, extract it with `dpkg -x $PACKAGE ./` and move `./usr/share/doc/openjdk-16-jre-headless/api/` diff --git a/lib/docs/filters/opengl/clean_html.rb b/lib/docs/filters/opengl/clean_html.rb new file mode 100644 index 00000000..c7f300c5 --- /dev/null +++ b/lib/docs/filters/opengl/clean_html.rb @@ -0,0 +1,22 @@ +module Docs + class Opengl + class CleanHtmlFilter < Filter + def call + # Rmeove 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('
') + node.parent['id'] = node.css('.fsfunc').text + node.replace(node.children) + end + + doc + end + end + end + end diff --git a/lib/docs/filters/opengl/entries.rb b/lib/docs/filters/opengl/entries.rb new file mode 100644 index 00000000..0b56c7ee --- /dev/null +++ b/lib/docs/filters/opengl/entries.rb @@ -0,0 +1,24 @@ +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| + entries << [ function.text, function.text ] + end + entries + end + end + end +end diff --git a/lib/docs/scrapers/opengl.rb b/lib/docs/scrapers/opengl.rb new file mode 100644 index 00000000..09bc4b7a --- /dev/null +++ b/lib/docs/scrapers/opengl.rb @@ -0,0 +1,34 @@ +module Docs + class Opengl < FileScraper + self.type = 'simple' + 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] = <<-HTML + Copyright 2017-2021 The Khronos Group, Inc.. This work is licensed + under a Creative + Commons Attribution 4.0 International License. + HTML + + version 'gl2.1' do + self.root_path = 'index.html' + self.release = 'gl2.1' + self.base_url = "https://registry.khronos.org/OpenGL-Refpages/#{self.version}/" + end + version 'gl4' do + self.root_path = 'index.php' + self.release = 'gl4' + self.base_url = "https://registry.khronos.org/OpenGL-Refpages/#{self.version}/" + end + + def get_latest_version(opts) + return 'v1.0.0' + end + end +end diff --git a/public/icons/docs/opengl/16.png b/public/icons/docs/opengl/16.png new file mode 100644 index 0000000000000000000000000000000000000000..92a58e085dffe976312d6f7ee4421750b35300de GIT binary patch literal 416 zcmV;R0bl-!P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-CP_p=RCwCN(?3gFVH5`N-_`79(bW{8OF`USEJ)U-!yO74@(skrAs{Bp{TdOx zgAfHjK(*D)NtX_VfW!;`zFKT&?J~LA(BzXG|QJz z$4AWJ5~tYdx0|C0(k!oG3k_7qB)rD~y8U)@@ZLh2F7I%z4x$;$9Vf3)$~Gs!Y>@f zX5b|$9nds3;~vWRM^MDiahKS@m&kmKJ^aN+$#szY_s=vj!P@}z>rEVS4}RCwC#R?AJpKoE^B7vK&^Du}6o zxPs)u4GFsfk}DVB!ZoCVI1)Dw4i(r`fT;kNU^?K9G?qrI-Obt#;^HTbM%v%J`P!4o zh!Ot`&-LK-^Xn990U>?CTB3sdu&&RUwvfcp!&-!1Vh#y44wR6MjEJWgFCdY{C_Qi>?V4jwBN4gcR1(rQ z8lI!^k}uUm^1yahoL+JwZ3$4=*M@r(vKLVsONHn=B*U3T7)oT(V((EyhSqA2+w0qA zoSEmAqHOqV#*Y{BEY^+P=35>uh4JDzcpfvP&TXdmV&ooo*3G&sqGXi=LhDyh&_aQvr8rt^Q zH3DtEKQ;T2rrPD+!cdUT@VQMWtf^REh#77pG#I|<)l8D${Hv31sdPy!y5&6o13bI) zc2ufEgDsPRESLsjfa~J;8n#M+?Jx?3-@1V^vche^UcC xFqun3i Date: Sun, 21 Jan 2024 22:51:30 +0000 Subject: [PATCH 2/3] Requested review changes --- docs/file-scrapers.md | 8 ++++---- lib/docs/scrapers/opengl.rb | 25 ++++++++++--------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/docs/file-scrapers.md b/docs/file-scrapers.md index ad035d64..62dfcf3e 100644 --- a/docs/file-scrapers.md +++ b/docs/file-scrapers.md @@ -168,10 +168,10 @@ Clone https://github.com/KhronosGroup/OpenGL-Refpages.git ```sh DEVDOCS_ROOT=/path/to/devdocs git clone https://github.com/KhronosGroup/OpenGL-Refpages.git -mkdir $DEVDOCS_ROOT/docs/opengl~gl4 -mkdir $DEVDOCS_ROOT/docs/opengl~gl2.1 -cp -r OpenGL-Refpages/gl4/html/* "$DEVDOCS_ROOT/docs/opengl~gl4" -cp -r OpenGL-Refpages/gl2.1/xhtml/* "$DEVDOCS_ROOT/docs/opengl~gl2.1" +mkdir $DEVDOCS_ROOT/docs/opengl~4 +mkdir $DEVDOCS_ROOT/docs/opengl~2.1 +cp -r OpenGL-Refpages/gl4/html/* "$DEVDOCS_ROOT/docs/opengl~4" +cp -r OpenGL-Refpages/gl2.1/xhtml/* "$DEVDOCS_ROOT/docs/opengl~2.1" ``` ## OpenJDK diff --git a/lib/docs/scrapers/opengl.rb b/lib/docs/scrapers/opengl.rb index 09bc4b7a..6ad6ee03 100644 --- a/lib/docs/scrapers/opengl.rb +++ b/lib/docs/scrapers/opengl.rb @@ -10,25 +10,20 @@ module Docs # indexflat.php is a copy of index.php options[:skip] = %w(indexflat.php) - options[:attribution] = <<-HTML - Copyright 2017-2021 The Khronos Group, Inc.. This work is licensed - under a Creative - Commons Attribution 4.0 International License. - HTML + options[:attribution] = ->(filter) { + # copyright is the last section in these pages + return filter.css('.refsect1:last-child').css('p').inner_text + } - version 'gl2.1' do + version '2.1' do self.root_path = 'index.html' - self.release = 'gl2.1' - self.base_url = "https://registry.khronos.org/OpenGL-Refpages/#{self.version}/" + self.release = '2.1' + self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/" end - version 'gl4' do + version '4' do self.root_path = 'index.php' - self.release = 'gl4' - self.base_url = "https://registry.khronos.org/OpenGL-Refpages/#{self.version}/" - end - - def get_latest_version(opts) - return 'v1.0.0' + self.release = '4' + self.base_url = "https://registry.khronos.org/OpenGL-Refpages/gl#{self.version}/" end end end From d3a731d5d06c8814592633f2734577d712ab06f4 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 28 Jul 2024 10:50:09 +0200 Subject: [PATCH 3/3] Update OpenGL documentation (4) --- assets/javascripts/news.json | 4 ++++ lib/docs/filters/opengl/clean_html.rb | 12 +++++++++++- lib/docs/filters/opengl/entries.rb | 1 + lib/docs/scrapers/opengl.rb | 14 ++++++++------ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 39b2883c..b964b557 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2024-07-28", + "New documentation: OpenGL" + ], [ "2024-06-12", "New documentations: Next.js, click" diff --git a/lib/docs/filters/opengl/clean_html.rb b/lib/docs/filters/opengl/clean_html.rb index c7f300c5..60c870bf 100644 --- a/lib/docs/filters/opengl/clean_html.rb +++ b/lib/docs/filters/opengl/clean_html.rb @@ -2,7 +2,11 @@ module Docs class Opengl class CleanHtmlFilter < Filter def call - # Rmeove table from function definitions + return '

OpenGL

' 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) @@ -15,6 +19,12 @@ module Docs 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 diff --git a/lib/docs/filters/opengl/entries.rb b/lib/docs/filters/opengl/entries.rb index 0b56c7ee..32ae2e3c 100644 --- a/lib/docs/filters/opengl/entries.rb +++ b/lib/docs/filters/opengl/entries.rb @@ -15,6 +15,7 @@ module Docs def additional_entries entries = [] css('.fsfunc').each do |function| + next if function.text == name entries << [ function.text, function.text ] end entries diff --git a/lib/docs/scrapers/opengl.rb b/lib/docs/scrapers/opengl.rb index 6ad6ee03..e860625f 100644 --- a/lib/docs/scrapers/opengl.rb +++ b/lib/docs/scrapers/opengl.rb @@ -1,6 +1,7 @@ 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/' @@ -12,18 +13,19 @@ module Docs options[:attribution] = ->(filter) { # copyright is the last section in these pages - return filter.css('.refsect1:last-child').css('p').inner_text + return filter.css('h2:contains("Copyright") ~ p').inner_text } - 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 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