I'm brand new to Sphinx and reStructuredText.
Inside my Sphinx conf.py
I defined:
version = '0.0.2'
Inside of tutorial.rst
I want access the version
variable and display 0.0.2
in my html file. I tried:
version
|version|
:version:
.. |version|
.. :version:
I succeeded in testing the contents of the version.
.. ifconfig:: version == '0.0.2'
This prints!
This was encouraging, but not what I want.
If you want this to be available everywhere, you can do something like this:
conf.py
rst_epilog = """
.. |ProjectVersion| replace:: Foo Project, version {versionnum}
""".format(
versionnum = version,
)
file.rst
As one may see, we have made significant strides in |ProjectVersion|
and hope that you enjoy the product!
The rst_epilog list makes items within it globally-available to compiled .rst files. See http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With