[devdocsgjs/main: 1063/1867] Add PyTorch v1.5.0 documentation
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 1063/1867] Add PyTorch v1.5.0 documentation
- Date: Fri, 19 Nov 2021 23:47:41 +0000 (UTC)
commit c0b94262bfda228fa307723c1deecac9a89771ca
Author: Peiran Yao <xavieryao me com>
Date: Sun May 31 16:45:44 2020 -0600
Add PyTorch v1.5.0 documentation
.../javascripts/templates/pages/about_tmpl.coffee | 5 ++
lib/docs/filters/pytorch/clean_html.rb | 12 +++++
lib/docs/filters/pytorch/entries.rb | 54 +++++++++++++++++++++
lib/docs/scrapers/pytorch.rb | 37 ++++++++++++++
public/icons/docs/pytorch/16.png | Bin 0 -> 1526 bytes
public/icons/docs/pytorch/16 2x png | Bin 0 -> 2302 bytes
public/icons/docs/pytorch/SOURCE | 1 +
7 files changed, 109 insertions(+)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 8ac93ed4..5fda9667 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -621,6 +621,11 @@ credits = [
'2001-2020 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
'PSFL',
'https://docs.python.org/3/license.html'
+ ], [
+ 'PyTorch',
+ '2019 Torch Contributors',
+ 'BSD',
+ 'https://raw.githubusercontent.com/pytorch/pytorch/master/LICENSE'
], [
'Q',
'2009-2017 Kristopher Michael Kowal',
diff --git a/lib/docs/filters/pytorch/clean_html.rb b/lib/docs/filters/pytorch/clean_html.rb
new file mode 100644
index 00000000..dd19c3e0
--- /dev/null
+++ b/lib/docs/filters/pytorch/clean_html.rb
@@ -0,0 +1,12 @@
+module Docs
+ class Pytorch
+ class CleanHtmlFilter < Filter
+ def call
+ @doc = at_css('.pytorch-article')
+ # Show katex-mathml nodes and remove katex-html nodes
+ css('.katex-html').remove
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/pytorch/entries.rb b/lib/docs/filters/pytorch/entries.rb
new file mode 100644
index 00000000..f63926b4
--- /dev/null
+++ b/lib/docs/filters/pytorch/entries.rb
@@ -0,0 +1,54 @@
+module Docs
+ class Pytorch
+ class EntriesFilter < Docs::EntriesFilter
+ def get_name
+ # The id of the container `div.section` indicates the page type.
+ # If the id starts with `module-`, then it's an API reference,
+ # otherwise it is a note or design doc.
+ # After the `sphinx/clean_html` filter, that id is assigned to the second element.
+ if doc.element_children[1]['id']&.starts_with? 'module-'
+ /\Amodule-(.*)/.match(doc.element_children[1]['id'])[1]
+ else
+ at_css('h1').content
+ end
+ end
+
+ def get_type
+ name
+ end
+
+ def include_default_entry?
+ # If the page is not an API reference, we only include it in the index when it
+ # contains additional entries. See the doc for `get_name`.
+ doc.element_children[1]['id']&.starts_with? 'module-'
+ end
+
+ def additional_entries
+ return [] if root_page?
+
+ entries = []
+
+ css('dt').each do |node|
+ name = node['id']
+ if name == self.name or name == nil
+ next
+ end
+
+ case node.parent['class']
+ when 'method', 'function'
+ if node.at_css('code').content.starts_with? 'property '
+ # this instance method is a property, so treat it as an attribute
+ entries << [name, node['id']]
+ else
+ entries << [name + '()', node['id']]
+ end
+ when 'class', 'attribute'
+ entries << [name, node['id']]
+ end
+ end
+
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/scrapers/pytorch.rb b/lib/docs/scrapers/pytorch.rb
new file mode 100644
index 00000000..4245981b
--- /dev/null
+++ b/lib/docs/scrapers/pytorch.rb
@@ -0,0 +1,37 @@
+module Docs
+ class Pytorch < UrlScraper
+ self.name = 'PyTorch'
+ self.slug = 'pytorch'
+ self.type = 'sphinx'
+ self.release = '1.5.0'
+ self.base_url = 'https://pytorch.org/docs/stable/'
+ self.force_gzip = true
+ self.links = {
+ home: 'https://pytorch.org/',
+ code: 'https://github.com/pytorch/pytorch'
+ }
+
+ html_filters.push 'pytorch/clean_html', 'sphinx/clean_html', 'pytorch/entries'
+
+ options[:skip] = ['cpp_index.html', 'packages.html', 'py-modindex.html', 'genindex.html']
+ options[:skip_patterns] = [/\Acommunity/, /\A_modules/, /\Anotes/, /\Aorg\/pytorch\//]
+ options[:max_image_size] = 256_000
+
+ options[:attribution] = <<-HTML
+ © 2019 Torch Contributors<br>
+ Licensed under the 3-clause BSD License.<br>
+ <a href="https://raw.githubusercontent.com/pytorch/pytorch/master/LICENSE"
class="_attribution-link">Read the full license.</a>
+ HTML
+
+ def get_latest_version(opts)
+ doc = fetch_doc('https://pytorch.org/docs/versions.html', opts)
+ doc.css('li.toctree-l1').each do |node|
+ match = /v(.+?) \(stable release\)/.match(node.content)
+ if match
+ return match[1]
+ end
+ end
+ end
+ end
+end
+
\ No newline at end of file
diff --git a/public/icons/docs/pytorch/16.png b/public/icons/docs/pytorch/16.png
new file mode 100644
index 00000000..a0104d59
Binary files /dev/null and b/public/icons/docs/pytorch/16.png differ
diff --git a/public/icons/docs/pytorch/16 2x png b/public/icons/docs/pytorch/16 2x png
new file mode 100644
index 00000000..b417ee98
Binary files /dev/null and b/public/icons/docs/pytorch/16 2x png differ
diff --git a/public/icons/docs/pytorch/SOURCE b/public/icons/docs/pytorch/SOURCE
new file mode 100644
index 00000000..9863ff2e
--- /dev/null
+++ b/public/icons/docs/pytorch/SOURCE
@@ -0,0 +1 @@
+https://pytorch.org/favicon.ico
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]