conf.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. #
  4. # MicroPython documentation build configuration file, created by
  5. # sphinx-quickstart on Sun Sep 21 11:42:03 2014.
  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. import sys
  16. import os
  17. # If extensions (or modules to document with autodoc) are in another directory,
  18. # add these directories to sys.path here. If the directory is relative to the
  19. # documentation root, use os.path.abspath to make it absolute, like shown here.
  20. sys.path.insert(0, os.path.abspath('.'))
  21. # Work out the port to generate the docs for
  22. from collections import OrderedDict
  23. micropy_port = os.getenv('MICROPY_PORT') or 'pyboard'
  24. tags.add('port_' + micropy_port)
  25. ports = OrderedDict((
  26. ('unix', 'unix'),
  27. ('pyboard', 'the pyboard'),
  28. ('wipy', 'the WiPy'),
  29. ('esp8266', 'the ESP8266'),
  30. ))
  31. # The members of the html_context dict are available inside topindex.html
  32. micropy_version = os.getenv('MICROPY_VERSION') or 'latest'
  33. micropy_all_versions = (os.getenv('MICROPY_ALL_VERSIONS') or 'latest').split(',')
  34. url_pattern = '%s/en/%%s/%%s' % (os.getenv('MICROPY_URL_PREFIX') or '/',)
  35. html_context = {
  36. 'port':micropy_port,
  37. 'port_name':ports[micropy_port],
  38. 'port_version':micropy_version,
  39. 'all_ports':[
  40. (port_id, url_pattern % (micropy_version, port_id))
  41. for port_id, port_name in ports.items()
  42. ],
  43. 'all_versions':[
  44. (ver, url_pattern % (ver, micropy_port))
  45. for ver in micropy_all_versions
  46. ],
  47. 'downloads':[
  48. ('PDF', url_pattern % (micropy_version, 'micropython-%s.pdf' % micropy_port)),
  49. ],
  50. }
  51. # Specify a custom master document based on the port name
  52. master_doc = micropy_port + '_' + 'index'
  53. # -- General configuration ------------------------------------------------
  54. # If your documentation needs a minimal Sphinx version, state it here.
  55. #needs_sphinx = '1.0'
  56. # Add any Sphinx extension module names here, as strings. They can be
  57. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  58. # ones.
  59. extensions = [
  60. 'sphinx.ext.autodoc',
  61. 'sphinx.ext.doctest',
  62. 'sphinx.ext.intersphinx',
  63. 'sphinx.ext.todo',
  64. 'sphinx.ext.coverage',
  65. 'sphinx_selective_exclude.modindex_exclude',
  66. 'sphinx_selective_exclude.eager_only',
  67. 'sphinx_selective_exclude.search_auto_exclude',
  68. ]
  69. # Add any paths that contain templates here, relative to this directory.
  70. templates_path = ['templates']
  71. # The suffix of source filenames.
  72. source_suffix = '.rst'
  73. # The encoding of source files.
  74. #source_encoding = 'utf-8-sig'
  75. # The master toctree document.
  76. #master_doc = 'index'
  77. # General information about the project.
  78. project = 'MicroPython'
  79. copyright = '2014-2018, Damien P. George, Paul Sokolovsky, and contributors'
  80. # The version info for the project you're documenting, acts as replacement for
  81. # |version| and |release|, also used in various other places throughout the
  82. # built documents.
  83. #
  84. # We don't follow "The short X.Y version" vs "The full version, including alpha/beta/rc tags"
  85. # breakdown, so use the same version identifier for both to avoid confusion.
  86. version = release = '1.9.4'
  87. # The language for content autogenerated by Sphinx. Refer to documentation
  88. # for a list of supported languages.
  89. #language = None
  90. # There are two options for replacing |today|: either, you set today to some
  91. # non-false value, then it is used:
  92. #today = ''
  93. # Else, today_fmt is used as the format for a strftime call.
  94. #today_fmt = '%B %d, %Y'
  95. # List of patterns, relative to source directory, that match files and
  96. # directories to ignore when looking for source files.
  97. exclude_patterns = ['build', '.venv']
  98. # The reST default role (used for this markup: `text`) to use for all
  99. # documents.
  100. default_role = 'any'
  101. # If true, '()' will be appended to :func: etc. cross-reference text.
  102. #add_function_parentheses = True
  103. # If true, the current module name will be prepended to all description
  104. # unit titles (such as .. function::).
  105. #add_module_names = True
  106. # If true, sectionauthor and moduleauthor directives will be shown in the
  107. # output. They are ignored by default.
  108. #show_authors = False
  109. # The name of the Pygments (syntax highlighting) style to use.
  110. pygments_style = 'sphinx'
  111. # A list of ignored prefixes for module index sorting.
  112. #modindex_common_prefix = []
  113. # If true, keep warnings as "system message" paragraphs in the built documents.
  114. #keep_warnings = False
  115. # Global include files. Sphinx docs suggest using rst_epilog in preference
  116. # of rst_prolog, so we follow. Absolute paths below mean "from the base
  117. # of the doctree".
  118. rst_epilog = """
  119. .. include:: /templates/replace.inc
  120. """
  121. # -- Options for HTML output ----------------------------------------------
  122. # on_rtd is whether we are on readthedocs.org
  123. on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
  124. if not on_rtd: # only import and set the theme if we're building docs locally
  125. try:
  126. import sphinx_rtd_theme
  127. html_theme = 'sphinx_rtd_theme'
  128. html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
  129. except:
  130. html_theme = 'default'
  131. html_theme_path = ['.']
  132. else:
  133. html_theme_path = ['.']
  134. # Theme options are theme-specific and customize the look and feel of a theme
  135. # further. For a list of options available for each theme, see the
  136. # documentation.
  137. #html_theme_options = {}
  138. # Add any paths that contain custom themes here, relative to this directory.
  139. # html_theme_path = ['.']
  140. # The name for this set of Sphinx documents. If None, it defaults to
  141. # "<project> v<release> documentation".
  142. #html_title = None
  143. # A shorter title for the navigation bar. Default is the same as html_title.
  144. #html_short_title = None
  145. # The name of an image file (relative to this directory) to place at the top
  146. # of the sidebar.
  147. #html_logo = '../../logo/trans-logo.png'
  148. # The name of an image file (within the static path) to use as favicon of the
  149. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  150. # pixels large.
  151. html_favicon = 'favicon.ico'
  152. # Add any paths that contain custom static files (such as style sheets) here,
  153. # relative to this directory. They are copied after the builtin static files,
  154. # so a file named "default.css" will overwrite the builtin "default.css".
  155. html_static_path = ['static']
  156. # Add any extra paths that contain custom files (such as robots.txt or
  157. # .htaccess) here, relative to this directory. These files are copied
  158. # directly to the root of the documentation.
  159. #html_extra_path = []
  160. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  161. # using the given strftime format.
  162. html_last_updated_fmt = '%d %b %Y'
  163. # If true, SmartyPants will be used to convert quotes and dashes to
  164. # typographically correct entities.
  165. #html_use_smartypants = True
  166. # Custom sidebar templates, maps document names to template names.
  167. #html_sidebars = {}
  168. # Additional templates that should be rendered to pages, maps page names to
  169. # template names.
  170. html_additional_pages = {"index": "topindex.html"}
  171. # If false, no module index is generated.
  172. #html_domain_indices = True
  173. # If false, no index is generated.
  174. #html_use_index = True
  175. # If true, the index is split into individual pages for each letter.
  176. #html_split_index = False
  177. # If true, links to the reST sources are added to the pages.
  178. #html_show_sourcelink = True
  179. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  180. #html_show_sphinx = True
  181. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  182. #html_show_copyright = True
  183. # If true, an OpenSearch description file will be output, and all pages will
  184. # contain a <link> tag referring to it. The value of this option must be the
  185. # base URL from which the finished HTML is served.
  186. #html_use_opensearch = ''
  187. # This is the file name suffix for HTML files (e.g. ".xhtml").
  188. #html_file_suffix = None
  189. # Output file base name for HTML help builder.
  190. htmlhelp_basename = 'MicroPythondoc'
  191. # -- Options for LaTeX output ---------------------------------------------
  192. latex_elements = {
  193. # The paper size ('letterpaper' or 'a4paper').
  194. #'papersize': 'letterpaper',
  195. # The font size ('10pt', '11pt' or '12pt').
  196. #'pointsize': '10pt',
  197. # Additional stuff for the LaTeX preamble.
  198. #'preamble': '',
  199. # Include 3 levels of headers in PDF ToC
  200. 'preamble': '\setcounter{tocdepth}{2}',
  201. }
  202. # Grouping the document tree into LaTeX files. List of tuples
  203. # (source start file, target name, title,
  204. # author, documentclass [howto, manual, or own class]).
  205. latex_documents = [
  206. (master_doc, 'MicroPython.tex', 'MicroPython Documentation',
  207. 'Damien P. George, Paul Sokolovsky, and contributors', 'manual'),
  208. ]
  209. # The name of an image file (relative to this directory) to place at the top of
  210. # the title page.
  211. #latex_logo = None
  212. # For "manual" documents, if this is true, then toplevel headings are parts,
  213. # not chapters.
  214. #latex_use_parts = False
  215. # If true, show page references after internal links.
  216. #latex_show_pagerefs = False
  217. # If true, show URL addresses after external links.
  218. #latex_show_urls = False
  219. # Documents to append as an appendix to all manuals.
  220. #latex_appendices = []
  221. # If false, no module index is generated.
  222. #latex_domain_indices = True
  223. # -- Options for manual page output ---------------------------------------
  224. # One entry per manual page. List of tuples
  225. # (source start file, name, description, authors, manual section).
  226. man_pages = [
  227. ('index', 'micropython', 'MicroPython Documentation',
  228. ['Damien P. George, Paul Sokolovsky, and contributors'], 1),
  229. ]
  230. # If true, show URL addresses after external links.
  231. #man_show_urls = False
  232. # -- Options for Texinfo output -------------------------------------------
  233. # Grouping the document tree into Texinfo files. List of tuples
  234. # (source start file, target name, title, author,
  235. # dir menu entry, description, category)
  236. texinfo_documents = [
  237. (master_doc, 'MicroPython', 'MicroPython Documentation',
  238. 'Damien P. George, Paul Sokolovsky, and contributors', 'MicroPython', 'One line description of project.',
  239. 'Miscellaneous'),
  240. ]
  241. # Documents to append as an appendix to all manuals.
  242. #texinfo_appendices = []
  243. # If false, no module index is generated.
  244. #texinfo_domain_indices = True
  245. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  246. #texinfo_show_urls = 'footnote'
  247. # If true, do not generate a @detailmenu in the "Top" node's menu.
  248. #texinfo_no_detailmenu = False
  249. # Example configuration for intersphinx: refer to the Python standard library.
  250. intersphinx_mapping = {'python': ('http://docs.python.org/3.5', None)}
  251. # Append the other ports' specific folders/files to the exclude pattern
  252. exclude_patterns.extend([port + '*' for port in ports if port != micropy_port])
  253. modules_port_specific = {
  254. 'pyboard': ['pyb'],
  255. 'wipy': ['wipy'],
  256. 'esp8266': ['esp'],
  257. }
  258. modindex_exclude = []
  259. for p, l in modules_port_specific.items():
  260. if p != micropy_port:
  261. modindex_exclude += l
  262. # Exclude extra modules per port
  263. modindex_exclude += {
  264. 'esp8266': ['cmath', 'select'],
  265. 'wipy': ['cmath'],
  266. }.get(micropy_port, [])