Merge branch 'bugfix/py3_error_code_generator_from_docs' into 'master'

Docs: Check Python packages

See merge request idf/esp-idf!3135
This commit is contained in:
Ivan Grokhotkov 2018-08-30 20:25:09 +08:00
commit 499d06746b
7 changed files with 74 additions and 44 deletions

View file

@ -30,6 +30,11 @@ builddir = builddir
if 'BUILDDIR' in os.environ: if 'BUILDDIR' in os.environ:
builddir = os.environ['BUILDDIR'] builddir = os.environ['BUILDDIR']
def call_with_python(cmd):
# using sys.executable ensures that the scripts are called with the same Python interpreter
if os.system('{} {}'.format(sys.executable, cmd)) != 0:
raise RuntimeError('{} failed'.format(cmd))
# Call Doxygen to get XML files from the header files # Call Doxygen to get XML files from the header files
print("Calling Doxygen to generate latest XML files") print("Calling Doxygen to generate latest XML files")
if os.system("doxygen ../Doxyfile") != 0: if os.system("doxygen ../Doxyfile") != 0:
@ -40,20 +45,17 @@ if os.system("doxygen ../Doxyfile") != 0:
copy_if_modified('xml/', 'xml_in/') copy_if_modified('xml/', 'xml_in/')
# Generate 'api_name.inc' files using the XML files by Doxygen # Generate 'api_name.inc' files using the XML files by Doxygen
if os.system('python ../gen-dxd.py') != 0: call_with_python('../gen-dxd.py')
raise RuntimeError('gen-dxd.py failed')
# Generate 'kconfig.inc' file from components' Kconfig files # Generate 'kconfig.inc' file from components' Kconfig files
kconfig_inc_path = '{}/inc/kconfig.inc'.format(builddir) kconfig_inc_path = '{}/inc/kconfig.inc'.format(builddir)
if os.system('python ../gen-kconfig-doc.py > ' + kconfig_inc_path + '.in') != 0: call_with_python('../gen-kconfig-doc.py > ' + kconfig_inc_path + '.in')
raise RuntimeError('gen-kconfig-doc.py failed')
copy_if_modified(kconfig_inc_path + '.in', kconfig_inc_path) copy_if_modified(kconfig_inc_path + '.in', kconfig_inc_path)
# Generate 'esp_err_defs.inc' file with ESP_ERR_ error code definitions # Generate 'esp_err_defs.inc' file with ESP_ERR_ error code definitions
esp_err_inc_path = '{}/inc/esp_err_defs.inc'.format(builddir) esp_err_inc_path = '{}/inc/esp_err_defs.inc'.format(builddir)
if os.system('python ../../tools/gen_esp_err_to_name.py --rst_output ' + esp_err_inc_path + '.in') != 0: call_with_python('../../tools/gen_esp_err_to_name.py --rst_output ' + esp_err_inc_path + '.in')
raise RuntimeError('gen_esp_err_to_name.py failed')
copy_if_modified(esp_err_inc_path + '.in', esp_err_inc_path) copy_if_modified(esp_err_inc_path + '.in', esp_err_inc_path)
# Generate version-related includes # Generate version-related includes
@ -62,8 +64,7 @@ copy_if_modified(esp_err_inc_path + '.in', esp_err_inc_path)
def generate_version_specific_includes(app): def generate_version_specific_includes(app):
print("Generating version-specific includes...") print("Generating version-specific includes...")
version_tmpdir = '{}/version_inc'.format(builddir) version_tmpdir = '{}/version_inc'.format(builddir)
if os.system('python ../gen-version-specific-includes.py {} {}'.format(app.config.language, version_tmpdir)): call_with_python('../gen-version-specific-includes.py {} {}'.format(app.config.language, version_tmpdir))
raise RuntimeError('gen-version-specific-includes.py failed')
copy_if_modified(version_tmpdir, '{}/inc'.format(builddir)) copy_if_modified(version_tmpdir, '{}/inc'.format(builddir))

