CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ai-forever

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: ai-forever/sber-swap
Path: blob/main/apex/docs/source/conf.py
Views: 792
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
#
4
# PyTorch documentation build configuration file, created by
5
# sphinx-quickstart on Fri Dec 23 13:31:47 2016.
6
#
7
# This file is execfile()d with the current directory set to its
8
# containing dir.
9
#
10
# Note that not all possible configuration values are present in this
11
# autogenerated file.
12
#
13
# All configuration values have a default; values that are commented out
14
# serve to show the default.
15
16
# If extensions (or modules to document with autodoc) are in another directory,
17
# add these directories to sys.path here. If the directory is relative to the
18
# documentation root, use os.path.abspath to make it absolute, like shown here.
19
#
20
import os
21
import sys
22
sys.path.insert(0, os.path.abspath('.'))
23
# sys.path.insert(0, os.path.abspath('../../apex/parallel/'))
24
import apex
25
# import multiproc
26
import sphinx_rtd_theme
27
28
29
# -- General configuration ------------------------------------------------
30
31
# If your documentation needs a minimal Sphinx version, state it here.
32
#
33
# needs_sphinx = '1.0'
34
35
# Add any Sphinx extension module names here, as strings. They can be
36
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
37
# ones.
38
extensions = [
39
'sphinx.ext.autodoc',
40
'sphinx.ext.autosummary',
41
'sphinx.ext.doctest',
42
'sphinx.ext.intersphinx',
43
'sphinx.ext.todo',
44
'sphinx.ext.coverage',
45
'sphinx.ext.mathjax',
46
'sphinx.ext.napoleon',
47
'sphinx.ext.viewcode',
48
'sphinx.ext.extlinks',
49
]
50
51
napoleon_use_ivar = True
52
53
# Add any paths that contain templates here, relative to this directory.
54
templates_path = ['_templates']
55
56
# The suffix(es) of source filenames.
57
# You can specify multiple suffix as a list of string:
58
#
59
# source_suffix = ['.rst', '.md']
60
source_suffix = '.rst'
61
62
# The master toctree document.
63
master_doc = 'index'
64
65
# General information about the project.
66
project = 'Apex'
67
copyright = '2018'
68
author = 'Christian Sarofeen, Natalia Gimelshein, Michael Carilli, Raul Puri'
69
70
# The version info for the project you're documenting, acts as replacement for
71
# |version| and |release|, also used in various other places throughout the
72
# built documents.
73
#
74
# The short X.Y version.
75
# TODO: change to [:2] at v1.0
76
# version = 'master (' + torch.__version__ + ' )'
77
version = '0.1'
78
# The full version, including alpha/beta/rc tags.
79
# TODO: verify this works as expected
80
release = '0.1.0'
81
82
# The language for content autogenerated by Sphinx. Refer to documentation
83
# for a list of supported languages.
84
#
85
# This is also used if you do content translation via gettext catalogs.
86
# Usually you set "language" from the command line for these cases.
87
language = None
88
89
# List of patterns, relative to source directory, that match files and
90
# directories to ignore when looking for source files.
91
# This pattern also affects html_static_path and html_extra_path
92
exclude_patterns = []
93
94
# The name of the Pygments (syntax highlighting) style to use.
95
pygments_style = 'sphinx'
96
97
# If true, `todo` and `todoList` produce output, else they produce nothing.
98
todo_include_todos = True
99
100
101
# -- Options for HTML output -------------------------------------------------
102
103
# The theme to use for HTML and HTML Help pages. See the documentation for
104
# a list of builtin themes.
105
#
106
html_theme = 'sphinx_rtd_theme'
107
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
108
109
# Theme options are theme-specific and customize the look and feel of a theme
110
# further. For a list of options available for each theme, see the
111
# documentation.
112
#
113
html_theme_options = {
114
'collapse_navigation': False,
115
'display_version': True,
116
'logo_only': True,
117
}
118
119
# html_logo = '_static/img/nv-pytorch2.png'
120
121
# Add any paths that contain custom static files (such as style sheets) here,
122
# relative to this directory. They are copied after the builtin static files,
123
# so a file named "default.css" will overwrite the builtin "default.css".
124
html_static_path = ['_static']
125
126
# html_style_path = 'css/pytorch_theme.css'
127
html_context = {
128
'css_files': [
129
'https://fonts.googleapis.com/css?family=Lato',
130
'_static/css/pytorch_theme.css'
131
],
132
}
133
134
135
# -- Options for HTMLHelp output ---------------------------------------------
136
137
# Output file base name for HTML help builder.
138
htmlhelp_basename = 'PyTorchdoc'
139
140
141
# -- Options for LaTeX output ------------------------------------------------
142
143
latex_elements = {
144
# The paper size ('letterpaper' or 'a4paper').
145
#
146
# 'papersize': 'letterpaper',
147
148
# The font size ('10pt', '11pt' or '12pt').
149
#
150
# 'pointsize': '10pt',
151
152
# Additional stuff for the LaTeX preamble.
153
#
154
# 'preamble': '',
155
156
# Latex figure (float) alignment
157
#
158
# 'figure_align': 'htbp',
159
}
160
161
# Grouping the document tree into LaTeX files. List of tuples
162
# (source start file, target name, title,
163
# author, documentclass [howto, manual, or own class]).
164
latex_documents = [
165
(master_doc, 'apex.tex', 'Apex Documentation',
166
'Torch Contributors', 'manual'),
167
]
168
169
170
# -- Options for manual page output ------------------------------------------
171
172
# One entry per manual page. List of tuples
173
# (source start file, name, description, authors, manual section).
174
man_pages = [
175
(master_doc, 'Apex', 'Apex Documentation',
176
[author], 1)
177
]
178
179
180
# -- Options for Texinfo output ----------------------------------------------
181
182
# Grouping the document tree into Texinfo files. List of tuples
183
# (source start file, target name, title, author,
184
# dir menu entry, description, category)
185
texinfo_documents = [
186
(master_doc, 'Apex', 'Apex Documentation',
187
author, 'Apex', 'One line description of project.',
188
'Miscellaneous'),
189
]
190
191
192
# Example configuration for intersphinx: refer to the Python standard library.
193
intersphinx_mapping = {
194
'python': ('https://docs.python.org/', None),
195
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
196
}
197
198
# -- A patch that prevents Sphinx from cross-referencing ivar tags -------
199
# See http://stackoverflow.com/a/41184353/3343043
200
201
from docutils import nodes
202
from sphinx.util.docfields import TypedField
203
from sphinx import addnodes
204
205
206
def patched_make_field(self, types, domain, items, **kw):
207
# `kw` catches `env=None` needed for newer sphinx while maintaining
208
# backwards compatibility when passed along further down!
209
210
# type: (List, unicode, Tuple) -> nodes.field
211
def handle_item(fieldarg, content):
212
par = nodes.paragraph()
213
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
214
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
215
# addnodes.literal_strong))
216
if fieldarg in types:
217
par += nodes.Text(' (')
218
# NOTE: using .pop() here to prevent a single type node to be
219
# inserted twice into the doctree, which leads to
220
# inconsistencies later when references are resolved
221
fieldtype = types.pop(fieldarg)
222
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
223
typename = u''.join(n.astext() for n in fieldtype)
224
typename = typename.replace('int', 'python:int')
225
typename = typename.replace('long', 'python:long')
226
typename = typename.replace('float', 'python:float')
227
typename = typename.replace('type', 'python:type')
228
par.extend(self.make_xrefs(self.typerolename, domain, typename,
229
addnodes.literal_emphasis, **kw))
230
else:
231
par += fieldtype
232
par += nodes.Text(')')
233
par += nodes.Text(' -- ')
234
par += content
235
return par
236
237
fieldname = nodes.field_name('', self.label)
238
if len(items) == 1 and self.can_collapse:
239
fieldarg, content = items[0]
240
bodynode = handle_item(fieldarg, content)
241
else:
242
bodynode = self.list_type()
243
for fieldarg, content in items:
244
bodynode += nodes.list_item('', handle_item(fieldarg, content))
245
fieldbody = nodes.field_body('', bodynode)
246
return nodes.field('', fieldname, fieldbody)
247
248
TypedField.make_field = patched_make_field
249
250