conf_common.py 12 KB

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