View file

@ -28,7 +28,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -w
# the i18n builder cannot share the environment and doctrees with the others # the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext dependencies version-specific-includes .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
help: help:
@echo "Please use \`make <target>\' where <target> is one of" @echo "Please use \`make <target>\' where <target> is one of"
@ -58,38 +58,44 @@ help:
clean: clean:
rm -rf $(BUILDDIR)/* rm -rf $(BUILDDIR)/*
html: # Notify users when some of the required python packages are not installed.
# Note: This is intended to help developers who generate the documentation on their local machine. Read The Docs uses
# the requirements.txt file directly and calls sphinx also directly without the use of the makefile!
check_python_packages:
$(IDF_PATH)/tools/check_python_dependencies.py -r $(IDF_PATH)/docs/requirements.txt
html: | check_python_packages
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo @echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml: dirhtml: | check_python_packages
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo @echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml: singlehtml: | check_python_packages
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo @echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle: pickle: | check_python_packages
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo @echo
@echo "Build finished; now you can process the pickle files." @echo "Build finished; now you can process the pickle files."
json: json: | check_python_packages
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo @echo
@echo "Build finished; now you can process the JSON files." @echo "Build finished; now you can process the JSON files."
htmlhelp: htmlhelp: | check_python_packages
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo @echo
@echo "Build finished; now you can run HTML Help Workshop with the" \ @echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp." ".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp: qthelp: | check_python_packages
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo @echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
@ -98,7 +104,7 @@ qthelp:
@echo "To view the help file:" @echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhc" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhc"
devhelp: devhelp: | check_python_packages
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo @echo
@echo "Build finished." @echo "Build finished."
@ -107,70 +113,70 @@ devhelp:
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ReadtheDocsTemplate" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ReadtheDocsTemplate"
@echo "# devhelp" @echo "# devhelp"
epub: epub: | check_python_packages
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo @echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub." @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex: latex: | check_python_packages
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo @echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \ @echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)." "(use \`make latexpdf' here to do that automatically)."
latexpdf: latexpdf: | check_python_packages
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..." @echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf $(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja: latexpdfja: | check_python_packages
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..." @echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text: text: | check_python_packages
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo @echo
@echo "Build finished. The text files are in $(BUILDDIR)/text." @echo "Build finished. The text files are in $(BUILDDIR)/text."
man: man: | check_python_packages
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo @echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man." @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo: texinfo: | check_python_packages
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo @echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \ @echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)." "(use \`make info' here to do that automatically)."
info: info: | check_python_packages
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..." @echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext: gettext: | check_python_packages
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo @echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes: changes: | check_python_packages
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo @echo
@echo "The overview file is in $(BUILDDIR)/changes." @echo "The overview file is in $(BUILDDIR)/changes."
linkcheck: linkcheck: | check_python_packages
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo @echo
@echo "Link check complete; look for any errors in the above output " \ @echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt." "or in $(BUILDDIR)/linkcheck/output.txt."
gh-linkcheck: gh-linkcheck: | check_python_packages
@echo "Checking for hardcoded GitHub links" @echo "Checking for hardcoded GitHub links"
@if (find ../ -name '*.rst' | xargs grep \ @if (find ../ -name '*.rst' | xargs grep \
'https://github.com/espressif/esp-idf/tree\|https://github.com/espressif/esp-idf/blob\|https://github.com/espressif/esp-idf/raw'\ 'https://github.com/espressif/esp-idf/tree\|https://github.com/espressif/esp-idf/blob\|https://github.com/espressif/esp-idf/raw'\
@ -194,17 +200,17 @@ gh-linkcheck:
fi fi
@echo "No hardcoded links found" @echo "No hardcoded links found"
doctest: doctest: | check_python_packages
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \ @echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt." "results in $(BUILDDIR)/doctest/output.txt."
xml: xml: | check_python_packages
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo @echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml." @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml: pseudoxml: | check_python_packages
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo @echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

2
docs/gen-dxd.py Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/env python
#
# gen-dxd.py - Generate Doxygen Directives # gen-dxd.py - Generate Doxygen Directives
# #
# This code is in the Public Domain (or CC0 licensed, at your option.) # This code is in the Public Domain (or CC0 licensed, at your option.)

View file

@ -4,8 +4,9 @@
sphinx==1.6.5 sphinx==1.6.5
sphinx-rtd-theme sphinx-rtd-theme
breathe==4.7.3 breathe==4.7.3
sphinxcontrib.blockdiag==1.5.3 sphinxcontrib-blockdiag==1.5.3
sphinxcontrib.seqdiag==0.8.5 sphinxcontrib-seqdiag==0.8.5
sphinxcontrib.actdiag==0.8.5 sphinxcontrib-actdiag==0.8.5
sphinxcontrib.nwdiag==0.9.5 sphinxcontrib-nwdiag==0.9.5
recommonmark recommonmark
future>=0.16.0 # for ../tools/gen_esp_err_to_name.py

17
tools/check_python_dependencies.py Normal file → Executable file
View file

@ -16,6 +16,7 @@
import os import os
import sys import sys
import argparse
try: try:
import pkg_resources import pkg_resources
except: except:
@ -24,11 +25,17 @@ except:
'setting up the required packages.') 'setting up the required packages.')
sys.exit(1) sys.exit(1)
req_file = '{}/requirements.txt'.format(os.getenv("IDF_PATH"))
if __name__ == "__main__": if __name__ == "__main__":
idf_path = os.getenv("IDF_PATH")
parser = argparse.ArgumentParser(description='ESP32 Python package dependency checker')
parser.add_argument('--requirements', '-r',
help='Path to the requrements file',
default=idf_path + '/requirements.txt')
args = parser.parse_args()
not_satisfied = [] not_satisfied = []
with open(req_file) as f: with open(args.requirements) as f:
for line in f: for line in f:
line = line.strip() line = line.strip()
try: try:
@ -40,7 +47,7 @@ if __name__ == "__main__":
print('The following Python requirements are not satisfied:') print('The following Python requirements are not satisfied:')
for requirement in not_satisfied: for requirement in not_satisfied:
print(requirement) print(requirement)
print('Please run "{} -m pip install -r {}" for resolving the issue.'.format(sys.executable, req_file)) print('Please run "{} -m pip install -r {}" for resolving the issue.'.format(sys.executable, args.requirements))
sys.exit(1) sys.exit(1)
print('Python requirements are satisfied.') print('Python requirements from {} are satisfied.'.format(args.requirements))

View file

@ -41,3 +41,5 @@ tools/test_idf_monitor/run_test_idf_monitor.py
tools/mass_mfg/mfg_gen.py tools/mass_mfg/mfg_gen.py
tools/unit-test-app/unit_test.py tools/unit-test-app/unit_test.py
tools/test_idf_size/test.sh tools/test_idf_size/test.sh
tools/check_python_dependencies.py
docs/gen-dxd.py

View file

@ -16,9 +16,20 @@
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
from builtins import str import sys
from builtins import range try:
from builtins import object from builtins import str
from builtins import range
from builtins import object
except ImportError:
# This should not happen because the Python packages are checked before invoking this script. However, here is
# some output which should help if we missed something.
print('Import has failed probably because of the missing "future" package. Please install all the packages for '
'interpreter {} from the requirements.txt file.'.format(sys.executable))
# The path to requirements.txt is not provided because this script could be invoked from an IDF project (then the
# requirements.txt from the IDF_PATH should be used) or from the documentation project (then the requirements.txt
# for the documentation directory should be used).
sys.exit(1)
from io import open from io import open
import os import os
import argparse import argparse