15
15
16
16
sys .path .append (os .path .join (os .path .dirname (__name__ ), '../py' ))
17
17
18
- import sphinx_material
18
+ import torch
19
+ import pytorch_sphinx_theme
20
+ import torch_tensorrt
19
21
# -- Project information -----------------------------------------------------
20
22
21
23
project = 'Torch-TensorRT'
22
24
copyright = '2021, NVIDIA Corporation'
23
25
author = 'NVIDIA Corporation'
24
26
27
+ version = 'master (' + torch_tensorrt .__version__ + ')'
25
28
# The full version, including alpha/beta/rc tags
26
29
release = 'master'
27
30
38
41
'sphinx.ext.intersphinx' ,
39
42
'sphinx.ext.autosummary' ,
40
43
'sphinx.ext.autodoc' ,
44
+ 'sphinx.ext.doctest' ,
45
+ 'sphinx.ext.todo' ,
46
+ 'sphinx.ext.coverage' ,
47
+ 'sphinx.ext.mathjax' ,
48
+ 'sphinx.ext.viewcode' ,
41
49
]
42
50
51
+ napoleon_use_ivar = True
52
+
43
53
autosummary_generate = True
44
54
45
55
# Add any paths that contain templates here, relative to this directory.
50
60
# This pattern also affects html_static_path and html_extra_path.
51
61
exclude_patterns = ['_build' , '_tmp' , 'Thumbs.db' , '.DS_Store' ]
52
62
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
+
53
69
# -- Options for HTML output -------------------------------------------------
54
70
55
71
# The theme to use for HTML and HTML Help pages. See the documentation for
56
72
# a list of builtin themes.
57
73
#
58
- html_theme = 'sphinx_material '
74
+ html_theme = 'pytorch_sphinx_theme '
59
75
60
76
# Add any paths that contain custom static files (such as style sheets) here,
61
77
# relative to this directory. They are copied after the builtin static files,
84
100
html_show_sourcelink = True
85
101
html_sidebars = {"**" : ["logo-text.html" , "globaltoc.html" , "localtoc.html" , "searchbox.html" ]}
86
102
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 "
91
107
92
108
# Material theme options (see theme.conf for more information)
93
109
html_theme_options = {
138
154
139
155
# Tell sphinx what the pygments highlight language should be.
140
156
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
0 commit comments