mirror of
https://git.yoctoproject.org/poky
synced 2026-04-29 18:32:20 +02:00
The Yocto Project docs was migrated from Docbook to Sphinx in YP 3.2. This 3.1 is an LTS release, and since 3.1 docs are 'close to' the docs in 3.2, we agreed to backport sphinx docs onto 3.1. This first patch brings all changes done in 3.2 until: 7f64574f7 README: include detailed information about sphinx There are other changes after this commit, but they will be selectively backported in individual patches. This patch was generated with the following command: git cherry-pick -n \ $(git log --reverse --oneline \ ac352ad7f95db7eeacb53c2778caa31800bd7c26..7f64574f7 \ | cut -f1 -d' ') The following commits were applies in the dunfell docs, but not in master, so they were first reverted (and squashed into this change). A commit will reintroduce the content from these patches in the Sphinx files in a followup patch. 069c27574 Documenation: Prepared for the 3.1.1 release bd140f0f9 Documentation: Add 3.1.1 version updates missing from previous commit 17cc71a8f Documenation: Prepared for the 3.1.2 release 1a69e2c02 Documenation: Prepared for the 3.1.3 release 8910ac1c7 Documenation: Prepared for the 3.1.4 release (From yocto-docs rev: c25fe058b88b893b0d146f3ed27320b47cdec236) Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
import re
|
|
import sys
|
|
|
|
import sphinx
|
|
from sphinx.application import Sphinx
|
|
|
|
# This extension uses pyyaml, report an explicit
|
|
# error message if it's not installed
|
|
try:
|
|
import yaml
|
|
except ImportError:
|
|
sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\
|
|
\nPlease make sure to install pyyaml python package.\n")
|
|
sys.exit(1)
|
|
|
|
__version__ = '1.0'
|
|
|
|
# Variables substitutions. Uses {VAR} subst using variables defined in poky.yaml
|
|
# Each .rst file is processed after source-read event (subst_vars_replace runs once per file)
|
|
subst_vars = {}
|
|
|
|
def subst_vars_replace(app: Sphinx, docname, source):
|
|
result = source[0]
|
|
for k in subst_vars:
|
|
result = result.replace("&"+k+";", subst_vars[k])
|
|
source[0] = result
|
|
|
|
PATTERN = re.compile(r'&(.*?);')
|
|
def expand(val, src):
|
|
return PATTERN.sub(lambda m: expand(src.get(m.group(1), ''), src), val)
|
|
|
|
def setup(app: Sphinx):
|
|
#FIXME: if poky.yaml changes, files are not reprocessed.
|
|
with open("poky.yaml") as file:
|
|
subst_vars.update(yaml.load(file, Loader=yaml.FullLoader))
|
|
|
|
for k in subst_vars:
|
|
subst_vars[k] = expand(subst_vars[k], subst_vars)
|
|
|
|
app.connect('source-read', subst_vars_replace)
|
|
|
|
return dict(
|
|
version = __version__,
|
|
parallel_read_safe = True,
|
|
parallel_write_safe = True
|
|
)
|