forked from freeCodeCamp/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request freeCodeCamp#1241 from xavieryao/master
Add PyTorch v1.7.0 documentation
- Loading branch information
Showing
7 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Docs | ||
class Pytorch < UrlScraper | ||
self.name = 'PyTorch' | ||
self.slug = 'pytorch' | ||
self.type = 'sphinx' | ||
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. | ||
HTML | ||
|
||
version do | ||
self.release = '1.7.0' | ||
self.base_url = "https://pytorch.org/docs/#{release}/" | ||
end | ||
|
||
def get_latest_version(opts) | ||
get_latest_github_release('pytorch', 'pytorch', opts) | ||
end | ||
end | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://pytorch.org/favicon.ico |