@@ -128,6 +128,27 @@ but require you to use Pipenv for them to run and aren't available when
following the instructions from
https://docs.yoctoproject.org/dev/ref-manual/system-requirements.html#required-packages-for-the-build-host.
+Note 2: while not a requirement to build the documentation, some parts of it
+need the [BitBake] and [OpenEmbedded-Core] repositories to be cloned next to the
+yocto-docs repository. This is used to generate documentation from Python
+docstrings. The expected default layout of the different repositories is is:
+
+ bitbake/
+ openembedded-core/
+ yocto-docs/
+
+The paths to BitBake and OpenEmbedded-Core can be overridden by setting the
+BITBAKE_REPO_PATH and OECORE_REPO_PATH environment variables respectively
+before building.
+
+Both BitBake and OpenEmbedded-Core should be cloned to the closest matching tag
+(e.g. 'yocto-6.1' for each of them).
+
+If not cloned, these parts of the documentation will be left empty.
+
+[BitBake]: https://git.openembedded.org/bitbake/
+[OpenEmbedded-Core]: https://git.openembedded.org/openembedded-core/
+
Style checking the Yocto Project documentation
==============================================
@@ -10,8 +10,10 @@ import datetime
import importlib.util
import os
import re
+import subprocess
import sys
+from pathlib import Path
from sphinx.builders.epub3 import Epub3Builder
from sphinx.search import SearchEnglish
from sphinx.search import languages
@@ -37,6 +39,30 @@ author = 'The Linux Foundation'
sys.path.insert(0, os.path.abspath('sphinx'))
+# We require openembedded-core's library to auto-document utilities and such,
+# which itself requires bitbake's library. We assume their default location is
+# next to the yocto-docs repository, but can be overridden with environment
+# variables.
+yocto_docs_parent_dir = Path(__file__).resolve().parent.parent.parent
+bitbake_dir = os.getenv("BITBAKE_REPO_PATH", str(yocto_docs_parent_dir / 'bitbake'))
+oecore_dir = os.getenv("OECORE_REPO_PATH", str(yocto_docs_parent_dir / 'openembedded-core'))
+sys.path.insert(0, os.path.join(bitbake_dir, 'lib'))
+sys.path.insert(0, os.path.join(oecore_dir, 'meta/lib'))
+
+# Check that we can import the oe module. If we can, show some information about
+# the repositories (useful for debugging in case of version mismatch).
+if not importlib.util.find_spec('oe'):
+ print("NOTE: bitbake and/or openembedded-core not found next to yocto-docs, "
+ "auto-documenting oe.* functions will not work")
+ if os.getenv('AUTOBUILDER_BUILD', '0') == '1':
+ sys.exit(1)
+else:
+ bitbake_rev = subprocess.check_output(["git", "-C", bitbake_dir, "describe"], encoding="utf-8").strip()
+ oecore_rev = subprocess.check_output(["git", "-C", oecore_dir, "describe"], encoding="utf-8").strip()
+ print("Found bb and oe modules:\n"
+ f"{bitbake_dir} ({bitbake_rev})\n"
+ f"{oecore_dir} ({oecore_rev})")
+
# -- General configuration ---------------------------------------------------
# Prevent building with an outdated version of sphinx
@@ -46,6 +72,7 @@ needs_sphinx = "4.0"
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
+ 'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
@@ -101,6 +128,12 @@ manpages_url = 'https://manpages.debian.org/{path}'
# Suppress "WARNING: unknown mimetype for ..."
suppress_warnings = ['epub.unknown_project_files']
+# Unless, we're building the docs with the Autobuilder, suppress warnings from
+# the autodoc module, as it assumes openembedded-core and bitbake are cloned
+# in yocto-docs.
+if not os.getenv('AUTOBUILDER_BUILD', '0') == '1':
+ suppress_warnings.append('autodoc.import_object')
+
# We need XeTeX to process special unicode character, sometimes the contributor
# list from the release note contains those.
# See https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html.
Enable the sphinx.ext.autodoc extension for this Sphinx build, but do not make it a requirement for building the documentation locally. The idea is to auto-document functions from openembedded-core here (which depends on bitbake since the oe library imports the bb library). However, this is most likely not the case for people wanting to contribute the yocto-docs documentation: therefore, ignore any 'autodoc.import_object' warning by default. An exception to that rule is when building from the Autobuilder, where we _need_ those warnings (turned to errors) to be caught. We expect the Autobuilder to set AUTOBUILDER_BUILD to 1 in these conditions. Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> --- documentation/README | 21 +++++++++++++++++++++ documentation/conf.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)