Migrate to new theme (#149331)

- Migrate pytorch docs, cpp docs and functorch docs to the pytorch_sphinx_theme2
- Migrate index.rst to markdown and restructure to use high-level horizontal bar sections Python API, Developer Notes
- Added python-api.md which becomes the main container for the API docs. This file will be used to add all api references in the toctree. It would be great to have lint for this file: https://github.com/pytorch/pytorch/issues/150718
- Enabled mermaid sphinx extension and opengraph sphinx extension

Pull Request resolved: https://github.com/pytorch/pytorch/pull/149331
Approved by: https://github.com/malfet, https://github.com/atalman, https://github.com/albanD
This commit is contained in:
Svetlana Karslioglu
2025-04-16 21:35:14 +00:00
committed by PyTorch MergeBot
parent 1ffaa00ad7
commit cd7bc60e11
23 changed files with 440 additions and 615 deletions

View File

@ -1,15 +1,20 @@
sphinx==5.3.0
#Description: This is used to generate PyTorch docs
#Pinned versions: 5.3.0
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@c49afc2aff734d40813b0ca182bb49b611d7a30c#egg=pytorch_sphinx_theme2
# TODO: sphinxcontrib.katex 0.9.0 adds a local KaTeX server to speed up pre-rendering
# but it doesn't seem to work and hangs around idly. The initial thought is probably
# something related to Docker setup. We can investigate this later
sphinxcontrib.katex==0.8.6
#Description: This is used to generate PyTorch docs
#Pinned versions: 0.8.6
sphinxext-opengraph==0.9.1
#Description: This is used to generate PyTorch docs
#Pinned versions: 0.9.1
matplotlib==3.5.3
#Description: This is used to generate PyTorch docs
#Pinned versions: 3.5.3
@ -46,5 +51,6 @@ myst-nb==0.17.2
# The following are required to build torch.distributed.elastic.rendezvous.etcd* docs
python-etcd==0.4.5
sphinx-copybutton==0.5.0
sphinx-panels==0.4.1
sphinx-design==0.4.0
sphinxcontrib-mermaid==1.0.0
myst-parser==0.18.1

View File

@ -119,12 +119,6 @@ popd
git rm -rf "$install_path" || true
mv "$pt_checkout/docs/build/html" "$install_path"
# Prevent Google from indexing $install_path/_modules. This folder contains
# generated source files.
# NB: the following only works on gnu sed. The sed shipped with mac os is different.
# One can `brew install gnu-sed` on a mac and then use "gsed" instead of "sed".
find "$install_path/_modules" -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">'
git add "$install_path" || true
git status
git config user.email "soumith+bot@pytorch.org"

View File

@ -1,32 +0,0 @@
/* These are hacks on top of pytorch-sphinx-theme to fix random problems when
it is applied to C++ docs */
/* Fix clickable types floating to the right */
a.reference.internal {
position: static !important;
}
/* Clickable links should have a underline */
a.reference.internal:hover {
text-decoration: underline !important;
}
/* Non-clickable type properties should match C++ syntax and be black */
.function em.property {
text-transform: none !important;
color: #262626 !important;
}
/* This was broken for some reason and wasn't using the right font */
.function a.anchorjs-link {
font-family: anchorjs-icons !important;
}
/* Prevents keywords from overlapping */
article.pytorch-article .class dt em.property {
position: initial !important;
}
/* Properly aligns keywords the left */
article.pytorch-article .class dt {
padding-left: 0.5em !important;
}

View File

@ -22,8 +22,8 @@
import os
import textwrap
# sys.path.insert(0, os.path.abspath('.'))
import pytorch_sphinx_theme2
# -- General configuration ------------------------------------------------
@ -112,6 +112,12 @@ highlight_language = "cpp"
# Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates']
theme_variables = pytorch_sphinx_theme2.get_theme_variables()
templates_path = [
"_templates",
os.path.join(os.path.dirname(pytorch_sphinx_theme2.__file__), "templates"),
]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
@ -142,7 +148,7 @@ release = "main"
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@ -160,7 +166,7 @@ todo_include_todos = True
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "pytorch_sphinx_theme"
html_theme = "pytorch_sphinx_theme2"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -168,37 +174,57 @@ html_theme = "pytorch_sphinx_theme"
#
html_theme_options = {
"canonical_url": "https://pytorch.org/docs/stable/",
"pytorch_project": "docs",
"collapse_navigation": False,
"logo": {"text": "Home"},
"icon_links": [
{
"name": "X",
"url": "https://x.com/PyTorch",
"icon": "fa-brands fa-x-twitter",
},
{
"name": "GitHub",
"url": "https://github.com/pytorch/pytorch",
"icon": "fa-brands fa-github",
},
{
"name": "PyTorch Forum",
"url": "https://discuss.pytorch.org/",
"icon": "fa-brands fa-discourse",
},
{
"name": "PyPi",
"url": "https://pypi.org/project/torch/",
"icon": "fa-brands fa-python",
},
],
"navbar_start": ["pytorch_version"],
"display_version": True,
"logo_only": True,
}
html_context = {
"theme_variables": theme_variables,
"github_url": "https://github.com",
"github_user": "pytorch",
"github_repo": "pytorch",
"feedback_url": "https://github.com/pytorch/pytorch",
"github_version": "main",
"doc_path": "docs/cpp/source",
"library_links": theme_variables.get("library_links", []),
"community_links": theme_variables.get("community_links", []),
"language_bindings_links": theme_variables.get("language_bindings_links", []),
}
# NOTE: sharing python docs resources
html_logo = os.path.join(
repo_root, "docs", "source", "_static", "img", "pytorch-logo-dark-unstable.png"
)
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# NOTE: sharing python docs resources
html_static_path = [os.path.join(repo_root, "docs", "cpp", "source", "_static")]
html_css_files = ["cpp_theme.css"]
# Called automatically by Sphinx, making this `conf.py` an "extension".
def setup(app):
# NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value
# and can be moved outside of this function (and the setup(app) function
# can be deleted).
html_css_files = ["cpp_theme.css"]
# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
# `add_stylesheet` (deprecated in 1.8).
add_css = getattr(app, "add_css_file", app.add_stylesheet)
for css_file in html_css_files:
add_css(css_file)
# -- Options for HTMLHelp output ------------------------------------------

View File

@ -1,5 +1,5 @@
sphinx==5.0.0
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
sphinx==5.3.0
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
# TODO: sphinxcontrib.katex 0.9.0 adds a local KaTeX server to speed up pre-rendering
# but it doesn't seem to work and hangs around idly. The initial thought is probably
# something related to Docker setup. We can investigate this later
@ -9,5 +9,6 @@ tensorboard==2.10.0
# required to build torch.distributed.elastic.rendezvous.etcd* docs
python-etcd==0.4.5
sphinx-copybutton==0.5.0
sphinx-panels==0.4.1
myst-parser==0.18.1
myst-parser==4.0.1
sphinx-design==0.6.1
sphinxcontrib-mermaid==1.0.0

View File

@ -1,145 +0,0 @@
/* styles needed for the Google Search button */
.gsc-overflow-hidden {
overflow: visible !important;
}
.gsc-control-cse {
padding-left: 0px !important;
padding-bottom: 0px !important;
}
.gsc-search-button .gsc-search-button-v2:focus {
border: transparent !important;
outline: none;
box-shadow: none;
}
.gsc-search-button-v2:active {
border: none !important;
}
.gsc-search-button-v2 {
border: none !important;
}
/* End of Google Search button styles */
/* Classes needed for the survey link*/
.pytorch-left-menu-search { /* This is needed so the distance between the search and menu is not too big */
margin-bottom: 0px;
}
.survey-link {
color: #262626;
}
.pytorch-left-menu-search .survey-link a {
color: #262626;
text-decoration: underline;
font-weight: 500;
}
/* End of classes needed for the survey banner*/
/* search radio button*/
input[type="radio"] {
accent-color: #ee4c2c;
}
.gsst_b {
display: none;
}
#gsc-i-id1 {
height: 1.5rem;
text-indent: 12px !important;
font-size: 1rem !important;
font-family: "FreightSansi";
background-image: url(../images/search-icon.svg) !important;
background-repeat: no-repeat !important;
background-size: 18px 18px !important;
background-position: 5px 0px !important;
padding-left: 20px !important;
}
#gsc-i-id1::placeholder {
font-family: 'FreightSans';
font-size: 1rem;
color: #262626;
}
.gsc-control-cse {
padding: 0 !important;
border-radius: 0px !important;
border: none !important;;
overflow: hidden;
}
#___gcse_0 {
height: 44px !important;
padding: 0 !important;
}
@media (max-width: 768px) {
#___gcse_0 {
height: 34px !important;
}
}
table.gsc-search-box td.gsc-input {
padding-right: 0 !important;
}
table.gsc-search-box td {
height: 44px;
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
@media (max-width: 768px) {
table.gsc-search-box td {
height: 34px;
}
}
.gsc-search-button-v2 {
display: none;
}
.gs_id50 {
width: 308px;
}
.gsib_a {
padding: 0px 8px 4px 9px !important;
}
.gsc-input-box {
border-radius: 0px !important;
border: none !important;
}
@media (max-width: 768px) {
.gsc-input-box {
padding-top: 0px;
padding-bottom: 0px;
}
}
@media (max-width: 768px) {
.searchbox {
height: 34px;
}
form.gsc-search-box {
margin-bottom 0px;
}
.pytorch-left-menu-search input[type=text] {
background-image: url("../images/search-icon.svg");
}
.gsc-overflow-hidden {
overflow: visible !important;
}
.form#searchForm {
padding-bottom: 0;
margin-bottom: 0;
}

View File

@ -1,123 +0,0 @@
{% extends "!layout.html" %}
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
{% block extrahead %}
{% if release == "main" %}
<!--
Search engines should not index the main version of documentation.
Stable documentation are built without release == 'main'.
-->
<meta name="robots" content="noindex">
{% endif %}
{{ super() }}
{% endblock %}
{% block menu %}
{% if release == "main" %}
<div>
<a style="color:#F05732" href="{{ theme_canonical_url }}{{ pagename }}.html">
You are viewing unstable developer preview docs.
Click here to view docs for latest stable release.
</a>
</div>
{% endif %}
{{ super() }}
{% endblock %}
{% block sidebartitle %}
<div class="version">
<a href='https://pytorch.org/docs/versions.html'>{{ version }} &#x25BC</a>
</div>
<div id="searchBox">
<div class="searchbox" id="googleSearchBox">
<script async src="https://cse.google.com/cse.js?cx=e65585f8c3ea1440e"></script>
<div class="gcse-search"></div>
</div>
<div id="sphinxSearchBox" style="display: none;">
<div role="search">
<form id="rtd-search-form" class="wy-form" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" placeholder="Search Docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<form id="searchForm">
<label style="margin-bottom: 1rem">
<input type="radio" name="searchType" value="google" checked>
Google Search
</label>
<label style="margin-bottom: 1rem">
<input type="radio" name="searchType" value="sphinx">
Classic Search
</label>
</form>
<script>
document.addEventListener('DOMContentLoaded', function() {
const searchForm = document.getElementById('searchForm');
const googleSearchBox = document.getElementById('googleSearchBox');
const sphinxSearchBox = document.getElementById('sphinxSearchBox');
// Function to toggle search box visibility
function toggleSearchBox(searchType) {
googleSearchBox.style.display = searchType === 'google' ? 'block' : 'none';
sphinxSearchBox.style.display = searchType === 'sphinx' ? 'block' : 'none';
}
// Determine the default search type
let defaultSearchType;
const currentUrl = window.location.href;
if (currentUrl.startsWith('https://pytorch.org/docs/stable')) {
// For the stable documentation, default to Google
defaultSearchType = localStorage.getItem('searchType') || 'google';
} else {
// For any other version, including docs-preview, default to Sphinx
defaultSearchType = 'sphinx';
}
// Set the default search type
document.querySelector(`input[name="searchType"][value="${defaultSearchType}"]`).checked = true;
toggleSearchBox(defaultSearchType);
// Event listener for changes in search type
searchForm.addEventListener('change', function(event) {
const selectedSearchType = event.target.value;
localStorage.setItem('searchType', selectedSearchType);
toggleSearchBox(selectedSearchType);
});
// Set placeholder text for Google search box
window.onload = function() {
var placeholderText = "Search Docs";
var googleSearchboxText = document.querySelector("#gsc-i-id1");
if (googleSearchboxText) {
googleSearchboxText.placeholder = placeholderText;
googleSearchboxText.style.fontFamily = 'FreightSans';
googleSearchboxText.style.fontSize = "1.2rem";
googleSearchboxText.style.color = '#262626';
}
};
});
</script>
{% endblock %}
{%- block content %}
{{ super() }}
<script>
var match = window.location.href.match(/\/_[a-zA-Z0-9_]*.html|_dynamo/gi);
var url = window.location.href.lastIndexOf(match[match.length-1]);
if (url)
{
var div = '<div class="admonition note"><p class="admonition-title">Note</p><p><i class="fa fa-exclamation-circle" aria-hidden="true">&nbsp</i> This page describes an internal API which is not intended to be used outside of the PyTorch codebase and can be modified or removed without notice.</p></div>'
document.getElementById("pytorch-article").insertAdjacentHTML('afterBegin', div)
}
</script>
{%- endblock %}
{% block footer %}
{{ super() }}
<script script type="text/javascript">
var collapsedSections = ['Developer Notes', 'Language Bindings', 'Libraries', 'Community'];
</script>
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>
{% endblock %}

View File

@ -1,3 +1,5 @@
:orphan:
PyTorch Governance | Build + CI
===============================

View File

@ -1,3 +1,5 @@
:orphan:
.. note::
This page has been deprecated. Please refer to the `Contribution Guide <https://github.com/pytorch/pytorch/wiki/The-Ultimate-Guide-to-PyTorch-Contributions>`_ on the PyTorch Wiki.

View File

@ -1,3 +1,5 @@
:orphan:
PyTorch Design Philosophy
=========================

View File

@ -1,3 +1,5 @@
:orphan:
PyTorch Governance | Mechanics
==============================

View File

@ -0,0 +1,10 @@
:orphan:
Community
=========
.. toctree::
:glob:
:maxdepth: 1
*

View File

@ -1,3 +1,5 @@
:orphan:
PyTorch Governance | Maintainers
=========================================

View File

@ -12,11 +12,6 @@
# serve to show the default.
import inspect
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
@ -29,6 +24,11 @@ from os import path
import torch
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
try:
import torchvision # noqa: F401
except ImportError:
@ -38,15 +38,14 @@ except ImportError:
RELEASE = os.environ.get("RELEASE", False)
import pytorch_sphinx_theme
import pytorch_sphinx_theme2
html_theme = "pytorch_sphinx_theme2"
html_theme_path = [pytorch_sphinx_theme2.get_html_theme_path()]
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
needs_sphinx = "3.1.2"
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
@ -58,22 +57,29 @@ extensions = [
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinxcontrib.katex",
"sphinx.ext.autosectionlabel",
"sphinxcontrib.katex",
"sphinx_copybutton",
"sphinx_panels",
"sphinx_design",
"myst_parser",
"sphinx.ext.linkcode",
"sphinxcontrib.mermaid",
"sphinxext.opengraph",
]
ogp_site_url = "http://pytorch.org/"
ogp_image = "https://pytorch.org/assets/images/social-share.jpg"
myst_enable_extensions = [
"colon_fence",
"deflist",
"html_image",
]
# build the templated autosummary files
autosummary_generate = True
numpydoc_show_class_members = False
# Theme has bootstrap already
panels_add_bootstrap_css = False
# autosectionlabel throws warnings if section names are duplicated.
# The following tells autosectionlabel to not throw a warning for
# duplicated section names that are in different documents.
@ -85,15 +91,130 @@ autosectionlabel_prefix_document = True
katex_prerender = True
# General information about the project.
project = "PyTorch"
copyright = "PyTorch Contributors"
author = "PyTorch Contributors"
torch_version = str(torch.__version__)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
# TODO: change to [:2] at v1.0
version = "main (" + torch_version + " )"
# The full version, including alpha/beta/rc tags.
release = "main"
# Customized html_title here.
# Default is " ".join(project, release, "documentation") if not set
if RELEASE:
# Turn 1.11.0aHASH into 1.11
# Note: the release candidates should no longer have the aHASH suffix, but in any
# case we wish to leave only major.minor, even for rc builds.
version = ".".join(torch_version.split(".")[:2])
html_title = " ".join((project, version, "documentation"))
release = version
switcher_version = "main" if not RELEASE else version
html_static_path = ["_static"]
html_theme_options = {
"logo": {"text": "Home"},
"analytics_id": "GTM-T8XT4PS",
"canonical_url": "https://pytorch.org/docs/stable/",
"switcher": {
"json_url": "https://pytorch.org/docs/pytorch-versions.json",
"version_match": switcher_version,
},
"navigation_with_keys": False,
"external_links": [
{
"name": "Tutorials",
"url": "https://pytorch.org/tutorials/",
},
],
"show_version_warning_banner": True,
"icon_links": [
{
"name": "X",
"url": "https://x.com/PyTorch",
"icon": "fa-brands fa-x-twitter",
},
{
"name": "GitHub",
"url": "https://github.com/pytorch/pytorch",
"icon": "fa-brands fa-github",
},
{
"name": "PyTorch Forum",
"url": "https://discuss.pytorch.org/",
"icon": "fa-brands fa-discourse",
},
{
"name": "PyPi",
"url": "https://pypi.org/project/torch/",
"icon": "fa-brands fa-python",
},
],
"navbar_align": "left",
"navbar_start": ["version-switcher", "navbar-logo"],
"navbar_center": ["navbar-nav"],
"navbar_end": ["search-field-custom", "theme-switcher", "navbar-icon-links"],
"header_links_before_dropdown": 4,
"navbar_persistent": [],
"use_edit_page_button": True,
"pytorch_project": "docs",
}
theme_variables = pytorch_sphinx_theme2.get_theme_variables()
# For these links to appear in the right nav, there is an override in
# the theme:
# pytorch_sphinx_theme2/templates/sections/sidebar-secondary.html#L17
community_links = [
{"url": "/community/index", "name": "PyTorch Governance"},
{"url": "/community/design", "name": "PyTorch Design Philosophy"},
{
"url": "https://github.com/pytorch/pytorch/wiki/The-Ultimate-Guide-to-PyTorch-Contributions",
"name": "The Ultimate Guide to PyTorch Contributions",
},
]
# For these links to appear in the right nav, there is an override in
# /pytorch_sphinx_theme2/templates/sections/sidebar-secondary.html
language_bindings_links = [
{"url": "/cpp_index", "name": "C++"},
{"url": "https://pytorch.org/javadoc/", "name": "Javadoc"},
{"url": "https://github.com/pytorch/multipy", "name": "torch.multiply"},
]
html_context = {
"theme_variables": theme_variables,
"github_url": "https://github.com",
"github_user": "pytorch",
"github_repo": "pytorch",
"feedback_url": "https://github.com/pytorch/pytorch",
"github_version": "main",
"pytorch_project": "docs",
"doc_path": "docs/source",
"theme_variables": theme_variables, # noqa: F601
# library links are defined in
# pytorch_sphinx_theme2/pytorch_sphinx_theme2/links.json
"library_links": theme_variables.get("library_links", []),
"community_links": community_links,
"language_bindings_links": language_bindings_links,
"version": version,
}
napoleon_use_ivar = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
templates_path = [
"_templates",
os.path.join(os.path.dirname(pytorch_sphinx_theme2.__file__), "templates"),
]
# TODO: document these and remove them from here.
html_domain_indices = False
coverage_ignore_functions = [
# torch
"typename",
@ -3364,33 +3485,6 @@ source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "PyTorch"
copyright = "PyTorch Contributors"
author = "PyTorch Contributors"
torch_version = str(torch.__version__)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
# TODO: change to [:2] at v1.0
version = "main (" + torch_version + " )"
# The full version, including alpha/beta/rc tags.
# TODO: verify this works as expected
release = "main"
# Customized html_title here.
# Default is " ".join(project, release, "documentation") if not set
if RELEASE:
# Turn 1.11.0aHASH into 1.11
# Note: the release candidates should no longer have the aHASH suffix, but in any
# case we wish to leave only major.minor, even for rc builds.
version = ".".join(torch_version.split(".")[:2])
html_title = " ".join((project, version, "documentation"))
release = version
# Use the linkcode extension to override [SOURCE] links to point
# to the repo. Use the torch_version variable defined above to
@ -3446,8 +3540,6 @@ exclude_patterns = []
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# Disable docstring inheritance
autodoc_inherit_docstrings = False
@ -3497,33 +3589,20 @@ autodoc_docstring_signature = True
#
#
html_theme = "pytorch_sphinx_theme"
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"pytorch_project": "docs",
"canonical_url": "https://pytorch.org/docs/stable/",
"collapse_navigation": False,
"display_version": True,
"logo_only": True,
"analytics_id": "GTM-T8XT4PS",
}
html_logo = "_static/img/pytorch-logo-dark-unstable.png"
if RELEASE:
html_logo = "_static/img/pytorch-logo-dark.svg"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = ["css/jit.css", "css/custom.css"]
html_css_files = [
"css/jit.css",
"css/custom.css",
"https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css",
]
from sphinx.ext.coverage import CoverageBuilder
@ -3647,23 +3726,16 @@ def process_docstring(app, what_, name, obj, options, lines):
lines.append("")
# Called automatically by Sphinx, making this `conf.py` an "extension".
def setup(app):
# NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value
# and can be moved outside of this function (and the setup(app) function
# can be deleted).
html_css_files = [
"https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css"
]
# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
# `add_stylesheet` (deprecated in 1.8).
add_css = getattr(app, "add_css_file", app.add_stylesheet)
for css_file in html_css_files:
add_css(css_file)
app.connect("build-finished", coverage_post_process)
app.connect("autodoc-process-docstring", process_docstring)
app.connect("html-page-context", hide_edit_button_for_pages)
return {"version": "0.1", "parallel_read_safe": True}
def hide_edit_button_for_pages(app, pagename, templatename, context, doctree):
if pagename.startswith("generated/"):
context["theme_use_edit_page_button"] = False
# From PyTorch 1.5, we now use autogenerated files to document classes and

View File

@ -1,3 +1,5 @@
:orphan:
C++
===================================
.. Note::

View File

@ -1,3 +1,5 @@
:orphan:
torch::deploy has been moved to pytorch/multipy
===============================================

48
docs/source/index.md Normal file
View File

@ -0,0 +1,48 @@
% PyTorch documentation master file, created by
% sphinx-quickstart on Fri Dec 23 13:31:47 2016.
% You can adapt this file completely to your liking, but it should at least
% contain the root `toctree` directive.
% :github_url: https://github.com/pytorch/pytorch
PyTorch documentation
===================================
PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.
Features described in this documentation are classified by release status:
*Stable:* These features will be maintained long-term and there should generally
be no major performance limitations or gaps in documentation.
We also expect to maintain backwards compatibility (although
breaking changes can happen and notice will be given one release ahead
of time).
*Beta:* These features are tagged as Beta because the API may change based on
user feedback, because the performance needs to improve, or because
coverage across operators is not yet complete. For Beta features, we are
committing to seeing the feature through to the Stable classification.
We are not, however, committing to backwards compatibility.
*Prototype:* These features are typically not available as part of
binary distributions like PyPI or Conda, except sometimes behind run-time
flags, and are at an early stage for feedback and testing.
```{toctree}
:glob:
:maxdepth: 2
pytorch-api
```
```{toctree}
:glob:
:maxdepth: 2
notes
```
## Indices and tables
* {ref}`genindex`
* {ref}`modindex`

View File

@ -1,157 +0,0 @@
.. PyTorch documentation master file, created by
sphinx-quickstart on Fri Dec 23 13:31:47 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
:github_url: https://github.com/pytorch/pytorch
PyTorch documentation
===================================
PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.
Features described in this documentation are classified by release status:
*Stable:* These features will be maintained long-term and there should generally
be no major performance limitations or gaps in documentation.
We also expect to maintain backwards compatibility (although
breaking changes can happen and notice will be given one release ahead
of time).
*Beta:* These features are tagged as Beta because the API may change based on
user feedback, because the performance needs to improve, or because
coverage across operators is not yet complete. For Beta features, we are
committing to seeing the feature through to the Stable classification.
We are not, however, committing to backwards compatibility.
*Prototype:* These features are typically not available as part of
binary distributions like PyPI or Conda, except sometimes behind run-time
flags, and are at an early stage for feedback and testing.
.. toctree::
:glob:
:maxdepth: 1
:caption: Community
community/*
.. toctree::
:glob:
:maxdepth: 1
:caption: Developer Notes
notes/*
.. toctree::
:maxdepth: 1
:caption: Language Bindings
cpp_index
Javadoc <https://pytorch.org/javadoc/>
torch::deploy <deploy>
.. toctree::
:glob:
:maxdepth: 1
:caption: Python API
torch
nn
nn.functional
tensors
tensor_attributes
tensor_view
torch.amp <amp>
torch.autograd <autograd>
torch.library <library>
accelerator
cpu
cuda
torch.cuda.memory <torch_cuda_memory>
mps
xpu
mtia
mtia.memory
meta
torch.backends <backends>
torch.export <export>
torch.distributed <distributed>
torch.distributed.tensor <distributed.tensor>
torch.distributed.algorithms.join <distributed.algorithms.join>
torch.distributed.elastic <distributed.elastic>
torch.distributed.fsdp <fsdp>
torch.distributed.fsdp.fully_shard <distributed.fsdp.fully_shard>
torch.distributed.tensor.parallel <distributed.tensor.parallel>
torch.distributed.optim <distributed.optim>
torch.distributed.pipelining <distributed.pipelining>
torch.distributed.checkpoint <distributed.checkpoint>
torch.distributions <distributions>
torch.compiler <torch.compiler>
torch.fft <fft>
torch.func <func>
futures
fx
fx.experimental
torch.hub <hub>
torch.jit <jit>
torch.linalg <linalg>
torch.monitor <monitor>
torch.signal <signal>
torch.special <special>
torch.overrides
torch.package <package>
profiler
nn.init
nn.attention
onnx
optim
complex_numbers
ddp_comm_hooks
quantization
rpc
torch.random <random>
masked
torch.nested <nested>
size
sparse
storage
torch.testing <testing>
torch.utils <utils>
torch.utils.benchmark <benchmark_utils>
torch.utils.bottleneck <bottleneck>
torch.utils.checkpoint <checkpoint>
torch.utils.cpp_extension <cpp_extension>
torch.utils.data <data>
torch.utils.deterministic <deterministic>
torch.utils.jit <jit_utils>
torch.utils.dlpack <dlpack>
torch.utils.mobile_optimizer <mobile_optimizer>
torch.utils.model_zoo <model_zoo>
torch.utils.tensorboard <tensorboard>
torch.utils.module_tracker <module_tracker>
type_info
named_tensor
name_inference
torch.__config__ <config_mod>
torch.__future__ <future_mod>
logging
torch_environment_variables
.. toctree::
:maxdepth: 1
:caption: Libraries
torchaudio <https://pytorch.org/audio/stable>
TorchData <https://pytorch.org/data>
TorchRec <https://pytorch.org/torchrec>
TorchServe <https://pytorch.org/serve>
torchtext <https://pytorch.org/text/stable>
torchvision <https://pytorch.org/vision/stable>
PyTorch on XLA Devices <https://pytorch.org/xla/>
torchao <https://pytorch.org/ao>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`

9
docs/source/notes.md Normal file
View File

@ -0,0 +1,9 @@
(developer_notes)=
# Developer Notes
```{toctree}
:glob:
:maxdepth: 1
notes/*
```

View File

@ -0,0 +1,89 @@
(pytorch_api)=
# Python API
```{toctree}
:glob:
:maxdepth: 1
torch
nn
nn.functional
tensors
tensor_attributes
tensor_view
torch.amp <amp>
torch.autograd <autograd>
torch.library <library>
accelerator
cpu
cuda
torch.cuda.memory <torch_cuda_memory>
mps
xpu
mtia
mtia.memory
meta
torch.backends <backends>
torch.export <export>
torch.distributed <distributed>
torch.distributed.tensor <distributed.tensor>
torch.distributed.algorithms.join <distributed.algorithms.join>
torch.distributed.elastic <distributed.elastic>
torch.distributed.fsdp <fsdp>
torch.distributed.fsdp.fully_shard <distributed.fsdp.fully_shard>
torch.distributed.tensor.parallel <distributed.tensor.parallel>
torch.distributed.optim <distributed.optim>
torch.distributed.pipelining <distributed.pipelining>
torch.distributed.checkpoint <distributed.checkpoint>
torch.distributions <distributions>
torch.compiler <torch.compiler>
torch.fft <fft>
torch.func <func>
futures
fx
fx.experimental
torch.hub <hub>
torch.jit <jit>
torch.linalg <linalg>
torch.monitor <monitor>
torch.signal <signal>
torch.special <special>
torch.overrides
torch.package <package>
profiler
nn.init
nn.attention
onnx
optim
complex_numbers
ddp_comm_hooks
quantization
rpc
torch.random <random>
masked
torch.nested <nested>
size
sparse
storage
torch.testing <testing>
torch.utils <utils>
torch.utils.benchmark <benchmark_utils>
torch.utils.bottleneck <bottleneck>
torch.utils.checkpoint <checkpoint>
torch.utils.cpp_extension <cpp_extension>
torch.utils.data <data>
torch.utils.deterministic <deterministic>
torch.utils.jit <jit_utils>
torch.utils.dlpack <dlpack>
torch.utils.mobile_optimizer <mobile_optimizer>
torch.utils.model_zoo <model_zoo>
torch.utils.tensorboard <tensorboard>
torch.utils.module_tracker <module_tracker>
type_info
named_tensor
name_inference
torch.__config__ <config_mod>
torch.__future__ <future_mod>
logging
torch_environment_variables
```

View File

@ -1,13 +0,0 @@
.codeblock-height-limiter {
max-height: 500px;
overflow: scroll;
}
.highlight pre {
border: 1px solid rgba(0,0,0,0.15);
border-radius: 4px;
}
div.cell div.cell_input {
border-bottom-width: 0px;
}

View File

@ -1,9 +0,0 @@
{% extends "!layout.html" %}
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
{% block sidebartitle %}
<div class="version">
<a href='https://pytorch.org/functorch/versions.html'>{{ version }} &#x25BC</a>
</div>
{% include "searchbox.html" %}
{% endblock %}

View File

@ -13,20 +13,19 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import functorch
# import sys
# source code directory, relative to this file, for sphinx-autobuild
# sys.path.insert(0, os.path.abspath('../..'))
RELEASE = os.environ.get("RELEASE", False)
import pytorch_sphinx_theme
sys.path.insert(0, os.path.abspath(".."))
import pytorch_sphinx_theme2
# -- General configuration ------------------------------------------------
@ -77,8 +76,10 @@ napoleon_use_ivar = True
autosummary_generate = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
templates_path = [
"_templates",
os.path.join(os.path.dirname(pytorch_sphinx_theme2.__file__), "templates"),
]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
@ -161,20 +162,66 @@ autodoc_docstring_signature = True
#
#
html_theme = "pytorch_sphinx_theme"
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
html_theme = "pytorch_sphinx_theme2"
html_theme_path = [pytorch_sphinx_theme2.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
switcher_version = "main" if not RELEASE else version
html_theme_options = {
"icon_links": [
{
"name": "X",
"url": "https://x.com/PyTorch",
"icon": "fa-brands fa-x-twitter",
},
{
"name": "GitHub",
"url": "https://github.com/pytorch/pytorch",
"icon": "fa-brands fa-github",
},
{
"name": "PyTorch Forum",
"url": "https://discuss.pytorch.org/",
"icon": "fa-brands fa-discourse",
},
{
"name": "PyPi",
"url": "https://pypi.org/project/torch/",
"icon": "fa-brands fa-python",
},
],
"collapse_navigation": False,
"display_version": True,
"logo_only": True,
"pytorch_project": "functorch",
"navigation_with_keys": True,
"analytics_id": "UA-117752657-2",
"logo": {"text": "Home"},
"switcher": {
"json_url": "https://pytorch.org/functorch/functorch-versions.json",
"version_match": switcher_version,
},
"navbar_start": ["version-switcher"],
}
theme_variables = pytorch_sphinx_theme2.get_theme_variables()
html_context = {
"theme_variables": theme_variables,
"display_github": True,
"github_url": "https://github.com",
"github_user": "pytorch",
"github_repo": "pytorch",
"feedback_url": "https://github.com/pytorch/pytorch",
"github_version": "main",
"doc_path": "functorch/docs/source",
"library_links": theme_variables.get("library_links", []),
"community_links": theme_variables.get("community_links", []),
"language_bindings_links": html_theme_options.get("language_bindings_links", []),
}
# Add any paths that contain custom static files (such as style sheets) here,
@ -184,23 +231,11 @@ html_static_path = ["_static"]
html_css_files = [
"css/custom.css",
"https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css",
]
# Called automatically by Sphinx, making this `conf.py` an "extension".
def setup(app):
# NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value
# and can be moved outside of this function (and the setup(app) function
# can be deleted).
html_css_files = [
"https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css"
]
# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
# `add_stylesheet` (deprecated in 1.8).
add_css = getattr(app, "add_css_file", app.add_stylesheet)
for css_file in html_css_files:
add_css(css_file)
# -- Options for HTMLHelp output ------------------------------------------