conf_common.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. from sanitize_version import sanitize_version
  24. from idf_extensions.util import download_file_if_missing
  25. # build_docs on the CI server sometimes fails under Python3. This is a workaround:
  26. sys.setrecursionlimit(3500)
  27. config_dir = os.path.abspath(os.path.dirname(__file__))
  28. # http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format
  29. #
  30. suppress_warnings = ['image.nonlocal_uri']
  31. # -- General configuration ------------------------------------------------
  32. # If your documentation needs a minimal Sphinx version, state it here.
  33. # needs_sphinx = '1.0'
  34. # Add any Sphinx extension module names here, as strings. They can be
  35. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  36. # ones.
  37. extensions = ['breathe',
  38. 'sphinx.ext.todo',
  39. 'sphinx_idf_theme',
  40. 'sphinxcontrib.blockdiag',
  41. 'sphinxcontrib.seqdiag',
  42. 'sphinxcontrib.actdiag',
  43. 'sphinxcontrib.nwdiag',
  44. 'sphinxcontrib.rackdiag',
  45. 'sphinxcontrib.packetdiag',
  46. 'extensions.html_redirects',
  47. 'extensions.toctree_filter',
  48. 'extensions.list_filter',
  49. 'idf_extensions.include_build_file',
  50. 'idf_extensions.link_roles',
  51. 'idf_extensions.build_system',
  52. 'idf_extensions.esp_err_definitions',
  53. 'idf_extensions.gen_toolchain_links',
  54. 'idf_extensions.gen_version_specific_includes',
  55. 'idf_extensions.kconfig_reference',
  56. 'idf_extensions.run_doxygen',
  57. 'idf_extensions.gen_idf_tools_links',
  58. 'idf_extensions.format_idf_target',
  59. # from https://github.com/pfalcon/sphinx_selective_exclude
  60. 'sphinx_selective_exclude.eager_only',
  61. # TODO: determine if we need search_auto_exclude
  62. # 'sphinx_selective_exclude.search_auto_exclude',
  63. ]
  64. # sphinx.ext.todo extension parameters
  65. # If the below parameter is True, the extension
  66. # produces output, else it produces nothing.
  67. todo_include_todos = False
  68. # Enabling this fixes cropping of blockdiag edge labels
  69. seqdiag_antialias = True
  70. # Add any paths that contain templates here, relative to this directory.
  71. templates_path = ['_templates']
  72. # The suffix of source filenames.
  73. source_suffix = ['.rst', '.md']
  74. source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser',
  75. }
  76. # The encoding of source files.
  77. # source_encoding = 'utf-8-sig'
  78. # The master toctree document.
  79. master_doc = 'index'
  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. # This is the full exact version, canonical git version description
  85. # visible when you open index.html.
  86. version = subprocess.check_output(['git', 'describe']).strip().decode('utf-8')
  87. # The 'release' version is the same as version for non-CI builds, but for CI
  88. # builds on a branch then it's replaced with the branch name
  89. release = sanitize_version(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', '**/_build']
  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/RF_calibration.rst', # temporary until support re-added in esp_wifi
  108. 'api-guides/ulp-legacy.rst',
  109. 'api-guides/unit-tests-legacy.rst',
  110. 'api-guides/ulp_instruction_set.rst',
  111. 'api-guides/jtag-debugging/configure-wrover.rst',
  112. 'api-reference/system/himem.rst',
  113. 'api-reference/bluetooth/**',
  114. 'api-reference/peripherals/sdio_slave.rst',
  115. 'api-reference/peripherals/esp_slave_protocol.rst',
  116. 'api-reference/peripherals/mcpwm.rst',
  117. 'api-reference/peripherals/sd_pullup_requirements.rst',
  118. 'api-reference/peripherals/sdmmc_host.rst',
  119. 'api-reference/protocols/esp_serial_slave_link.rst',
  120. 'api-reference/system/ipc.rst',
  121. 'get-started-legacy/**',
  122. 'security/secure-boot-v1.rst',
  123. 'security/secure-boot-v2.rst',
  124. 'gnu-make-legacy.rst',
  125. 'hw-reference/esp32/**',
  126. ]:
  127. exclude_patterns.append(e)
  128. if "esp32s2" not in tags:
  129. # Exclude ESP32-S2-only document pages so they aren't found in the initial search for .rst files
  130. # note: in toctrees, these also need to be marked with a :esp32: filter
  131. for e in ['esp32s2.rst',
  132. 'hw-reference/esp32s2/**',
  133. 'api-guides/ulps2_instruction_set.rst',
  134. 'api-reference/peripherals/temp_sensor.rst']:
  135. exclude_patterns.append(e)
  136. # The reST default role (used for this markup: `text`) to use for all
  137. # documents.
  138. # default_role = None
  139. # If true, '()' will be appended to :func: etc. cross-reference text.
  140. # add_function_parentheses = True
  141. # If true, the current module name will be prepended to all description
  142. # unit titles (such as .. function::).
  143. # add_module_names = True
  144. # If true, sectionauthor and moduleauthor directives will be shown in the
  145. # output. They are ignored by default.
  146. # show_authors = False
  147. # The name of the Pygments (syntax highlighting) style to use.
  148. pygments_style = 'sphinx'
  149. # A list of ignored prefixes for module index sorting.
  150. # modindex_common_prefix = []
  151. # If true, keep warnings as "system message" paragraphs in the built documents.
  152. # keep_warnings = False
  153. # Extra options required by sphinx_idf_theme
  154. project_slug = 'esp-idf'
  155. versions_url = 'https://dl.espressif.com/dl/esp-idf/idf_versions.js'
  156. idf_targets = ['esp32', 'esp32s2']
  157. languages = ['en', 'zh_CN']
  158. project_homepage = "https://github.com/espressif/esp-idf"
  159. # -- Options for HTML output ----------------------------------------------
  160. # Custom added feature to allow redirecting old URLs
  161. #
  162. # Redirects should be listed in page_redirects.xt
  163. #
  164. with open("../page_redirects.txt") as f:
  165. lines = [re.sub(" +", " ", l.strip()) for l in f.readlines() if l.strip() != "" and not l.startswith("#")]
  166. for line in lines: # check for well-formed entries
  167. if len(line.split(' ')) != 2:
  168. raise RuntimeError("Invalid line in page_redirects.txt: %s" % line)
  169. html_redirect_pages = [tuple(l.split(' ')) for l in lines]
  170. # The theme to use for HTML and HTML Help pages. See the documentation for
  171. # a list of builtin themes.
  172. html_theme = 'sphinx_idf_theme'
  173. # Theme options are theme-specific and customize the look and feel of a theme
  174. # further. For a list of options available for each theme, see the
  175. # documentation.
  176. # html_theme_options = {}
  177. # Add any paths that contain custom themes here, relative to this directory.
  178. # html_theme_path = []
  179. # The name for this set of Sphinx documents. If None, it defaults to
  180. # "<project> v<release> documentation".
  181. # html_title = None
  182. # A shorter title for the navigation bar. Default is the same as html_title.
  183. # html_short_title = None
  184. # The name of an image file (relative to this directory) to place at the top
  185. # of the sidebar.
  186. html_logo = "../_static/espressif-logo.svg"
  187. # The name of an image file (within the static path) to use as favicon of the
  188. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  189. # pixels large.
  190. # html_favicon = None
  191. # Add any paths that contain custom static files (such as style sheets) here,
  192. # relative to this directory. They are copied after the builtin static files,
  193. # so a file named "default.css" will overwrite the builtin "default.css".
  194. html_static_path = ['../_static']
  195. # Add any extra paths that contain custom files (such as robots.txt or
  196. # .htaccess) here, relative to this directory. These files are copied
  197. # directly to the root of the documentation.
  198. # html_extra_path = []
  199. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  200. # using the given strftime format.
  201. # html_last_updated_fmt = '%b %d, %Y'
  202. # If true, SmartyPants will be used to convert quotes and dashes to
  203. # typographically correct entities.
  204. # html_use_smartypants = True
  205. # Custom sidebar templates, maps document names to template names.
  206. # html_sidebars = {}
  207. # Additional templates that should be rendered to pages, maps page names to
  208. # template names.
  209. # html_additional_pages = {}
  210. # If false, no module index is generated.
  211. # html_domain_indices = True
  212. # If false, no index is generated.
  213. # html_use_index = True
  214. # If true, the index is split into individual pages for each letter.
  215. # html_split_index = False
  216. # If true, links to the reST sources are added to the pages.
  217. # html_show_sourcelink = True
  218. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  219. # html_show_sphinx = True
  220. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  221. # html_show_copyright = True
  222. # If true, an OpenSearch description file will be output, and all pages will
  223. # contain a <link> tag referring to it. The value of this option must be the
  224. # base URL from which the finished HTML is served.
  225. # html_use_opensearch = ''
  226. # This is the file name suffix for HTML files (e.g. ".xhtml").
  227. # html_file_suffix = None
  228. # Output file base name for HTML help builder.
  229. htmlhelp_basename = 'ReadtheDocsTemplatedoc'
  230. # -- Options for LaTeX output ---------------------------------------------
  231. latex_elements = {
  232. # The paper size ('letterpaper' or 'a4paper').
  233. # 'papersize': 'letterpaper',
  234. #
  235. # The font size ('10pt', '11pt' or '12pt').
  236. # 'pointsize': '10pt',
  237. #
  238. # Additional stuff for the LaTeX preamble.
  239. # 'preamble': '',
  240. }
  241. # Grouping the document tree into LaTeX files. List of tuples
  242. # (source start file, target name, title,
  243. # author, documentclass [howto, manual, or own class]).
  244. latex_documents = [
  245. ('index', 'ReadtheDocsTemplate.tex', u'Read the Docs Template Documentation',
  246. u'Read the Docs', 'manual'),
  247. ]
  248. # The name of an image file (relative to this directory) to place at the top of
  249. # the title page.
  250. # latex_logo = None
  251. # For "manual" documents, if this is true, then toplevel headings are parts,
  252. # not chapters.
  253. # latex_use_parts = False
  254. # If true, show page references after internal links.
  255. # latex_show_pagerefs = False
  256. # If true, show URL addresses after external links.
  257. # latex_show_urls = False
  258. # Documents to append as an appendix to all manuals.
  259. # latex_appendices = []
  260. # If false, no module index is generated.
  261. # latex_domain_indices = True
  262. # -- Options for manual page output ---------------------------------------
  263. # One entry per manual page. List of tuples
  264. # (source start file, name, description, authors, manual section).
  265. man_pages = [
  266. ('index', 'readthedocstemplate', u'Read the Docs Template Documentation',
  267. [u'Read the Docs'], 1)
  268. ]
  269. # If true, show URL addresses after external links.
  270. # man_show_urls = False
  271. # -- Options for Texinfo output -------------------------------------------
  272. # Grouping the document tree into Texinfo files. List of tuples
  273. # (source start file, target name, title, author,
  274. # dir menu entry, description, category)
  275. texinfo_documents = [
  276. ('index', 'ReadtheDocsTemplate', u'Read the Docs Template Documentation',
  277. u'Read the Docs', 'ReadtheDocsTemplate', 'One line description of project.',
  278. 'Miscellaneous'),
  279. ]
  280. # Documents to append as an appendix to all manuals.
  281. # texinfo_appendices = []
  282. # If false, no module index is generated.
  283. # texinfo_domain_indices = True
  284. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  285. # texinfo_show_urls = 'footnote'
  286. # If true, do not generate a @detailmenu in the "Top" node's menu.
  287. # texinfo_no_detailmenu = False
  288. # Override RTD CSS theme to introduce the theme corrections
  289. # https://github.com/rtfd/sphinx_rtd_theme/pull/432
  290. def setup(app):
  291. app.add_stylesheet('theme_overrides.css')
  292. # these two must be pushed in by build_docs.py
  293. if "idf_target" not in app.config:
  294. app.add_config_value('idf_target', None, 'env')
  295. app.add_config_value('idf_targets', None, 'env')
  296. # Breathe extension variables (depend on build_dir)
  297. # note: we generate into xml_in and then copy_if_modified to xml dir
  298. app.config.breathe_projects = {"esp32-idf": os.path.join(app.config.build_dir, "xml_in/")}
  299. app.config.breathe_default_project = "esp32-idf"
  300. setup_diag_font(app)
  301. def setup_diag_font(app):
  302. # blockdiag and other tools require a font which supports their character set
  303. # the font file is stored on the download server to save repo size
  304. font_name = {
  305. 'en': 'DejaVuSans.ttf',
  306. 'zh_CN': 'NotoSansSC-Regular.otf',
  307. }[app.config.language]
  308. font_dir = os.path.join(config_dir, '_static')
  309. assert os.path.exists(font_dir)
  310. print("Downloading font file %s for %s" % (font_name, app.config.language))
  311. download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/{}'.format(font_name), font_dir)
  312. font_path = os.path.abspath(os.path.join(font_dir, font_name))
  313. assert os.path.exists(font_path)
  314. app.config.blockdiag_fontpath = font_path
  315. app.config.seqdiag_fontpath = font_path
  316. app.config.actdiag_fontpath = font_path
  317. app.config.nwdiag_fontpath = font_path
  318. app.config.rackdiag_fontpath = font_path
  319. app.config.packetdiag_fontpath = font_path