简体   繁体   中英

Multiple substitutions with rst_prolog in Sphinx

How do I define multiple global substitutions in Sphinx?

I see in this question how to create global substitutions using rst_prolog in conf.py. Eg,

rst_prolog = '.. |my_conf_val| replace:: 42'

All examples of this that I can find only define one substitution in rst_prolog , but I want to do more than one. I tried this:

rst_prolog = """.. |sub1| replace:: mine1\
         .. |sub2| replace:: mine2"""

When I put |sub1| into text in an rst file, |sub1| is (not surprisingly) replaced with:

mine1 .. |sub2| replace:: mine2

What is the correct syntax here?

Make sure that the alignment of the substitution definitions is consistent. Backslashes are not needed. This works:

rst_prolog = """
.. |sub1| replace:: mine1
.. |sub2| replace:: mine2
"""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM