ifconfig and variables from conf.py

162 views
Skip to first unread message

Andrew

unread,
Oct 27, 2008, 11:22:55 AM10/27/08
to sphinx-dev
Hi,

I was hoping to use the ifconfig to build slightly different versions
of my documentation (for different platforms).

I put the following code in my .rst file:

.. ifconfig:: livecd

Some Live CD specific text

and then added

livecd = True

to the conf.py. However, because (I think) of the line "if name in
self.values:" in "init_values" in "config.py", my 'custom' variable is
never loaded and so I get a warning when I build: "NameError: name
'livecd' is not defined" . I don't want to have to add "livecd" into
the "config_values" variable at the start of "config.py" as it's not a
general option - it's specific to this project.

Is there a reason that other variables can't be included in the
environment used by ifconfig? Is there a better way of achieving what
I'm trying to do (without maintaining two different sets of
documents)?

Thanks

Andrew

Georg Brandl

unread,
Oct 27, 2008, 1:34:55 PM10/27/08
to sphin...@googlegroups.com
Andrew schrieb:

Yes -- new config values should be made known to Sphinx via the extension
API.

Put this into your conf.py:

def setup(app):
app.add_config_value('livecd', <the default: True or False>, True)

For more, see <http://sphinx.pocoo.org/ext/appapi.html>.

cheers,
Georg

Andrew

unread,
Oct 27, 2008, 2:27:17 PM10/27/08
to sphinx-dev
Thanks for getting back to me so quickly! I hadn't seen that part of
the documentation (or hadn't thought it would relate to this).

Thanks for your help (and an excellent tool!)

Regards

Andrew

Kent Tenney

unread,
Oct 29, 2008, 9:27:47 AM10/29/08
to sphin...@googlegroups.com

might be good to add a mention of ``app.add_config_value`` on that page

>
> cheers,
> Georg
>
> >
>

Georg Brandl

unread,
Nov 1, 2008, 10:55:19 AM11/1/08
to sphin...@googlegroups.com
Kent Tenney schrieb:

Indeed, added the reference and an example setup function.
The ifconfig docs were not updated from a different config API.

cheers,
Georg

Reply all
Reply to author
Forward
0 new messages