Skip to content

Commit 4bbc132

Browse files
authored
Merge pull request #1063 from pytorch/theme_change
docs: Update the documentation theme to PyTorch
2 parents 292fc15 + 46a724c commit 4bbc132

File tree

6 files changed

+91
-16
lines changed

6 files changed

+91
-16
lines changed

.github/workflows/docgen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build-docs:
1313
runs-on: ubuntu-18.04
1414
container:
15-
image: ghcr.io/nvidia/torch-tensorrt/docgen:latest
15+
image: docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0
1616
credentials:
1717
username: ${{ github.actor }}
1818
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
password: ${{ secrets.GITHUB_TOKEN }}
3434
- name: Run image
3535
run: |
36-
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
36+
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
3737
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
3838
env:
3939
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -70,7 +70,7 @@ jobs:
7070
password: ${{ secrets.GITHUB_TOKEN }}
7171
- name: Run image
7272
run: |
73-
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
73+
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
7474
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
7575
env:
7676
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@ examples/int8/qat/qat
5757
examples/int8/training/vgg16/data/*
5858
examples/int8/datasets/data/*
5959
env/**/*
60-
bazel-Torch-TensorRT-Preview
60+
bazel-Torch-TensorRT-Preview
61+
docsrc/src/
62+
bazel-TensorRT
63+
bazel-tensorrt

docsrc/conf.py

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

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

18-
import sphinx_material
18+
import torch
19+
import pytorch_sphinx_theme
20+
import torch_tensorrt
1921
# -- Project information -----------------------------------------------------
2022

2123
project = 'Torch-TensorRT'
2224
copyright = '2021, NVIDIA Corporation'
2325
author = 'NVIDIA Corporation'
2426

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

@@ -38,8 +41,15 @@
3841
'sphinx.ext.intersphinx',
3942
'sphinx.ext.autosummary',
4043
'sphinx.ext.autodoc',
44+
'sphinx.ext.doctest',
45+
'sphinx.ext.todo',
46+
'sphinx.ext.coverage',
47+
'sphinx.ext.mathjax',
48+
'sphinx.ext.viewcode',
4149
]
4250

51+
napoleon_use_ivar = True
52+
4353
autosummary_generate = True
4454

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

63+
# The name of the Pygments (syntax highlighting) style to use.
64+
pygments_style = 'sphinx'
65+
66+
# If true, `todo` and `todoList` produce output, else they produce nothing.
67+
todo_include_todos = True
68+
5369
# -- Options for HTML output -------------------------------------------------
5470

5571
# The theme to use for HTML and HTML Help pages. See the documentation for
5672
# a list of builtin themes.
5773
#
58-
html_theme = 'sphinx_material'
74+
html_theme = 'pytorch_sphinx_theme'
5975

6076
# Add any paths that contain custom static files (such as style sheets) here,
6177
# relative to this directory. They are copied after the builtin static files,
@@ -84,10 +100,10 @@
84100
html_show_sourcelink = True
85101
html_sidebars = {"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]}
86102

87-
extensions.append("sphinx_material")
88-
html_theme_path = sphinx_material.html_theme_path()
89-
html_context = sphinx_material.get_html_context()
90-
html_theme = "sphinx_material"
103+
#extensions.append("sphinx_material")
104+
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
105+
#html_context = sphinx_material.get_html_context()
106+
html_theme = "pytorch_sphinx_theme"
91107

92108
# Material theme options (see theme.conf for more information)
93109
html_theme_options = {
@@ -138,3 +154,56 @@
138154

139155
# Tell sphinx what the pygments highlight language should be.
140156
highlight_language = 'cpp'
157+
158+
# -- A patch that prevents Sphinx from cross-referencing ivar tags -------
159+
# See http://stackoverflow.com/a/41184353/3343043
160+
161+
from docutils import nodes
162+
from sphinx.util.docfields import TypedField
163+
from sphinx import addnodes
164+
165+
166+
def patched_make_field(self, types, domain, items, **kw):
167+
# `kw` catches `env=None` needed for newer sphinx while maintaining
168+
# backwards compatibility when passed along further down!
169+
170+
# type: (list, unicode, tuple) -> nodes.field
171+
def handle_item(fieldarg, content):
172+
par = nodes.paragraph()
173+
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
174+
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
175+
# addnodes.literal_strong))
176+
if fieldarg in types:
177+
par += nodes.Text(' (')
178+
# NOTE: using .pop() here to prevent a single type node to be
179+
# inserted twice into the doctree, which leads to
180+
# inconsistencies later when references are resolved
181+
fieldtype = types.pop(fieldarg)
182+
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
183+
typename = u''.join(n.astext() for n in fieldtype)
184+
typename = typename.replace('int', 'python:int')
185+
typename = typename.replace('long', 'python:long')
186+
typename = typename.replace('float', 'python:float')
187+
typename = typename.replace('type', 'python:type')
188+
par.extend(self.make_xrefs(self.typerolename, domain, typename,
189+
addnodes.literal_emphasis, **kw))
190+
else:
191+
par += fieldtype
192+
par += nodes.Text(')')
193+
par += nodes.Text(' -- ')
194+
par += content
195+
return par
196+
197+
fieldname = nodes.field_name('', self.label)
198+
if len(items) == 1 and self.can_collapse:
199+
fieldarg, content = items[0]
200+
bodynode = handle_item(fieldarg, content)
201+
else:
202+
bodynode = self.list_type()
203+
for fieldarg, content in items:
204+
bodynode += nodes.list_item('', handle_item(fieldarg, content))
205+
fieldbody = nodes.field_body('', bodynode)
206+
return nodes.field('', fieldname, fieldbody)
207+
208+
209+
TypedField.make_field = patched_make_field

docsrc/requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
sphinx==4.3.0
2-
breathe==4.31.0
3-
exhale==0.2.3
4-
sphinx-material==0.0.35
5-
nbsphinx==0.8.7
1+
sphinx==4.5.0
2+
breathe==4.33.1
3+
exhale==0.3.1
4+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
5+
nbsphinx==0.8.8
66
docutils==0.17.1

py/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ def run(self):
240240
include_dirs=[
241241
dir_path + "torch_tensorrt/csrc", dir_path + "torch_tensorrt/include",
242242
dir_path + "/../bazel-TRTorch/external/tensorrt/include",
243-
dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include", dir_path + "/../"
243+
dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include",
244+
dir_path + "/../bazel-TensorRT/external/tensorrt/include",
245+
dir_path + "/../bazel-tensorrt/external/tensorrt/include",
246+
dir_path + "/../"
244247
],
245248
extra_compile_args=[
246249
"-Wno-deprecated",

0 commit comments

Comments
 (0)