Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Opengl documentation (gl4 + gl2.1) #2136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/file-scrapers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`
Expand Down
22 changes: 22 additions & 0 deletions lib/docs/filters/opengl/clean_html.rb
Original file line number Diff line number Diff line change
@@ -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('<div>')
node.parent['id'] = node.css('.fsfunc').text
node.replace(node.children)
end

doc
end
end
end
end
24 changes: 24 additions & 0 deletions lib/docs/filters/opengl/entries.rb
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions lib/docs/scrapers/opengl.rb
Original file line number Diff line number Diff line change
@@ -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 <a href="http://creativecommons.org/licenses/by/4.0/">Creative
Commons Attribution 4.0 International License</a>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contradicts the licenses mentioned on https://github.com/KhronosGroup/OpenGL-Refpages#licenses

For historical reasons, the ref pages are under a mix of open source licenses from Khronos, SGI, 3Dlabs, and others. We are unable to change many of those licenses, because the original authors are no longer in business (SGI, 3Dlabs). Ideally we’d like to end up with a Creative Commons license on all the ref pages and Apache 2.0 on all the scripts and tools, but it’s unlikely that will ever be possible.

https://registry.khronos.org/OpenGL-Refpages/gl4/html/barrier.xhtml mentions "Open Publication License", https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBlendColor.xhtml mentions "SGI Free Software B License"

See the lib/docs/scrapers/crystal.rb scraper how to output different licenses depending on the URL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have written logic to extract copyright from the page, but I am getting this warning
Docs::AttributionFilter is re-parsing the document.
Unfortunately, I don't think there is any way to do this without parsing the document, as the value changes without any pattern in the URL.

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
Suraj-Yadav marked this conversation as resolved.
Show resolved Hide resolved
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'
Suraj-Yadav marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
Binary file added public/icons/docs/opengl/16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/opengl/[email protected]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/opengl/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.khronos.org/legal/trademarks/