summaryrefslogtreecommitdiffstats
path: root/documentation/sphinx
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2020-11-20 20:17:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-04 10:55:00 +0000
commitfa0cb4d34b1073f215fa3c680f2316208739d53d (patch)
treeba89c1f4289fd6456af4409a6a19caf6548dfb9c /documentation/sphinx
parenta038e58f3cd82c56102444bdc5ac76c9f1550a0d (diff)
downloadpoky-fa0cb4d34b1073f215fa3c680f2316208739d53d.tar.gz
sphinx: import docs
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>
Diffstat (limited to 'documentation/sphinx')
-rw-r--r--documentation/sphinx/yocto-vars.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/documentation/sphinx/yocto-vars.py b/documentation/sphinx/yocto-vars.py
new file mode 100644
index 0000000000..8083d7da19
--- /dev/null
+++ b/documentation/sphinx/yocto-vars.py
@@ -0,0 +1,47 @@
1#!/usr/bin/env python
2import re
3import sys
4
5import sphinx
6from sphinx.application import Sphinx
7
8# This extension uses pyyaml, report an explicit
9# error message if it's not installed
10try:
11 import yaml
12except ImportError:
13 sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\
14 \nPlease make sure to install pyyaml python package.\n")
15 sys.exit(1)
16
17__version__ = '1.0'
18
19# Variables substitutions. Uses {VAR} subst using variables defined in poky.yaml
20# Each .rst file is processed after source-read event (subst_vars_replace runs once per file)
21subst_vars = {}
22
23def subst_vars_replace(app: Sphinx, docname, source):
24 result = source[0]
25 for k in subst_vars:
26 result = result.replace("&"+k+";", subst_vars[k])
27 source[0] = result
28
29PATTERN = re.compile(r'&(.*?);')
30def expand(val, src):
31 return PATTERN.sub(lambda m: expand(src.get(m.group(1), ''), src), val)
32
33def setup(app: Sphinx):
34 #FIXME: if poky.yaml changes, files are not reprocessed.
35 with open("poky.yaml") as file:
36 subst_vars.update(yaml.load(file, Loader=yaml.FullLoader))
37
38 for k in subst_vars:
39 subst_vars[k] = expand(subst_vars[k], subst_vars)
40
41 app.connect('source-read', subst_vars_replace)
42
43 return dict(
44 version = __version__,
45 parallel_read_safe = True,
46 parallel_write_safe = True
47 )