conf_common.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Common (non-language-specific) configuration for Sphinx
  4. #
  5. # This file is imported from a language-specific conf.py (ie en/conf.py or
  6. # zh_CN/conf.py)
  7. # type: ignore
  8. # pylint: disable=wildcard-import
  9. # pylint: disable=undefined-variable
  10. from __future__ import print_function, unicode_literals
  11. import os.path
  12. import re
  13. from esp_docs.conf_docs import * # noqa: F403,F401
  14. if os.environ.get('IDF_PATH') is None:
  15. raise RuntimeError('IDF_PATH should be set, run export.sh before building docs')
  16. BT_DOCS = ['api-guides/blufi.rst',
  17. 'api-guides/esp-ble-mesh/**',
  18. 'api-reference/bluetooth/bt_le.rst',
  19. 'api-reference/bluetooth/esp_bt_defs.rst',
  20. 'api-reference/bluetooth/esp_bt_device.rst',
  21. 'api-reference/bluetooth/esp_bt_main.rst',
  22. 'api-reference/bluetooth/bt_common.rst',
  23. 'api-reference/bluetooth/controller_vhci.rst',
  24. 'api-reference/bluetooth/esp_gap_ble.rst',
  25. 'api-reference/bluetooth/esp_gatt_defs.rst',
  26. 'api-reference/bluetooth/esp_gatts.rst',
  27. 'api-reference/bluetooth/esp_gattc.rst',
  28. 'api-reference/bluetooth/esp_blufi.rst',
  29. 'api-reference/bluetooth/esp-ble-mesh.rst',
  30. 'api-reference/bluetooth/index.rst',
  31. 'api-reference/bluetooth/nimble/index.rst']
  32. CLASSIC_BT_DOCS = ['api-reference/bluetooth/classic_bt.rst',
  33. 'api-reference/bluetooth/esp_a2dp.rst',
  34. 'api-reference/bluetooth/esp_avrc.rst',
  35. 'api-reference/bluetooth/esp_hidd.rst',
  36. 'api-reference/bluetooth/esp_l2cap_bt.rst',
  37. 'api-reference/bluetooth/esp_sdp.rst',
  38. 'api-reference/bluetooth/esp_hf_defs.rst',
  39. 'api-reference/bluetooth/esp_hf_client.rst',
  40. 'api-reference/bluetooth/esp_hf_ag.rst',
  41. 'api-reference/bluetooth/esp_spp.rst',
  42. 'api-reference/bluetooth/esp_gap_bt.rst']
  43. WIFI_DOCS = ['api-guides/wifi.rst',
  44. 'api-guides/wifi-security.rst',
  45. 'api-guides/wireshark-user-guide.rst']
  46. COEXISTENCE_DOCS = ['api-guides/coexist.rst']
  47. SDMMC_DOCS = ['api-reference/peripherals/sdmmc_host.rst',
  48. 'api-reference/peripherals/sd_pullup_requirements.rst']
  49. SDIO_SLAVE_DOCS = ['api-reference/peripherals/sdio_slave.rst',
  50. 'api-reference/protocols/esp_sdio_slave_protocol.rst']
  51. MCPWM_DOCS = ['api-reference/peripherals/mcpwm.rst']
  52. DEDIC_GPIO_DOCS = ['api-reference/peripherals/dedic_gpio.rst']
  53. PCNT_DOCS = ['api-reference/peripherals/pcnt.rst']
  54. RMT_DOCS = ['api-reference/peripherals/rmt.rst']
  55. DAC_DOCS = ['api-reference/peripherals/dac.rst']
  56. TEMP_SENSOR_DOCS = ['api-reference/peripherals/temp_sensor.rst']
  57. TOUCH_SENSOR_DOCS = ['api-reference/peripherals/touch_pad.rst']
  58. SPIRAM_DOCS = ['api-guides/external-ram.rst']
  59. USB_DOCS = ['api-reference/peripherals/usb_device.rst',
  60. 'api-reference/peripherals/usb_host.rst',
  61. 'api-guides/usb-otg-console.rst',
  62. 'api-guides/dfu.rst']
  63. FTDI_JTAG_DOCS = ['api-guides/jtag-debugging/configure-ft2232h-jtag.rst']
  64. USB_SERIAL_JTAG_DOCS = ['api-guides/jtag-debugging/configure-builtin-jtag.rst',
  65. 'api-guides/usb-serial-jtag-console.rst']
  66. ULP_DOCS = ['api-reference/system/ulp.rst',
  67. 'api-reference/system/ulp_macros.rst',
  68. 'api-reference/system/ulp_instruction_set.rst']
  69. RISCV_COPROC_DOCS = ['api-reference/system/ulp-risc-v.rst',]
  70. XTENSA_DOCS = ['api-guides/hlinterrupts.rst',
  71. 'api-reference/system/perfmon.rst']
  72. RISCV_DOCS = [] # type: list[str]
  73. TWAI_DOCS = ['api-reference/peripherals/twai.rst']
  74. SIGMADELTA_DOCS = ['api-reference/peripherals/sigmadelta.rst']
  75. I2S_DOCS = ['api-reference/peripherals/i2s.rst']
  76. ESP32_DOCS = ['api-reference/system/himem.rst',
  77. 'api-guides/romconsole.rst',
  78. 'api-reference/system/ipc.rst',
  79. 'security/secure-boot-v1.rst',
  80. 'api-reference/peripherals/secure_element.rst',
  81. 'api-reference/peripherals/dac.rst',
  82. 'hw-reference/esp32/**',
  83. 'api-guides/RF_calibration.rst'] + FTDI_JTAG_DOCS
  84. ESP32S2_DOCS = ['hw-reference/esp32s2/**',
  85. 'api-guides/usb-console.rst',
  86. 'api-reference/peripherals/ds.rst',
  87. 'api-reference/peripherals/spi_slave_hd.rst',
  88. 'api-reference/peripherals/temp_sensor.rst',
  89. 'api-reference/system/async_memcpy.rst',
  90. 'api-reference/peripherals/touch_element.rst',
  91. 'api-guides/RF_calibration.rst'] + FTDI_JTAG_DOCS
  92. ESP32S3_DOCS = ['hw-reference/esp32s3/**',
  93. 'api-reference/system/ipc.rst',
  94. 'api-guides/flash_psram_config.rst',
  95. 'api-guides/RF_calibration.rst']
  96. # No JTAG docs for this one as it gets gated on SOC_USB_SERIAL_JTAG_SUPPORTED down below.
  97. ESP32C3_DOCS = ['hw-reference/esp32c3/**',
  98. 'api-guides/RF_calibration.rst']
  99. # format: {tag needed to include: documents to included}, tags are parsed from sdkconfig and peripheral_caps.h headers
  100. conditional_include_dict = {'SOC_BT_SUPPORTED':BT_DOCS,
  101. 'SOC_WIFI_SUPPORTED':WIFI_DOCS,
  102. 'SOC_CLASSIC_BT_SUPPORTED':CLASSIC_BT_DOCS,
  103. 'SOC_SUPPORT_COEXISTENCE':COEXISTENCE_DOCS,
  104. 'SOC_SDMMC_HOST_SUPPORTED':SDMMC_DOCS,
  105. 'SOC_SDIO_SLAVE_SUPPORTED':SDIO_SLAVE_DOCS,
  106. 'SOC_MCPWM_SUPPORTED':MCPWM_DOCS,
  107. 'SOC_USB_OTG_SUPPORTED':USB_DOCS,
  108. 'SOC_USB_SERIAL_JTAG_SUPPORTED':USB_SERIAL_JTAG_DOCS,
  109. 'SOC_DEDICATED_GPIO_SUPPORTED':DEDIC_GPIO_DOCS,
  110. 'SOC_SPIRAM_SUPPORTED':SPIRAM_DOCS,
  111. 'SOC_PCNT_SUPPORTED':PCNT_DOCS,
  112. 'SOC_RMT_SUPPORTED':RMT_DOCS,
  113. 'SOC_DAC_SUPPORTED':DAC_DOCS,
  114. 'SOC_TOUCH_SENSOR_NUM':TOUCH_SENSOR_DOCS,
  115. 'SOC_ULP_SUPPORTED':ULP_DOCS,
  116. 'SOC_RISCV_COPROC_SUPPORTED':RISCV_COPROC_DOCS,
  117. 'SOC_DIG_SIGN_SUPPORTED':['api-reference/peripherals/ds.rst'],
  118. 'SOC_HMAC_SUPPORTED':['api-reference/peripherals/hmac.rst'],
  119. 'SOC_ASYNC_MEMCPY_SUPPORTED':['api-reference/system/async_memcpy.rst'],
  120. 'CONFIG_IDF_TARGET_ARCH_XTENSA':XTENSA_DOCS,
  121. 'CONFIG_IDF_TARGET_ARCH_RISCV':RISCV_DOCS,
  122. 'SOC_TEMP_SENSOR_SUPPORTED':TEMP_SENSOR_DOCS,
  123. 'SOC_TWAI_SUPPORTED':TWAI_DOCS,
  124. 'SOC_I2S_SUPPORTED':I2S_DOCS,
  125. 'SOC_SIGMADELTA_SUPPORTED':SIGMADELTA_DOCS,
  126. 'esp32':ESP32_DOCS,
  127. 'esp32s2':ESP32S2_DOCS,
  128. 'esp32s3':ESP32S3_DOCS,
  129. 'esp32c3':ESP32C3_DOCS}
  130. extensions += ['sphinx_copybutton',
  131. 'sphinxcontrib.wavedrom',
  132. # Note: order is important here, events must
  133. # be registered by one extension before they can be
  134. # connected to another extension
  135. 'esp_docs.idf_extensions.build_system',
  136. 'esp_docs.idf_extensions.esp_err_definitions',
  137. 'esp_docs.idf_extensions.gen_toolchain_links',
  138. 'esp_docs.idf_extensions.gen_defines',
  139. 'esp_docs.idf_extensions.gen_version_specific_includes',
  140. 'esp_docs.idf_extensions.kconfig_reference',
  141. 'esp_docs.idf_extensions.gen_idf_tools_links',
  142. 'esp_docs.esp_extensions.run_doxygen',
  143. ]
  144. # Use wavedrompy as backend, insted of wavedrom-cli
  145. render_using_wavedrompy = True
  146. # link roles config
  147. github_repo = 'espressif/esp-idf'
  148. # context used by sphinx_idf_theme
  149. html_context['github_user'] = 'espressif'
  150. html_context['github_repo'] = 'esp-idf'
  151. # Extra options required by sphinx_idf_theme
  152. project_slug = 'esp-idf'
  153. versions_url = 'https://dl.espressif.com/dl/esp-idf/idf_versions.js'
  154. idf_targets = ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c2']
  155. languages = ['en', 'zh_CN']
  156. google_analytics_id = os.environ.get('CI_GOOGLE_ANALYTICS_ID', None)
  157. project_homepage = 'https://github.com/espressif/esp-idf'
  158. linkcheck_anchors = False
  159. linkcheck_exclude_documents = ['index', # several false positives due to the way we link to different sections
  160. 'api-reference/protocols/esp_local_ctrl', # Fails due to `https://<mdns-hostname>.local`
  161. 'api-reference/provisioning/wifi_provisioning', # Fails due to `https://<mdns-hostname>.local`
  162. ]
  163. linkcheck_ignore = ['https://webhome.phy.duke.edu/~rgb/General/dieharder.php', # Certificate error
  164. 'https://dl.espressif.com/dl/esp32s3_rom.elf', # Not published
  165. 'https://docs.espressif.com/projects/esptool/en/latest/esp32c2/espefuse/index.html', # Not published
  166. 'https://www.espressif.com/sites/default/files/documentation/esp32-c2_datasheet_en.pdf', # Not published
  167. ]
  168. # Custom added feature to allow redirecting old URLs
  169. with open('../page_redirects.txt') as f:
  170. lines = [re.sub(' +', ' ', line.strip()) for line in f.readlines() if line.strip() != '' and not line.startswith('#')]
  171. for line in lines: # check for well-formed entries
  172. if len(line.split(' ')) != 2:
  173. raise RuntimeError('Invalid line in page_redirects.txt: %s' % line)
  174. html_redirect_pages = [tuple(line.split(' ')) for line in lines]
  175. html_static_path = ['../_static']
  176. # Callback function for user setup that needs be done after `config-init`-event
  177. # config.idf_target is not available at the initial config stage
  178. def conf_setup(app, config):
  179. config.add_warnings_content = 'This document is not updated for {} yet, so some of the content may not be correct.'.format(config.idf_target.upper())
  180. add_warnings_file = '{}/../docs_not_updated/{}.txt'.format(app.confdir, config.idf_target)
  181. try:
  182. with open(add_warnings_file) as warning_file:
  183. config.add_warnings_pages = warning_file.read().splitlines()
  184. except FileNotFoundError:
  185. # Not for all target
  186. pass
  187. user_setup_callback = conf_setup