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
  19. import os
  20. import os.path
  21. import re
  22. import subprocess
  23. # build_docs on the CI server sometimes fails under Python3. This is a workaround:
  24. sys.setrecursionlimit(3500)
  25. # http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format
  26. #
  27. suppress_warnings = ['image.nonlocal_uri']
  28. # -- General configuration ------------------------------------------------
  29. # If your documentation needs a minimal Sphinx version, state it here.
  30. # needs_sphinx = '1.0'
  31. idf_target = ''
  32. # Add any Sphinx extension module names here, as strings. They can be
  33. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  34. # ones.
  35. extensions = ['breathe',
  36. 'sphinx.ext.todo',
  37. 'sphinxcontrib.blockdiag',
  38. 'sphinxcontrib.seqdiag',
  39. 'sphinxcontrib.actdiag',
  40. 'sphinxcontrib.nwdiag',
  41. 'sphinxcontrib.rackdiag',
  42. 'sphinxcontrib.packetdiag',
  43. 'extensions.html_redirects',
  44. 'extensions.toctree_filter',
  45. 'idf_extensions.include_build_file',
  46. 'idf_extensions.link_roles',
  47. 'idf_extensions.build_system',
  48. 'idf_extensions.esp_err_definitions',
  49. 'idf_extensions.gen_toolchain_links',
  50. 'idf_extensions.gen_version_specific_includes',
  51. 'idf_extensions.kconfig_reference',
  52. 'idf_extensions.run_doxygen',
  53. 'idf_extensions.gen_idf_tools_links',
  54. 'idf_extensions.format_idf_target',
  55. # from https://github.com/pfalcon/sphinx_selective_exclude
  56. 'sphinx_selective_exclude.eager_only',
  57. # TODO: determine if we need search_auto_exclude
  58. # 'sphinx_selective_exclude.search_auto_exclude',
  59. ]
  60. # sphinx.ext.todo extension parameters
  61. # If the below parameter is True, the extension
  62. # produces output, else it produces nothing.
  63. todo_include_todos = False
  64. # Enabling this fixes cropping of blockdiag edge labels
  65. seqdiag_antialias = True
  66. # Add any paths that contain templates here, relative to this directory.
  67. templates_path = ['_templates']
  68. # The suffix of source filenames.
  69. source_suffix = ['.rst', '.md']
  70. source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser',
  71. }
  72. # The encoding of source files.
  73. # source_encoding = 'utf-8-sig'
  74. # The master toctree document.
  75. master_doc = 'index'
  76. # The version info for the project you're documenting, acts as replacement for
  77. # |version| and |release|, also used in various other places throughout the
  78. # built documents.
  79. #
  80. # Readthedocs largely ignores 'version' and 'release', and displays one of
  81. # 'latest', tag name, or branch name, depending on the build type.
  82. # Still, this is useful for non-RTD builds.
  83. # This is supposed to be "the short X.Y version", but it's the only version
  84. # visible when you open index.html.
  85. # Display full version to make things less confusing.
  86. version = subprocess.check_output(['git', 'describe']).strip()
  87. # The full version, including alpha/beta/rc tags.
  88. # If needed, nearest tag is returned by 'git describe --abbrev=0'.
  89. release = version
  90. print('Version: {0} Release: {1}'.format(version, release))
  91. # There are two options for replacing |today|: either, you set today to some
  92. # non-false value, then it is used:
  93. # today = ''
  94. # Else, today_fmt is used as the format for a strftime call.
  95. # today_fmt = '%B %d, %Y'
  96. # List of patterns, relative to source directory, that match files and
  97. # directories to ignore when looking for source files.
  98. exclude_patterns = ['**/inc/**', '_static']
  99. # Add target-specific excludes based on tags (for the IDF_TARGET). Haven't found any better way to do this yet
  100. def update_exclude_patterns(tags):
  101. if "esp32" not in tags:
  102. # Exclude ESP32-only document pages so they aren't found in the initial search for .rst files
  103. # note: in toctrees, these also need to be marked with a :esp32: filter
  104. for e in ['api-guides/blufi.rst',
  105. 'api-guides/build-system-legacy.rst',
  106. 'api-guides/esp-ble-mesh/**',
  107. 'api-guides/ulp-legacy.rst',
  108. 'api-guides/unit-tests-legacy.rst',
  109. 'api-guides/jtag-debugging/configure-wrover.rst',
  110. 'api-reference/system/himem.rst',
  111. 'api-reference/bluetooth/**',
  112. 'api-reference/system/ipc.rst',
  113. 'get-started-legacy/**',
  114. 'gnu-make-legacy.rst',
  115. 'hw-reference/esp32/**']:
  116. exclude_patterns.append(e)
  117. if "esp32s2" not in tags:
  118. # Exclude ESP32-only document pages so they aren't found in the initial search for .rst files
  119. # note: in toctrees, these also need to be marked with a :esp32: filter
  120. for e in ['hw-reference/esp32s2/**']:
  121. exclude_patterns.append(e)
  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. # Custom added feature to allow redirecting old URLs
  141. #
  142. # Redirects should be listed in page_redirects.xt
  143. #
  144. with open("../page_redirects.txt") as f:
  145. lines = [re.sub(" +", " ", l.strip()) for l in f.readlines() if l.strip() != "" and not l.startswith("#")]
  146. for line in lines: # check for well-formed entries
  147. if len(line.split(' ')) != 2:
  148. raise RuntimeError("Invalid line in page_redirects.txt: %s" % line)
  149. html_redirect_pages = [tuple(l.split(' ')) for l in lines]
  150. # The theme to use for HTML and HTML Help pages. See the documentation for
  151. # a list of builtin themes.
  152. html_theme = 'sphinx_rtd_theme'
  153. # Theme options are theme-specific and customize the look and feel of a theme
  154. # further. For a list of options available for each theme, see the
  155. # documentation.
  156. # html_theme_options = {}
  157. # Add any paths that contain custom themes here, relative to this directory.
  158. # html_theme_path = []
  159. # The name for this set of Sphinx documents. If None, it defaults to
  160. # "<project> v<release> documentation".
  161. # html_title = None
  162. # A shorter title for the navigation bar. Default is the same as html_title.
  163. # html_short_title = None
  164. # The name of an image file (relative to this directory) to place at the top
  165. # of the sidebar.
  166. html_logo = "../_static/espressif-logo.svg"
  167. # The name of an image file (within the static path) to use as favicon of the
  168. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  169. # pixels large.
  170. # html_favicon = None
  171. # Add any paths that contain custom static files (such as style sheets) here,
  172. # relative to this directory. They are copied after the builtin static files,
  173. # so a file named "default.css" will overwrite the builtin "default.css".
  174. html_static_path = ['../_static']
  175. # Add any extra paths that contain custom files (such as robots.txt or
  176. # .htaccess) here, relative to this directory. These files are copied
  177. # directly to the root of the documentation.
  178. # html_extra_path = []
  179. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  180. # using the given strftime format.
  181. # html_last_updated_fmt = '%b %d, %Y'
  182. # If true, SmartyPants will be used to convert quotes and dashes to
  183. # typographically correct entities.
  184. # html_use_smartypants = True
  185. # Custom sidebar templates, maps document names to template names.
  186. # html_sidebars = {}
  187. # Additional templates that should be rendered to pages, maps page names to
  188. # template names.
  189. # html_additional_pages = {}
  190. # If false, no module index is generated.
  191. # html_domain_indices = True
  192. # If false, no index is generated.
  193. # html_use_index = True
  194. # If true, the index is split into individual pages for each letter.
  195. # html_split_index = False
  196. # If true, links to the reST sources are added to the pages.
  197. # html_show_sourcelink = True
  198. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  199. # html_show_sphinx = True
  200. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  201. # html_show_copyright = True
  202. # If true, an OpenSearch description file will be output, and all pages will
  203. # contain a <link> tag referring to it. The value of this option must be the
  204. # base URL from which the finished HTML is served.
  205. # html_use_opensearch = ''
  206. # This is the file name suffix for HTML files (e.g. ".xhtml").
  207. # html_file_suffix = None
  208. # Output file base name for HTML help builder.
  209. htmlhelp_basename = 'ReadtheDocsTemplatedoc'
  210. # -- Options for LaTeX output ---------------------------------------------
  211. latex_elements = {
  212. # The paper size ('letterpaper' or 'a4paper').
  213. # 'papersize': 'letterpaper',
  214. #
  215. # The font size ('10pt', '11pt' or '12pt').
  216. # 'pointsize': '10pt',
  217. #
  218. # Additional stuff for the LaTeX preamble.
  219. # 'preamble': '',
  220. }
  221. # Grouping the document tree into LaTeX files. List of tuples
  222. # (source start file, target name, title,
  223. # author, documentclass [howto, manual, or own class]).
  224. latex_documents = [
  225. ('index', 'ReadtheDocsTemplate.tex', u'Read the Docs Template Documentation',
  226. u'Read the Docs', 'manual'),
  227. ]
  228. # The name of an image file (relative to this directory) to place at the top of
  229. # the title page.
  230. # latex_logo = None
  231. # For "manual" documents, if this is true, then toplevel headings are parts,
  232. # not chapters.
  233. # latex_use_parts = False
  234. # If true, show page references after internal links.
  235. # latex_show_pagerefs = False
  236. # If true, show URL addresses after external links.
  237. # latex_show_urls = False
  238. # Documents to append as an appendix to all manuals.
  239. # latex_appendices = []
  240. # If false, no module index is generated.
  241. # latex_domain_indices = True
  242. # -- Options for manual page output ---------------------------------------
  243. # One entry per manual page. List of tuples
  244. # (source start file, name, description, authors, manual section).
  245. man_pages = [
  246. ('index', 'readthedocstemplate', u'Read the Docs Template Documentation',
  247. [u'Read the Docs'], 1)
  248. ]
  249. # If true, show URL addresses after external links.
  250. # man_show_urls = False
  251. # -- Options for Texinfo output -------------------------------------------
  252. # Grouping the document tree into Texinfo files. List of tuples
  253. # (source start file, target name, title, author,
  254. # dir menu entry, description, category)
  255. texinfo_documents = [
  256. ('index', 'ReadtheDocsTemplate', u'Read the Docs Template Documentation',
  257. u'Read the Docs', 'ReadtheDocsTemplate', 'One line description of project.',
  258. 'Miscellaneous'),
  259. ]
  260. # Documents to append as an appendix to all manuals.
  261. # texinfo_appendices = []
  262. # If false, no module index is generated.
  263. # texinfo_domain_indices = True
  264. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  265. # texinfo_show_urls = 'footnote'
  266. # If true, do not generate a @detailmenu in the "Top" node's menu.
  267. # texinfo_no_detailmenu = False
  268. # Override RTD CSS theme to introduce the theme corrections
  269. # https://github.com/rtfd/sphinx_rtd_theme/pull/432
  270. def setup(app):
  271. app.add_stylesheet('theme_overrides.css')
  272. app.add_config_value('idf_target', '', 'env')
  273. # Breathe extension variables (depend on build_dir)
  274. # note: we generate into xml_in and then copy_if_modified to xml dir
  275. app.config.breathe_projects = {"esp32-idf": os.path.join(app.config.build_dir, "xml_in/")}
  276. app.config.breathe_default_project = "esp32-idf"