]> git.puffer.fish Git - mirror/frr.git/commitdiff
doc: make conf.py know about variable substitutions
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 12 Jan 2018 21:00:24 +0000 (16:00 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 12 Jan 2018 21:00:24 +0000 (16:00 -0500)
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 <qlyoung@cumulusnetworks.com>
doc/user/conf.py

index ebb8b828a1e0ca31b40b0aa5fa1b60e9eef34c18..d62e46301c9ce0cb7a7dbd4b288203636d574fed 100644 (file)
@@ -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 = "<install_prefix>"
+
+# 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.