I do test builds using a command like the one below:

sphinx-build -n -a -b html C:\Data\docs\Help-root\cs-mpHelp C:\Data\Docs\build

Our production build is run from a complex series of Python scripts - for prod 
builds the developer now says they'll probably write the value of 
ifconf_product to the conf.py file.



-----Original Message-----
From: sphinx-dev@googlegroups.com [mailto:sphinx-dev@googlegroups.com] On 
Behalf Of Ernesto Posse
Sent: 05 December 2011 19:50
To: sphinx-dev@googlegroups.com
Subject: Re: [sphinx-dev] Using if statements in conf.py

My comments are below.

On Mon, Dec 5, 2011 at 5:47 AM, Alastair Dent <alastair.d...@imgtec.com> wrote:
> Thanks, that helps. I really don't know anything about Python - my background 
> is with languages like Fortran and Pascal.
>
> How do I pass an argument to conf.py?
>
> If I were doing this in Pascal I'd declare it as a global variable and 
> initialise it explicitly at an appropriate point. Python doesn't seem to work 
> like that.  From what I can tell, I need to use something like:
>
> ifconf_product = sys.argv[1]
>
> in the conf.py. But how do I call conf.py with an argument?

Well, it depends on what you are trying to do, and why are you trying to call 
conf.py. First of all, normally you do not call conf.py directly. conf.py is 
automatically "called" (or rather, imported) when you execute sphinx-build. 
Using sys.arg should in principle give you access to the command-line arguments 
to sphinx-build. You did not mention in your e-mail if you actually tried this. 
If you did, and it is not working, what kind of behaviour, messages or errors 
do you get?

Also note that the declarations in conf.py *are* variables (and you can think 
of them as 'global' in certain sense) and are initialized right there (in 
conf.py). This file is meant to contain the parameters of the sphinx-build 
process, so it seems rather odd that you are trying to "call" conf.py. Perhaps 
if you clarified what is it that you are trying to do, might help.

If you are trying to have alternative configurations, it has been suggested to 
have two (or more) separate config files, e.g.
config1.py, config2.py and then invoking:

sphinx-build -c /path/to/config1.py

of

sphinx-build -c /path/to/config2.py



>
> -----Original Message-----
> From: sphinx-dev@googlegroups.com [mailto:sphinx-dev@googlegroups.com] 
> On Behalf Of Ernesto Posse
> Sent: 02 December 2011 22:29
> To: sphinx-dev@googlegroups.com
> Subject: Re: [sphinx-dev] Using if statements in conf.py
>
> On Fri, Dec 2, 2011 at 11:27 AM, Alastair Dent <alastair.d...@imgtec.com> 
> wrote:
>> Can I do something like the following in conf.py:
>
> You can but you'll have to use Python syntax (conf.py is a Python 
> module), so instead of
>
>> if ifconf_product='mini' then
>>
>> exclude_patterns = ['interface/*.rst','dialogs/*.rst']
>>
>> elseif ifconf_product='main' then
>>
>>                 exclude_patterns = ['mini-indexes.rst]
>>
>>
>>
>> endif
>
> it should be something like
>
> if ifconf_product=='mini':
>    exclude_patterns = ['interface/*.rst','dialogs/*.rst']
> elif ifconf_product=='main':
>    exclude_patterns = ['mini-indexes.rst]
>
>
> --
> Ernesto Posse
>
> Modelling and Analysis in Software Engineering School of Computing 
> Queen's University - Kingston, Ontario, Canada
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-dev" group.
> To post to this group, send email to sphinx-dev@googlegroups.com.
> To unsubscribe from this group, send email to 
> sphinx-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sphinx-dev?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-dev" group.
> To post to this group, send email to sphinx-dev@googlegroups.com.
> To unsubscribe from this group, send email to 
> sphinx-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sphinx-dev?hl=en.
>



--
Ernesto Posse

Modelling and Analysis in Software Engineering School of Computing Queen's 
University - Kingston, Ontario, Canada

--
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to sphinx-dev@googlegroups.com.
To unsubscribe from this group, send email to 
sphinx-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to sphinx-dev@googlegroups.com.
To unsubscribe from this group, send email to 
sphinx-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to