3
0

conf.py 7.9 KB

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