diff options
author | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2020-07-03 17:46:31 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-17 10:09:33 +0100 |
commit | 44e8d439aa57973437ea0f9d7ee60b8f55df9dd1 (patch) | |
tree | 48eef6bfd1207830c608ee352ad998db52b9749a /documentation/conf.py | |
parent | 18786fbffe299f81b7c156ba1cee00359589dc3f (diff) | |
download | poky-44e8d439aa57973437ea0f9d7ee60b8f55df9dd1.tar.gz |
sphinx: conf: add substitutions/global variables
The Yocto Project documentation makes heavy use of 'global'
variables. In Docbook these 'variables' are stored in the file
poky.ent. This Docbook feature is not handled automatically with
Pandoc. Sphinx has builtin support for substitutions however they are
local to each reST file by default. They can be made global by using
rst_prolog:
rst_prolog
A string of reStructuredText that will be included at the
beginning of every source file that is read.
However Sphinx substitution feature has several important limitations. For
example, substitution does not work in code-block section.
yocto-vars.py is an extension that processes .rst file to find and
replace 'variables'. This plugin will do variables substitutions
whenever a rst file is read, so it happens before sphinx parses the
content.
All variables are set in poky.yaml. It's a simple YAML file with pairs
of variable/value, and the file is parsed once during setup. It's
important to note that variables can reference other
variables. poky.yaml was generated by converting poky.ent into a YAML
format.
To use a variable in the Yocto Project .rst files, make sure it is
defined in poky.yaml, and then you can use : &DISTRO_NAME;
For external links, Sphinx has a specific extension called extlinks,
let's use it instead of variable substituions. Note that we
intentionnally did not put the trailing '/' in the URL, this is to
allow us to use :yocto_git:`/` trick to get the actual URL displayed
in the HTML.
(From yocto-docs rev: dc5f53fae8fdfdda04285869dd1419107b920bfe)
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/conf.py')
-rw-r--r-- | documentation/conf.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/documentation/conf.py b/documentation/conf.py index dd20e44a1a..5519acb87a 100644 --- a/documentation/conf.py +++ b/documentation/conf.py | |||
@@ -26,10 +26,15 @@ author = 'The Linux Foundation' | |||
26 | 26 | ||
27 | # -- General configuration --------------------------------------------------- | 27 | # -- General configuration --------------------------------------------------- |
28 | 28 | ||
29 | # to load local extension from the folder 'sphinx' | ||
30 | sys.path.insert(0, os.path.abspath('sphinx')) | ||
31 | |||
29 | # Add any Sphinx extension module names here, as strings. They can be | 32 | # Add any Sphinx extension module names here, as strings. They can be |
30 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | 33 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
31 | # ones. | 34 | # ones. |
32 | extensions = [ | 35 | extensions = [ |
36 | 'sphinx.ext.extlinks', | ||
37 | 'yocto-vars' | ||
33 | ] | 38 | ] |
34 | 39 | ||
35 | # Add any paths that contain templates here, relative to this directory. | 40 | # Add any paths that contain templates here, relative to this directory. |
@@ -44,6 +49,26 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | |||
44 | # set it ourselves. | 49 | # set it ourselves. |
45 | master_doc = 'index' | 50 | master_doc = 'index' |
46 | 51 | ||
52 | # create substitution for project configuration variables | ||
53 | rst_prolog = """ | ||
54 | .. |project_name| replace:: %s | ||
55 | .. |copyright| replace:: %s | ||
56 | .. |author| replace:: %s | ||
57 | """ % (project, copyright, author) | ||
58 | |||
59 | # external links and substitutions | ||
60 | extlinks = { | ||
61 | 'yocto_home': ('https://yoctoproject.org%s', None), | ||
62 | 'yocto_wiki': ('https://wiki.yoctoproject.org%s', None), | ||
63 | 'yocto_dl': ('https://downloads.yoctoproject.org%s', None), | ||
64 | 'yocto_lists': ('https://lists.yoctoproject.org%s', None), | ||
65 | 'yocto_bugs': ('https://bugzilla.yoctoproject.org%s', None), | ||
66 | 'yocto_ab': ('https://autobuilder.yoctoproject.org%s', None), | ||
67 | 'yocto_git': ('https://git.yoctoproject.org%s', None), | ||
68 | 'oe_home': ('https://www.openembedded.org%s', None), | ||
69 | 'oe_lists': ('https://lists.openembedded.org%s', None), | ||
70 | } | ||
71 | |||
47 | # -- Options for HTML output ------------------------------------------------- | 72 | # -- Options for HTML output ------------------------------------------------- |
48 | 73 | ||
49 | # The theme to use for HTML and HTML Help pages. See the documentation for | 74 | # The theme to use for HTML and HTML Help pages. See the documentation for |