8000 docs: Update the documentation theme to PyTorch by narendasan · Pull Request #1063 · pytorch/TensorRT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs: Update the documentation theme to PyTorch #1063

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

Merged
merged 2 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build-docs:
runs-on: ubuntu-18.04
container:
image: ghcr.io/nvidia/torch-tensorrt/docgen:latest
image: docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run image
run: |
docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace ghcr.io/nvidia/torch-tensorrt/docgen:latest
docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run image
run: |
docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace ghcr.io/nvidia/torch-tensorrt/docgen:latest
docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ examples/int8/qat/qat
examples/int8/training/vgg16/data/*
examples/int8/datasets/data/*
env/**/*
bazel-Torch-TensorRT-Preview
bazel-Torch-TensorRT-Preview
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this anymore. Can we get rid of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I dont think it hurts to keep it around just in case

docsrc/src/
bazel-TensorRT
bazel-tensorrt
81 changes: 75 additions & 6 deletions docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

sys.path.append(os.path.join(os.path.dirname(__name__), '../py'))

import sphinx_material
import torch
import pytorch_sphinx_theme
import torch_tensorrt
# -- Project information -----------------------------------------------------

project = 'Torch-TensorRT'
copyright = '2021, NVIDIA Corporation'
author = 'NVIDIA Corporation'

version = 'master (' + torch_tensorrt.__version__ + ')'
# The full version, including alpha/beta/rc tags
release = 'master'

Expand All @@ -38,8 +41,15 @@
'sphinx.ext.intersphinx',
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
]

napoleon_use_ivar = True

autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -50,12 +60,18 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '_tmp', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_material'
html_theme = 'pytorch_sphinx_theme'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for addressing vulnerability reports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the new PyTorch theme to match the rest of the documentation


# 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,
Expand Down Expand Up @@ -84,10 +100,10 @@
html_show_sourcelink = True
html_sidebars = {"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]}

extensions.append("sphinx_material")
html_theme_path = sphinx_material.html_theme_path()
html_context = sphinx_material.get_html_context()
html_theme = "sphinx_material"
#extensions.append("sphinx_material")
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
#html_context = sphinx_material.get_html_context()
html_theme = "pytorch_sphinx_theme"

# Material theme options (see theme.conf for more information)
html_theme_options = {
Expand Down Expand Up @@ -138,3 +154,56 @@

# Tell sphinx what the pygments highlight language should be.
highlight_language = 'cpp'

# -- A patch that prevents Sphinx from cross-referencing ivar tags -------
# See http://stackoverflow.com/a/41184353/3343043

from docutils import nodes
from sphinx.util.docfields import TypedField
from sphinx import addnodes


def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!

# type: (list, unicode, tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = typename.replace('int', 'python:int')
typename = typename.replace('long', 'python:long')
typename = typename.replace('float', 'python:float')
typename = typename.replace('type', 'python:type')
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis, **kw))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par

fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)


TypedField.make_field = patched_make_field
10 changes: 5 additions & 5 deletions docsrc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx==4.3.0
breathe==4.31.0
exhale==0.2.3
sphinx-material==0.0.35
nbsphinx==0.8.7
sphinx==4.5.0
breathe==4.33.1
exhale==0.3.1
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
nbsphinx==0.8.8
docutils==0.17.1
5 changes: 4 additions & 1 deletion py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ def run(self):
include_dirs=[
dir_path + "torch_tensorrt/csrc", dir_path + "torch_tensorrt/include",
dir_path + "/../bazel-TRTorch/external/tensorrt/include",
dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include", dir_path + "/../"
dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include",
dir_path + "/../bazel-TensorRT/external/tensorrt/include",
dir_path + "/../bazel-tensorrt/external/tensorrt/include",
dir_path + "/../"
],
extra_compile_args=[
"-Wno-deprecated",
Expand Down
0