conf_common.py 13 KB

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