Hello.

I've scoured the docs and don't see anything that will quite do what I'm 
looking for. I've been at this a few days and am hoping someone here can 
help me. 

Let's say I'm writing documentation for a pet store software package. I'm 
trying to build two sets of documentation: one for dog/llama owners, one 
for cat owners. I'm building html docs using *make -e html*. This should 
bring in the myPet environmental variable. 

If I make a static *.. |myPet| replace:: |myCat|* entry in rst_epilog, I 
get the output I'm after. But I really want to do something like *.. 
|myPet| replace:: '|' += os.environ.get('myPet') += '|'*

*Right now, ifconfig has the desired outcome, but replacement (in conf.py, 
rst_epilog) doesn't work. How can I make replacement work (e.g. dynamically 
.. |myPet| replace:: |myCat|)?* *Yes, I could probably hack together a 
sed/awk script to change these lines in conf.py, but there must be a better 
way.*

I would much rather type out:

*Thanks for buying a fuzzy pet who says |myPet|!* 


rather than something like 

*Thanks for buying a fuzzy pet who says *

 

*.. ifconfig:: myPet in ('|myCat|')*

*   Meow*

*.. ifconfig:: myPet in ('|myDog|')*

*   Woof*

*!*


*Environment*: 

$ printenv | grep "myPet"
myPet=myCat


*conf.py*:
 

> myPet= u''
def setup(app):
    app.add_config_value('myPet', '', 'env')

myPet += os.environ.get('myPet')

rst_epilog = """

.. |myCat| replace:: Meow
.. |myDog| replace:: Woof

""" 


*Information.rst*: 

This software is designed to run on Windows, Mac OS and Linux. 

.. ifconfig:: myPet in ('|myCat|')

   In order to install this software, the **Cat** must be installed on your 
system.

.. ifconfig:: myPet in ('|myDog|')

   In order to install this software, the **Dog** must be installed on your 
system.


*Changelog.rst*:
* Better pet store algorithm

.. ifconfig:: myPet in ('|myCat|')

   * |PETSTOREFeatureNew| Improved meowing sounds
   * |PETSTOREFeatureNew| Improved hissing sounds

.. ifconfig:: myPet in ('|myDog|', '|myLlama|')

   * |PETSTOREFeatureNew| Improved slobber effect

* Minor Fixes

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to