conf_common.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Common (non-language-specific) configuration for Read The Docs & Sphinx
  4. #
  5. # Based on a Read the Docs Template documentation build configuration file,
  6. # created by sphinx-quickstart on Tue Aug 26 14:19:49 2014.
  7. #
  8. # This file is imported from a language-specific conf.py (ie en/conf.py or
  9. # zh_CN/conf.py)
  10. #
  11. # Note that not all possible configuration values are present in this
  12. # autogenerated file.
  13. #
  14. # All configuration values have a default; values that are commented out
  15. # serve to show the default.
  16. import sys, os
  17. import re
  18. from subprocess import Popen, PIPE
  19. import shlex
  20. # Note: If extensions (or modules to document with autodoc) are in another directory,
  21. # add these directories to sys.path here. If the directory is relative to the
  22. # documentation root, use os.path.abspath to make it absolute
  23. from local_util import run_cmd_get_output, copy_if_modified
  24. builddir = '_build'
  25. builddir = builddir
  26. if 'BUILDDIR' in os.environ:
  27. builddir = os.environ['BUILDDIR']
  28. # Call Doxygen to get XML files from the header files
  29. print("Calling Doxygen to generate latest XML files")
  30. if os.system("doxygen ../Doxyfile") != 0:
  31. raise RuntimeError('Doxygen call failed')
  32. # Doxygen has generated XML files in 'xml' directory.
  33. # Copy them to 'xml_in', only touching the files which have changed.
  34. copy_if_modified('xml/', 'xml_in/')
  35. # Generate 'api_name.inc' files using the XML files by Doxygen
  36. if os.system('python ../gen-dxd.py') != 0:
  37. raise RuntimeError('gen-dxd.py failed')
  38. # Generate 'kconfig.inc' file from components' Kconfig files
  39. kconfig_inc_path = '{}/inc/kconfig.inc'.format(builddir)
  40. if os.system('python ../gen-kconfig-doc.py > ' + kconfig_inc_path + '.in') != 0:
  41. raise RuntimeError('gen-kconfig-doc.py failed')
  42. copy_if_modified(kconfig_inc_path + '.in', kconfig_inc_path)
  43. # Generate 'esp_err_defs.inc' file with ESP_ERR_ error code definitions
  44. esp_err_inc_path = '{}/inc/esp_err_defs.inc'.format(builddir)
  45. if os.system('python ../../tools/gen_esp_err_to_name.py --rst_output ' + esp_err_inc_path + '.in') != 0:
  46. raise RuntimeError('gen_esp_err_to_name.py failed')
  47. copy_if_modified(esp_err_inc_path + '.in', esp_err_inc_path)
  48. # Generate version-related includes
  49. #
  50. # (Note: this is in a function as it needs to access configuration to get the language)
  51. def generate_version_specific_includes(app):
  52. print("Generating version-specific includes...")
  53. version_tmpdir = '{}/version_inc'.format(builddir)
  54. if os.system('python ../gen-version-specific-includes.py {} {}'.format(app.config.language, version_tmpdir)):
  55. raise RuntimeError('gen-version-specific-includes.py failed')
  56. copy_if_modified(version_tmpdir, '{}/inc'.format(builddir))
  57. # http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format
  58. #
  59. suppress_warnings = ['image.nonlocal_uri']
  60. # -- General configuration ------------------------------------------------
  61. # If your documentation needs a minimal Sphinx version, state it here.
  62. #needs_sphinx = '1.0'
  63. # Add any Sphinx extension module names here, as strings. They can be
  64. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  65. # ones.
  66. extensions = ['breathe',
  67. 'link-roles',
  68. 'sphinxcontrib.blockdiag',
  69. 'sphinxcontrib.seqdiag',
  70. 'sphinxcontrib.actdiag',
  71. 'sphinxcontrib.nwdiag',
  72. 'sphinxcontrib.rackdiag',
  73. 'sphinxcontrib.packetdiag'
  74. ]
  75. # Set up font for blockdiag, nwdiag, rackdiag and packetdiag
  76. blockdiag_fontpath = '../_static/DejaVuSans.ttf'
  77. seqdiag_fontpath = '../_static/DejaVuSans.ttf'
  78. actdiag_fontpath = '../_static/DejaVuSans.ttf'
  79. nwdiag_fontpath = '../_static/DejaVuSans.ttf'
  80. rackdiag_fontpath = '../_static/DejaVuSans.ttf'
  81. packetdiag_fontpath = '../_static/DejaVuSans.ttf'
  82. # Breathe extension variables
  83. # Doxygen regenerates files in 'xml/' directory every time,
  84. # but we copy files to 'xml_in/' only when they change, to speed up
  85. # incremental builds.
  86. breathe_projects = { "esp32-idf": "xml_in/" }
  87. breathe_default_project = "esp32-idf"
  88. # Add any paths that contain templates here, relative to this directory.
  89. templates_path = ['_templates']
  90. # The suffix of source filenames.
  91. source_suffix = ['.rst', '.md']
  92. source_parsers = {
  93. '.md': 'recommonmark.parser.CommonMarkParser',
  94. }
  95. # The encoding of source files.
  96. #source_encoding = 'utf-8-sig'
  97. # The master toctree document.
  98. master_doc = 'index'
  99. # The version info for the project you're documenting, acts as replacement for
  100. # |version| and |release|, also used in various other places throughout the
  101. # built documents.
  102. #
  103. # Readthedocs largely ignores 'version' and 'release', and displays one of
  104. # 'latest', tag name, or branch name, depending on the build type.
  105. # Still, this is useful for non-RTD builds.
  106. # This is supposed to be "the short X.Y version", but it's the only version
  107. # visible when you open index.html.
  108. # Display full version to make things less confusing.
  109. version = run_cmd_get_output('git describe')
  110. # The full version, including alpha/beta/rc tags.
  111. # If needed, nearest tag is returned by 'git describe --abbrev=0'.
  112. release = version
  113. print('Version: {0} Release: {1}'.format(version, release))
  114. # There are two options for replacing |today|: either, you set today to some
  115. # non-false value, then it is used:
  116. #today = ''
  117. # Else, today_fmt is used as the format for a strftime call.
  118. #today_fmt = '%B %d, %Y'
  119. # List of patterns, relative to source directory, that match files and
  120. # directories to ignore when looking for source files.
  121. exclude_patterns = ['_build','README.md']
  122. # The reST default role (used for this markup: `text`) to use for all
  123. # documents.
  124. #default_role = None
  125. # If true, '()' will be appended to :func: etc. cross-reference text.
  126. #add_function_parentheses = True
  127. # If true, the current module name will be prepended to all description
  128. # unit titles (such as .. function::).
  129. #add_module_names = True
  130. # If true, sectionauthor and moduleauthor directives will be shown in the
  131. # output. They are ignored by default.
  132. #show_authors = False
  133. # The name of the Pygments (syntax highlighting) style to use.
  134. pygments_style = 'sphinx'
  135. # A list of ignored prefixes for module index sorting.
  136. #modindex_common_prefix = []
  137. # If true, keep warnings as "system message" paragraphs in the built documents.
  138. #keep_warnings = False
  139. # -- Options for HTML output ----------------------------------------------
  140. # The theme to use for HTML and HTML Help pages. See the documentation for
  141. # a list of builtin themes.
  142. html_theme = 'default'
  143. # Theme options are theme-specific and customize the look and feel of a theme
  144. # further. For a list of options available for each theme, see the
  145. # documentation.
  146. #html_theme_options = {}
  147. # Add any paths that contain custom themes here, relative to this directory.
  148. #html_theme_path = []
  149. # The name for this set of Sphinx documents. If None, it defaults to
  150. # "<project> v<release> documentation".
  151. #html_title = None
  152. # A shorter title for the navigation bar. Default is the same as html_title.
  153. #html_short_title = None
  154. # The name of an image file (relative to this directory) to place at the top
  155. # of the sidebar.
  156. html_logo = "../_static/espressif-logo.svg"
  157. # The name of an image file (within the static path) to use as favicon of the
  158. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  159. # pixels large.
  160. #html_favicon = None
  161. # Add any paths that contain custom static files (such as style sheets) here,
  162. # relative to this directory. They are copied after the builtin static files,
  163. # so a file named "default.css" will overwrite the builtin "default.css".
  164. html_static_path = ['../_static']
  165. # Add any extra paths that contain custom files (such as robots.txt or
  166. # .htaccess) here, relative to this directory. These files are copied
  167. # directly to the root of the documentation.
  168. #html_extra_path = []
  169. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  170. # using the given strftime format.
  171. #html_last_updated_fmt = '%b %d, %Y'
  172. # If true, SmartyPants will be used to convert quotes and dashes to
  173. # typographically correct entities.
  174. #html_use_smartypants = True
  175. # Custom sidebar templates, maps document names to template names.
  176. #html_sidebars = {}
  177. # Additional templates that should be rendered to pages, maps page names to
  178. # template names.
  179. #html_additional_pages = {}
  180. # If false, no module index is generated.
  181. #html_domain_indices = True
  182. # If false, no index is generated.
  183. #html_use_index = True
  184. # If true, the index is split into individual pages for each letter.
  185. #html_split_index = False
  186. # If true, links to the reST sources are added to the pages.
  187. #html_show_sourcelink = True
  188. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  189. #html_show_sphinx = True
  190. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  191. #html_show_copyright = True
  192. # If true, an OpenSearch description file will be output, and all pages will
  193. # contain a <link> tag referring to it. The value of this option must be the
  194. # base URL from which the finished HTML is served.
  195. #html_use_opensearch = ''
  196. # This is the file name suffix for HTML files (e.g. ".xhtml").
  197. #html_file_suffix = None
  198. # Output file base name for HTML help builder.
  199. htmlhelp_basename = 'ReadtheDocsTemplatedoc'
  200. # -- Options for LaTeX output ---------------------------------------------
  201. latex_elements = {
  202. # The paper size ('letterpaper' or 'a4paper').
  203. #'papersize': 'letterpaper',
  204. # The font size ('10pt', '11pt' or '12pt').
  205. #'pointsize': '10pt',
  206. # Additional stuff for the LaTeX preamble.
  207. #'preamble': '',
  208. }
  209. # Grouping the document tree into LaTeX files. List of tuples
  210. # (source start file, target name, title,
  211. # author, documentclass [howto, manual, or own class]).
  212. latex_documents = [
  213. ('index', 'ReadtheDocsTemplate.tex', u'Read the Docs Template Documentation',
  214. u'Read the Docs', 'manual'),
  215. ]
  216. # The name of an image file (relative to this directory) to place at the top of
  217. # the title page.
  218. #latex_logo = None
  219. # For "manual" documents, if this is true, then toplevel headings are parts,
  220. # not chapters.
  221. #latex_use_parts = False
  222. # If true, show page references after internal links.
  223. #latex_show_pagerefs = False
  224. # If true, show URL addresses after external links.
  225. #latex_show_urls = False
  226. # Documents to append as an appendix to all manuals.
  227. #latex_appendices = []
  228. # If false, no module index is generated.
  229. #latex_domain_indices = True
  230. # -- Options for manual page output ---------------------------------------
  231. # One entry per manual page. List of tuples
  232. # (source start file, name, description, authors, manual section).
  233. man_pages = [
  234. ('index', 'readthedocstemplate', u'Read the Docs Template Documentation',
  235. [u'Read the Docs'], 1)
  236. ]
  237. # If true, show URL addresses after external links.
  238. #man_show_urls = False
  239. # -- Options for Texinfo output -------------------------------------------
  240. # Grouping the document tree into Texinfo files. List of tuples
  241. # (source start file, target name, title, author,
  242. # dir menu entry, description, category)
  243. texinfo_documents = [
  244. ('index', 'ReadtheDocsTemplate', u'Read the Docs Template Documentation',
  245. u'Read the Docs', 'ReadtheDocsTemplate', 'One line description of project.',
  246. 'Miscellaneous'),
  247. ]
  248. # Documents to append as an appendix to all manuals.
  249. #texinfo_appendices = []
  250. # If false, no module index is generated.
  251. #texinfo_domain_indices = True
  252. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  253. #texinfo_show_urls = 'footnote'
  254. # If true, do not generate a @detailmenu in the "Top" node's menu.
  255. #texinfo_no_detailmenu = False
  256. # -- Use sphinx_rtd_theme for local builds --------------------------------
  257. # ref. https://github.com/snide/sphinx_rtd_theme#using-this-theme-locally-then-building-on-read-the-docs
  258. #
  259. # on_rtd is whether we are on readthedocs.org
  260. on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
  261. if not on_rtd: # only import and set the theme if we're building docs locally
  262. import sphinx_rtd_theme
  263. html_theme = 'sphinx_rtd_theme'
  264. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  265. # otherwise, readthedocs.org uses their theme by default, so no need to specify it
  266. # Override RTD CSS theme to introduce the theme corrections
  267. # https://github.com/rtfd/sphinx_rtd_theme/pull/432
  268. def setup(app):
  269. app.add_stylesheet('theme_overrides.css')
  270. generate_version_specific_includes(app)