From: Quentin Young Date: Fri, 12 Jan 2018 21:00:24 +0000 (-0500) Subject: doc: make conf.py know about variable substitutions X-Git-Tag: frr-5.0-dev~165^2~87 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=964b36623b38b9813cde1a8bf79ab9ced95305c1;p=mirror%2Ffrr.git doc: make conf.py know about variable substitutions The old Texi docs had some Makefile-style variable substitutions they used to pull in information like release date, configured install path, etc. Sphinx has this ability as well, we start making use of it here. Signed-off-by: Quentin Young --- diff --git a/doc/user/conf.py b/doc/user/conf.py index ebb8b828a1..d62e46301c 100644 --- a/doc/user/conf.py +++ b/doc/user/conf.py @@ -24,7 +24,10 @@ import re # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +needs_sphinx = '1.0' + +# prolog for various variable substitutions +rst_prolog = '' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -36,7 +39,7 @@ templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] +# source_suffix = ['.rst'] source_suffix = '.rst' # The encoding of source files. @@ -59,6 +62,10 @@ version = u'?.?' # The full version, including alpha/beta/rc tags. release = u'?.?-?' +install_prefix_etc = "" + +# extract version information, installation location, other stuff we need to +# use when building final documents val = re.compile('^S\["([^"]+)"\]="(.*)"$') with open('../../config.status', 'r') as cfgstatus: for ln in cfgstatus.readlines(): @@ -67,6 +74,17 @@ with open('../../config.status', 'r') as cfgstatus: if m.group(1) == 'PACKAGE_VERSION': release = m.group(2) version = release.split('-')[0] + if m.group(1) == 'CFG_SYSCONF': + install_prefix_etc = m.group(2) + + +# add substitutions to prolog +rst_prolog += ''' +.. |INSTALL_PREFIX_ETC| replace:: {} +.. |PACKAGE_VERSION| replace:: {} +'''.format(install_prefix_etc, version) + + # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.