Hi,

On Friday, 17 January 2020 11:22:06 UTC+1, Olivier Carrere wrote:
>
> Hi,
>
> How can I put all my substitutions in a dedicated, external file, and 
> include them in my conf.py?
>
> I tried to insert an  external substitutions file with via literalinclude 
> with rst_prolog or rst_epilog, but then, substitions are not evaluated at 
> build time and appear literally in the HTML output.
>
> Thanks
>
Assuming your substitutions are in replace.txt, in conf. py write 

rst_epilog = open("replace.txt", "r").read()
or
rst_prolog = open("replace.txt", "r").read()

Since I use the same replace.txt for different projects, I have a slight 
different definition of rst_epilog, which I report in case someone finds it 
useful.

rst_epilog = """
.. |product| replace:: %s
.. |company| replace:: %s
"""  % (project, comp) + open("replace.txt", "r").read()

Here, project and comp are variables defined in conf.py that vary with the 
project I am working on.
HTH,
Stefano

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/ce38552c-4e36-4553-8232-24f64202a32c%40googlegroups.com.

Reply via email to