docs_common.mk 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. # "Common" Makefile for Sphinx documentation
  2. #
  3. # (included from en/Makefile & zh_CN/Makefile
  4. #
  5. # NOTE: This makefile runs with cwd=either en or zh_CN subfolder, so this
  6. # (docs/) directory is '..' relative to it.
  7. # ************ IMPORTANT *****************
  8. #
  9. # ReadTheDocs DOES NOT USE THIS MAKEFILE,
  10. # so any behaviour additions must be
  11. # done via Sphinx Config not here
  12. #
  13. # ****************************************
  14. # You can set these variables from the command line.
  15. SPHINXOPTS =
  16. # note: this is changed from sphinx-build so it depends on default python interpreter, not on /bin/sphinx-build
  17. # (which will be the most recently installed version of sphinx and may not match)
  18. SPHINXBUILD = python -m sphinx
  19. PAPER =
  20. BUILDDIR = _build
  21. # Internal variables.
  22. PAPEROPT_a4 = -D latex_paper_size=a4
  23. PAPEROPT_letter = -D latex_paper_size=letter
  24. ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -w sphinx-warning-log.txt .
  25. # the i18n builder cannot share the environment and doctrees with the others
  26. I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
  27. .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext dependencies version-specific-includes check_python_packages
  28. help:
  29. @echo "Please use \`make <target>\' where <target> is one of"
  30. @echo " html to make standalone HTML files"
  31. @echo " dirhtml to make HTML files named index.html in directories"
  32. @echo " singlehtml to make a single large HTML file"
  33. @echo " pickle to make pickle files"
  34. @echo " json to make JSON files"
  35. @echo " htmlhelp to make HTML files and a HTML help project"
  36. @echo " qthelp to make HTML files and a qthelp project"
  37. @echo " devhelp to make HTML files and a Devhelp project"
  38. @echo " epub to make an epub"
  39. @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
  40. @echo " latexpdf to make LaTeX files and run them through pdflatex"
  41. @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
  42. @echo " text to make text files"
  43. @echo " man to make manual pages"
  44. @echo " texinfo to make Texinfo files"
  45. @echo " info to make Texinfo files and run them through makeinfo"
  46. @echo " gettext to make PO message catalogs"
  47. @echo " changes to make an overview of all changed/added/deprecated items"
  48. @echo " xml to make Docutils-native XML files"
  49. @echo " pseudoxml to make pseudoxml-XML files for display purposes"
  50. @echo " linkcheck to check all external links for integrity"
  51. @echo " doctest to run all doctests embedded in the documentation (if enabled) "
  52. clean:
  53. rm -rf $(BUILDDIR)/*
  54. # Notify users when some of the required python packages are not installed.
  55. # Note: This is intended to help developers who generate the documentation on their local machine. Read The Docs uses
  56. # the requirements.txt file directly and calls sphinx also directly without the use of the makefile!
  57. check_python_packages:
  58. $(IDF_PATH)/tools/check_python_dependencies.py -r $(IDF_PATH)/docs/requirements.txt
  59. html: | check_python_packages
  60. $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
  61. @echo
  62. @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
  63. dirhtml: | check_python_packages
  64. $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
  65. @echo
  66. @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
  67. singlehtml: | check_python_packages
  68. $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
  69. @echo
  70. @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
  71. pickle: | check_python_packages
  72. $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
  73. @echo
  74. @echo "Build finished; now you can process the pickle files."
  75. json: | check_python_packages
  76. $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
  77. @echo
  78. @echo "Build finished; now you can process the JSON files."
  79. htmlhelp: | check_python_packages
  80. $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
  81. @echo
  82. @echo "Build finished; now you can run HTML Help Workshop with the" \
  83. ".hhp project file in $(BUILDDIR)/htmlhelp."
  84. qthelp: | check_python_packages
  85. $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
  86. @echo
  87. @echo "Build finished; now you can run "qcollectiongenerator" with the" \
  88. ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
  89. @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhcp"
  90. @echo "To view the help file:"
  91. @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhc"
  92. devhelp: | check_python_packages
  93. $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
  94. @echo
  95. @echo "Build finished."
  96. @echo "To view the help file:"
  97. @echo "# mkdir -p $$HOME/.local/share/devhelp/ReadtheDocsTemplate"
  98. @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ReadtheDocsTemplate"
  99. @echo "# devhelp"
  100. epub: | check_python_packages
  101. $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
  102. @echo
  103. @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
  104. latex: | check_python_packages
  105. $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
  106. @echo
  107. @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
  108. @echo "Run \`make' in that directory to run these through (pdf)latex" \
  109. "(use \`make latexpdf' here to do that automatically)."
  110. latexpdf: | check_python_packages
  111. $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
  112. @echo "Running LaTeX files through pdflatex..."
  113. $(MAKE) -C $(BUILDDIR)/latex all-pdf
  114. @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
  115. latexpdfja: | check_python_packages
  116. $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
  117. @echo "Running LaTeX files through platex and dvipdfmx..."
  118. $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
  119. @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
  120. text: | check_python_packages
  121. $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
  122. @echo
  123. @echo "Build finished. The text files are in $(BUILDDIR)/text."
  124. man: | check_python_packages
  125. $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
  126. @echo
  127. @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
  128. texinfo: | check_python_packages
  129. $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
  130. @echo
  131. @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
  132. @echo "Run \`make' in that directory to run these through makeinfo" \
  133. "(use \`make info' here to do that automatically)."
  134. info: | check_python_packages
  135. $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
  136. @echo "Running Texinfo files through makeinfo..."
  137. make -C $(BUILDDIR)/texinfo info
  138. @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
  139. gettext: | check_python_packages
  140. $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
  141. @echo
  142. @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
  143. changes: | check_python_packages
  144. $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
  145. @echo
  146. @echo "The overview file is in $(BUILDDIR)/changes."
  147. linkcheck: | check_python_packages
  148. $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
  149. @echo
  150. @echo "Link check complete; look for any errors in the above output " \
  151. "or in $(BUILDDIR)/linkcheck/output.txt."
  152. gh-linkcheck: | check_python_packages
  153. @echo "Checking for hardcoded GitHub links" # note: exception for links to support policy doc as we *want* this to be a link to master's policy
  154. @if (find ../ -name '*.rst' | xargs grep \
  155. 'https://github.com/espressif/esp-idf/tree\|https://github.com/espressif/esp-idf/blob\|https://github.com/espressif/esp-idf/raw' \
  156. | grep -v 'SUPPORT_POLICY\.md' \
  157. ); \
  158. then \
  159. echo "WARNINIG: Some .rst files contain hardcoded Github links."; \
  160. echo "Please check above output and replace links with one of the following:"; \
  161. echo "- :idf:\`dir\` - points to directory inside ESP-IDF"; \
  162. echo "- :idf_file:\`file\` - points to file inside ESP-IDF"; \
  163. echo "- :idf_raw:\`file\` - points to raw view of the file inside ESP-IDF"; \
  164. echo "- :component:\`dir\` - points to directory inside ESP-IDF components dir"; \
  165. echo "- :component_file:\`file\` - points to file inside ESP-IDF components dir"; \
  166. echo "- :component_raw:\`file\` - points to raw view of the file inside ESP-IDF"; \
  167. echo " components dir"; \
  168. echo "- :example:\`dir\` - points to directory inside ESP-IDF examples dir"; \
  169. echo "- :example_file:\`file\` - points to file inside ESP-IDF examples dir"; \
  170. echo "- :example_raw:\`file\` - points to raw view of the file inside ESP-IDF"; \
  171. echo " examples dir"; \
  172. echo "These link types will point to the correct GitHub version automatically"; \
  173. exit 1; \
  174. fi
  175. @echo "No hardcoded links found"
  176. doctest: | check_python_packages
  177. $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
  178. @echo "Testing of doctests in the sources finished, look at the " \
  179. "results in $(BUILDDIR)/doctest/output.txt."
  180. xml: | check_python_packages
  181. $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
  182. @echo
  183. @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
  184. pseudoxml: | check_python_packages
  185. $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
  186. @echo
  187. @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."