Add PyTorch v1.7.0 documentation
Unified · Split
| @@ -626,6 +626,11 @@ credits = [ · 625 unmodified lines | |||
| 626 | '2001-2020 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.', | 626 | '2001-2020 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.', |
| 627 | 'PSFL', | 627 | 'PSFL', |
| 628 | 'https://docs.python.org/3/license.html' | 628 | 'https://docs.python.org/3/license.html' |
| 629 | ], [ | ||
| 630 | 'PyTorch', | ||
| 631 | '2019 Torch Contributors', | ||
| 632 | 'BSD', | ||
| 633 | 'https://raw.githubusercontent.com/pytorch/pytorch/master/LICENSE' | ||
| 629 | ], [ | 634 | ], [ |
| 630 | 'Q', | 635 | 'Q', |
| 631 | '2009-2017 Kristopher Michael Kowal', | 636 | '2009-2017 Kristopher Michael Kowal', |
| @@ -0,0 +1,12 @@ | |||
| 1 | module Docs | ||
| 2 | class Pytorch | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | @doc = at_css('.pytorch-article') | ||
| 6 | # Show katex-mathml nodes and remove katex-html nodes | ||
| 7 | css('.katex-html').remove | ||
| 8 | doc | ||
| 9 | end | ||
| 10 | end | ||
| 11 | end | ||
| 12 | end | ||
| @@ -0,0 +1,54 @@ | |||
| 1 | module Docs | ||
| 2 | class Pytorch | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | # The id of the container `div.section` indicates the page type. | ||
| 6 | # If the id starts with `module-`, then it's an API reference, | ||
| 7 | # otherwise it is a note or design doc. | ||
| 8 | # After the `sphinx/clean_html` filter, that id is assigned to the second element. | ||
| 9 | if doc.element_children[1]['id']&.starts_with? 'module-' | ||
| 10 | /\Amodule-(.*)/.match(doc.element_children[1]['id'])[1] | ||
| 11 | else | ||
| 12 | at_css('h1').content | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | def get_type | ||
| 17 | name | ||
| 18 | end | ||
| 19 | |||
| 20 | def include_default_entry? | ||
| 21 | # If the page is not an API reference, we only include it in the index when it | ||
| 22 | # contains additional entries. See the doc for `get_name`. | ||
| 23 | doc.element_children[1]['id']&.starts_with? 'module-' | ||
| 24 | end | ||
| 25 | |||
| 26 | def additional_entries | ||
| 27 | return [] if root_page? | ||
| 28 | |||
| 29 | entries = [] | ||
| 30 | |||
| 31 | css('dt').each do |node| | ||
| 32 | name = node['id'] | ||
| 33 | if name == self.name or name == nil | ||
| 34 | next | ||
| 35 | end | ||
| 36 | |||
| 37 | case node.parent['class'] | ||
| 38 | when 'method', 'function' | ||
| 39 | if node.at_css('code').content.starts_with? 'property ' | ||
| 40 | # this instance method is a property, so treat it as an attribute | ||
| 41 | entries << [name, node['id']] | ||
| 42 | else | ||
| 43 | entries << [name + '()', node['id']] | ||
| 44 | end | ||
| 45 | when 'class', 'attribute' | ||
| 46 | entries << [name, node['id']] | ||
| 47 | end | ||
| 48 | end | ||
| 49 | |||
| 50 | entries | ||
| 51 | end | ||
| 52 | end | ||
| 53 | end | ||
| 54 | end | ||
| @@ -0,0 +1,32 @@ | |||
| 1 | module Docs | ||
| 2 | class Pytorch < UrlScraper | ||
| 3 | self.name = 'PyTorch' | ||
| 4 | self.slug = 'pytorch' | ||
| 5 | self.type = 'sphinx' | ||
| 6 | self.force_gzip = true | ||
| 7 | self.links = { | ||
| 8 | home: 'https://pytorch.org/', | ||
| 9 | code: 'https://github.com/pytorch/pytorch' | ||
| 10 | } | ||
| 11 | |||
| 12 | html_filters.push 'pytorch/clean_html', 'sphinx/clean_html', 'pytorch/entries' | ||
| 13 | |||
| 14 | options[:skip] = ['cpp_index.html', 'packages.html', 'py-modindex.html', 'genindex.html'] | ||
| 15 | options[:skip_patterns] = [/\Acommunity/, /\A_modules/, /\Anotes/, /\Aorg\/pytorch\//] | ||
| 16 | options[:max_image_size] = 256_000 | ||
| 17 | |||
| 18 | options[:attribution] = <<-HTML | ||
| 19 | © 2019 Torch Contributors<br> | ||
| 20 | Licensed under the 3-clause BSD License. | ||
| 21 | HTML | ||
| 22 | |||
| 23 | version do | ||
| 24 | self.release = '1.7.0' | ||
| 25 | self.base_url = "https://pytorch.org/docs/#{release}/" | ||
| 26 | end | ||
| 27 | |||
| 28 | def get_latest_version(opts) | ||
| 29 | get_latest_github_release('pytorch', 'pytorch', opts) | ||
| 30 | end | ||
| 31 | end | ||
| 32 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://pytorch.org/favicon.ico | ||