Two possible solutions in that thread, neither great:
Option 1: use .. parsed-literal:: instead of .. code-block:: , but this makes the code block have different styling from other code blocks (different text color) and hyperlinks become clickable: https://ibb.co/9VP61vx
I've been working a bit on this issue and turns out that global variable substitution in Sphinx reST is more complicated (than it should).
Based on:
https:/ /www.sphinx- doc.org/ en/master/ usage/configura tion.html# confval- rst_epilog
and
https:/ /opendev. org/openstack/ openstack- ansible/ src/commit/ 5a8e199ca1ac525 c1f6a5a5c3d6196 4f2393dfce/ deploy- guide/source/ conf.py# L59
I've added in doc/source/conf.py:
rst_epilog = """ ANSIBLE_ VER_EXCLUSIVE| replace:: {MAX_KOLLA_ ANSIBLE_ VER_EXCLUSIVE} VER_EXCLUSIVE| replace:: {MAX_ANSIBLE_ VER_EXCLUSIVE} ANSIBLE_ GIT_BRANCH| replace:: {KOLLA_ ANSIBLE_ GIT_BRANCH} KOLLA_ANSIBLE_ VER_EXCLUSIVE= MAX_KOLLA_ ANSIBLE_ VER_EXCLUSIVE, ANSIBLE_ VER_EXCLUSIVE= MAX_ANSIBLE_ VER_EXCLUSIVE, GIT_BRANCH= KOLLA_GIT_ BRANCH, ANSIBLE_ GIT_BRANCH= KOLLA_ANSIBLE_ GIT_BRANCH
.. |MAX_KOLLA_
.. |MAX_ANSIBLE_
.. |KOLLA_GIT_BRANCH| replace:: {KOLLA_GIT_BRANCH}
.. |KOLLA_
""".format(
MAX_
MAX_
KOLLA_
KOLLA_
)
But unfortunately variables are not replaced in code blocks like this:
.. code-block:: console
git clone --branch |KOLLA_GIT_BRANCH| https:/ /opendev. org/openstack/ kolla ANSIBLE_ GIT_BRANCH| https:/ /opendev. org/openstack/ kolla-ansible
git clone --branch |KOLLA_
also according to https:/ /stackoverflow. com/questions/ 42158111/ variable- substitution- not-working- properly- in-sphinx
Two possible solutions in that thread, neither great:
Option 1: use .. parsed-literal:: instead of .. code-block:: , but this makes the code block have different styling from other code blocks (different text color) and hyperlinks become clickable: https:/ /ibb.co/ 9VP61vx
Option 2: add a docs dependency lib: https:/ /github. com/adamtheturt le/sphinx- substitution- extensions
Anyone has a better idea?