You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

conf.py 8.2 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
  3. # flake8: noqa
  4. # Configuration file for the Sphinx documentation builder.
  5. #
  6. # This file does only contain a selection of the most common options. For a
  7. # full list see the documentation:
  8. # http://www.sphinx-doc.org/en/master/config
  9. # -- Path setup --------------------------------------------------------------
  10. # If extensions (or modules to document with autodoc) are in another directory,
  11. # add these directories to sys.path here. If the directory is relative to the
  12. # documentation root, use os.path.abspath to make it absolute, like shown here.
  13. #
  14. import os
  15. import sys
  16. import mock
  17. # The theme to use for HTML and HTML Help pages. See the documentation for
  18. # a list of builtin themes.
  19. #
  20. import sphinx_rtd_theme
  21. # The suffix(es) of source filenames.
  22. # You can specify multiple suffix as a list of string:
  23. #
  24. # to support markdown
  25. from recommonmark.parser import CommonMarkParser
  26. sys.path.insert(0, os.path.abspath("../"))
  27. DEPLOY = os.environ.get("READTHEDOCS") == "True"
  28. # -- Project information -----------------------------------------------------
  29. try:
  30. import torch # noqa
  31. except ImportError:
  32. for m in [
  33. "torch",
  34. "torchvision",
  35. "torch.nn",
  36. "torch.nn.parallel",
  37. "torch.distributed",
  38. "torch.multiprocessing",
  39. "torch.autograd",
  40. "torch.autograd.function",
  41. "torch.nn.modules",
  42. "torch.nn.modules.utils",
  43. "torch.utils",
  44. "torch.utils.data",
  45. "torchvision",
  46. "torchvision.ops",
  47. ]:
  48. sys.modules[m] = mock.Mock(name=m)
  49. for m in [
  50. "cv2",
  51. "scipy",
  52. "portalocker",
  53. "detectron2._C",
  54. "pycocotools",
  55. "pycocotools.mask",
  56. "pycocotools.coco",
  57. "pycocotools.cocoeval",
  58. ]:
  59. sys.modules[m] = mock.Mock(name=m)
  60. sys.modules["cv2"].__version__ = "3.4"
  61. import detectron2 # isort: skip
  62. project = "detectron2"
  63. copyright = "2019, detectron2 contributors"
  64. author = "detectron2 contributors"
  65. # The short X.Y version
  66. version = detectron2.__version__
  67. # The full version, including alpha/beta/rc tags
  68. release = version
  69. # -- General configuration ---------------------------------------------------
  70. # If your documentation needs a minimal Sphinx version, state it here.
  71. #
  72. needs_sphinx = "1.7"
  73. # Add any Sphinx extension module names here, as strings. They can be
  74. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  75. # ones.
  76. extensions = [
  77. "sphinx.ext.autodoc",
  78. "sphinx.ext.napoleon",
  79. "sphinx.ext.intersphinx",
  80. "sphinx.ext.todo",
  81. "sphinx.ext.coverage",
  82. "sphinx.ext.mathjax",
  83. "sphinx.ext.viewcode",
  84. "sphinx.ext.githubpages",
  85. ]
  86. # -- Configurations for plugins ------------
  87. napoleon_google_docstring = True
  88. napoleon_include_init_with_doc = True
  89. napoleon_include_special_with_doc = True
  90. napoleon_numpy_docstring = False
  91. napoleon_use_rtype = False
  92. autodoc_inherit_docstrings = False
  93. autodoc_member_order = "bysource"
  94. if DEPLOY:
  95. intersphinx_timeout = 10
  96. else:
  97. # skip this when building locally
  98. intersphinx_timeout = 0.1
  99. intersphinx_mapping = {
  100. "python": ("https://docs.python.org/3.6", None),
  101. "numpy": ("https://docs.scipy.org/doc/numpy/", None),
  102. "torch": ("https://pytorch.org/docs/master/", None),
  103. }
  104. # -------------------------
  105. # Add any paths that contain templates here, relative to this directory.
  106. templates_path = ["_templates"]
  107. source_parsers = {".md": CommonMarkParser}
  108. source_suffix = [".rst", ".md"]
  109. # The master toctree document.
  110. master_doc = "index"
  111. # The language for content autogenerated by Sphinx. Refer to documentation
  112. # for a list of supported languages.
  113. #
  114. # This is also used if you do content translation via gettext catalogs.
  115. # Usually you set "language" from the command line for these cases.
  116. language = None
  117. # List of patterns, relative to source directory, that match files and
  118. # directories to ignore when looking for source files.
  119. # This pattern also affects html_static_path and html_extra_path.
  120. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "build", "README.md"]
  121. # The name of the Pygments (syntax highlighting) style to use.
  122. pygments_style = "sphinx"
  123. # -- Options for HTML output -------------------------------------------------
  124. html_theme = "sphinx_rtd_theme"
  125. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  126. # Theme options are theme-specific and customize the look and feel of a theme
  127. # further. For a list of options available for each theme, see the
  128. # documentation.
  129. #
  130. # html_theme_options = {}
  131. # Add any paths that contain custom static files (such as style sheets) here,
  132. # relative to this directory. They are copied after the builtin static files,
  133. # so a file named "default.css" will overwrite the builtin "default.css".
  134. html_static_path = ["_static"]
  135. # Custom sidebar templates, must be a dictionary that maps document names
  136. # to template names.
  137. #
  138. # The default sidebars (for documents that don't match any pattern) are
  139. # defined by theme itself. Builtin themes are using these templates by
  140. # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
  141. # 'searchbox.html']``.
  142. #
  143. # html_sidebars = {}
  144. # -- Options for HTMLHelp output ---------------------------------------------
  145. # Output file base name for HTML help builder.
  146. htmlhelp_basename = "detectron2doc"
  147. # -- Options for LaTeX output ------------------------------------------------
  148. latex_elements = {
  149. # The paper size ('letterpaper' or 'a4paper').
  150. #
  151. # 'papersize': 'letterpaper',
  152. # The font size ('10pt', '11pt' or '12pt').
  153. #
  154. # 'pointsize': '10pt',
  155. # Additional stuff for the LaTeX preamble.
  156. #
  157. # 'preamble': '',
  158. # Latex figure (float) alignment
  159. #
  160. # 'figure_align': 'htbp',
  161. }
  162. # Grouping the document tree into LaTeX files. List of tuples
  163. # (source start file, target name, title,
  164. # author, documentclass [howto, manual, or own class]).
  165. latex_documents = [
  166. (master_doc, "detectron2.tex", "detectron2 Documentation", "detectron2 contributors", "manual")
  167. ]
  168. # -- Options for manual page output ------------------------------------------
  169. # One entry per manual page. List of tuples
  170. # (source start file, name, description, authors, manual section).
  171. man_pages = [(master_doc, "detectron2", "detectron2 Documentation", [author], 1)]
  172. # -- Options for Texinfo output ----------------------------------------------
  173. # Grouping the document tree into Texinfo files. List of tuples
  174. # (source start file, target name, title, author,
  175. # dir menu entry, description, category)
  176. texinfo_documents = [
  177. (
  178. master_doc,
  179. "detectron2",
  180. "detectron2 Documentation",
  181. author,
  182. "detectron2",
  183. "One line description of project.",
  184. "Miscellaneous",
  185. )
  186. ]
  187. # -- Options for todo extension ----------------------------------------------
  188. # If true, `todo` and `todoList` produce output, else they produce nothing.
  189. todo_include_todos = True
  190. _DEPRECATED_NAMES = set(["out_feature_channels", "out_feature_strides", "out_features"])
  191. def autodoc_skip_member(app, what, name, obj, skip, options):
  192. # we hide something deliberately
  193. if getattr(obj, "__HIDE_SPHINX_DOC__", False):
  194. return True
  195. # Hide some names that are deprecated or not intended to be used
  196. if name in _DEPRECATED_NAMES:
  197. return True
  198. return None
  199. def url_resolver(url):
  200. if ".html" not in url:
  201. url = url.replace("../", "")
  202. return "https://github.com/facebookresearch/detectron2/blob/master/" + url
  203. else:
  204. if DEPLOY:
  205. return "http://detectron2.readthedocs.io/" + url
  206. else:
  207. return "/" + url
  208. def setup(app):
  209. from recommonmark.transform import AutoStructify
  210. app.connect("autodoc-skip-member", autodoc_skip_member)
  211. # app.connect('autodoc-skip-member', autodoc_skip_member)
  212. app.add_config_value(
  213. "recommonmark_config",
  214. {
  215. "url_resolver": url_resolver,
  216. "auto_toc_tree_section": "Contents",
  217. "enable_math": True,
  218. "enable_inline_math": True,
  219. "enable_eval_rst": True,
  220. },
  221. True,
  222. )
  223. app.add_transform(AutoStructify)

No Description