How to use a substitution variable in Toctree Sphinx?

124 Views Asked by At

The problem consist to use a substitution variable var_link which is declared in conf.py file as follow :

var_link = 'https://www.google.fr/'

This variable is added into rst_prolog by

rst_prolog = f"""
.. |var_link| replace:: {var_link}
"""

And I need to use this link in my toctree index as :

.. toctree::
   :maxdepth: 1

   Title <|var_link|>

When I try the above syntax, it gives me a warning :

WARNING: toctree contains reference to nonexisting document '|var_link|'

Thanks for your helpful

1

There are 1 best solutions below

1
user23258048 On

Within conv.py

open("toctree.rst","w").write(f"""

.. toctree:: HOME file://{my_html_file}" :hidden:

""")

Within rst file:

.. toctree:: .......

.. include:: toctree.rst

.. toctree:: .......