conf.py 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Configuration file for the Sphinx documentation builder.
  4. #
  5. # This file does only contain a selection of the most common options. For a
  6. # full list see the documentation:
  7. # http://www.sphinx-doc.org/en/master/config
  8. # -- Path setup --------------------------------------------------------------
  9. # If extensions (or modules to document with autodoc) are in another directory,
  10. # add these directories to sys.path here. If the directory is relative to the
  11. # documentation root, use os.path.abspath to make it absolute, like shown here.
  12. #
  13. # import os
  14. # import sys
  15. # sys.path.insert(0, os.path.abspath('.'))
  16. import sys
  17. from recommonmark.transform import AutoStructify
  18. from recommonmark.parser import CommonMarkParser
  19. # -- Project information -----------------------------------------------------
  20. sys.path.insert(0, '..')
  21. src_path = '../tesseract'
  22. project = 'tesseract'
  23. copyright = '2020, Learning@home & contributors'
  24. author = 'Learning@home & contributors'
  25. # The short X.Y version
  26. version = ''
  27. # The full version, including alpha/beta/rc tags
  28. release = 'latest'
  29. branch = 'master'
  30. # -- General configuration ---------------------------------------------------
  31. # If your documentation needs a minimal Sphinx version, state it here.
  32. #
  33. # needs_sphinx = '1.0'
  34. # Add any Sphinx extension module names here, as strings. They can be
  35. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  36. # ones.
  37. extensions = [
  38. 'sphinx.ext.autodoc',
  39. 'sphinx.ext.autosummary',
  40. 'sphinx.ext.intersphinx',
  41. 'sphinx.ext.todo',
  42. 'sphinx.ext.coverage',
  43. 'sphinx.ext.mathjax',
  44. 'sphinx.ext.ifconfig',
  45. # 'sphinx.ext.viewcode', # create HTML file of source code and link to it
  46. 'sphinx.ext.linkcode', # link to github, see linkcode_resolve() below
  47. # 'numpydoc',
  48. 'sphinx.ext.napoleon', # alternative to numpydoc
  49. ]
  50. # see http://stackoverflow.com/q/12206334/562769
  51. # numpydoc_show_class_members = False
  52. # Napoleon settings
  53. napoleon_google_docstring = False
  54. napoleon_numpy_docstring = True
  55. napoleon_include_init_with_doc = True
  56. napoleon_include_private_with_doc = False
  57. napoleon_include_special_with_doc = True
  58. napoleon_use_admonition_for_examples = False
  59. napoleon_use_admonition_for_notes = False
  60. napoleon_use_admonition_for_references = False
  61. napoleon_use_ivar = False
  62. napoleon_use_param = True
  63. napoleon_use_rtype = True
  64. # Add any paths that contain templates here, relative to this directory.
  65. templates_path = ['_templates']
  66. # The suffix(es) of source filenames.
  67. # You can specify multiple suffix as a list of string:
  68. #
  69. source_suffix = ['.rst', '.md']
  70. source_parsers = {
  71. '.md': CommonMarkParser,
  72. }
  73. # The master toctree document.
  74. master_doc = 'index'
  75. # The language for content autogenerated by Sphinx. Refer to documentation
  76. # for a list of supported languages.
  77. #
  78. # This is also used if you do content translation via gettext catalogs.
  79. # Usually you set "language" from the command line for these cases.
  80. language = None
  81. # List of patterns, relative to source directory, that match files and
  82. # directories to ignore when looking for source files.
  83. # This pattern also affects html_static_path and html_extra_path.
  84. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
  85. # The name of the Pygments (syntax highlighting) style to use.
  86. pygments_style = None
  87. # -- Options for HTML output -------------------------------------------------
  88. # The theme to use for HTML and HTML Help pages. See the documentation for
  89. # a list of builtin themes.
  90. #
  91. html_theme = 'sphinx_rtd_theme'
  92. # Theme options are theme-specific and customize the look and feel of a theme
  93. # further. For a list of options available for each theme, see the
  94. # documentation.
  95. #
  96. # html_theme_options = {}
  97. # Add any paths that contain custom static files (such as style sheets) here,
  98. # relative to this directory. They are copied after the builtin static files,
  99. # so a file named "default.css" will overwrite the builtin "default.css".
  100. html_static_path = ['_static']
  101. # Custom sidebar templates, must be a dictionary that maps document names
  102. # to template names.
  103. #
  104. # The default sidebars (for documents that don't match any pattern) are
  105. # defined by theme itself. Builtin themes are using these templates by
  106. # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
  107. # 'searchbox.html']``.
  108. #
  109. # html_sidebars = {}
  110. # -- Options for HTMLHelp output ---------------------------------------------
  111. # Output file base name for HTML help builder.
  112. htmlhelp_basename = 'tesseractdoc'
  113. # -- Options for LaTeX output ------------------------------------------------
  114. latex_elements = {
  115. # The paper size ('letterpaper' or 'a4paper').
  116. #
  117. # 'papersize': 'letterpaper',
  118. # The font size ('10pt', '11pt' or '12pt').
  119. #
  120. # 'pointsize': '10pt',
  121. # Additional stuff for the LaTeX preamble.
  122. #
  123. # 'preamble': '',
  124. # Latex figure (float) alignment
  125. #
  126. # 'figure_align': 'htbp',
  127. }
  128. # Grouping the document tree into LaTeX files. List of tuples
  129. # (source start file, target name, title,
  130. # author, documentclass [howto, manual, or own class]).
  131. latex_documents = [
  132. (master_doc, 'tesseract.tex', 'tesseract Documentation',
  133. 'Learning@home \\& contributors', 'manual'),
  134. ]
  135. # -- Options for manual page output ------------------------------------------
  136. # One entry per manual page. List of tuples
  137. # (source start file, name, description, authors, manual section).
  138. man_pages = [
  139. (master_doc, 'tesseract', 'tesseract Documentation',
  140. [author], 1)
  141. ]
  142. # -- Options for Texinfo output ----------------------------------------------
  143. # Grouping the document tree into Texinfo files. List of tuples
  144. # (source start file, target name, title, author,
  145. # dir menu entry, description, category)
  146. texinfo_documents = [
  147. (master_doc, 'tesseract', 'tesseract Documentation',
  148. author, 'tesseract', 'One line description of project.',
  149. 'Miscellaneous'),
  150. ]
  151. # -- Options for Epub output -------------------------------------------------
  152. # Bibliographic Dublin Core info.
  153. epub_title = project
  154. # The unique identifier of the text. This can be a ISBN number
  155. # or the project homepage.
  156. #
  157. # epub_identifier = ''
  158. # A unique identification for the text.
  159. #
  160. # epub_uid = ''
  161. # A list of files that should not be packed into the epub file.
  162. epub_exclude_files = ['search.html']
  163. # -- Extension configuration -------------------------------------------------
  164. # -- Options for intersphinx extension ---------------------------------------
  165. # Example configuration for intersphinx: refer to the Python standard library.
  166. intersphinx_mapping = {'https://docs.python.org/': None}
  167. # -- Options for todo extension ----------------------------------------------
  168. # If true, `todo` and `todoList` produce output, else they produce nothing.
  169. todo_include_todos = True
  170. # markdown autostructify
  171. def setup(app):
  172. github_doc_root = 'https://github.com/rtfd/recommonmark/tree/master/doc/' # TODO
  173. app.add_config_value('recommonmark_config', {
  174. 'url_resolver': lambda url: github_doc_root + url,
  175. 'auto_toc_tree_section': 'Contents',
  176. 'enable_math': True,
  177. 'enable_inline_math': True,
  178. 'enable_eval_rst': True,
  179. # 'enable_auto_doc_ref': True,
  180. }, True)
  181. app.add_transform(AutoStructify)
  182. # Resolve function for the linkcode extension.
  183. def linkcode_resolve(domain, info):
  184. def find_source():
  185. # try to find the file and line number, based on code from numpy:
  186. # https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
  187. obj = sys.modules[info['module']]
  188. for part in info['fullname'].split('.'):
  189. obj = getattr(obj, part)
  190. import inspect
  191. import os
  192. fn = inspect.getsourcefile(obj)
  193. fn = os.path.relpath(fn, start=os.path.dirname(src_path))
  194. source, lineno = inspect.getsourcelines(obj)
  195. return fn, lineno, lineno + len(source) - 1
  196. if domain != 'py' or not info['module']:
  197. return None
  198. try:
  199. filename = 'tesseract/%s#L%d-L%d' % find_source()
  200. except Exception:
  201. filename = info['module'].replace('.', '/') + '.py'
  202. return "https://github.com/learning-at-home/tesseract/blob/%s/%s" % (branch, filename)