Re: [sphinx-dev] Using if statements in conf.py

2011-12-06 Thread Viktoras M
while going with config switching, you can include some common values from 
third file, will save some copy-paste work:

config1.py:
myPlatform="windows"
execfile("common-config.py")

config2.py:
myPlatform="linux"
execfile("common-config.py")

common-config.py:
echo "my current platform is:",myPlatform



normally, execfile() is not a prefered way include module in python, but in 
this case it will save some trouble of exchanging values from caller 
config. going the "normal" way (using import statements) you'd have to 
declare everything from common-config.py as function(s), and call them from 
config1/config2 with config-specific arguments.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sphinx-dev/-/GDcYMgUPKl0J.
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.



RE: [sphinx-dev] Using if statements in conf.py

2011-12-06 Thread Alastair Dent
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  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  
> 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.



Re: [sphinx-dev] Using if statements in conf.py

2011-12-05 Thread Ernesto Posse
My comments are below.

On Mon, Dec 5, 2011 at 5:47 AM, Alastair Dent  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  
> 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.



Re: [sphinx-dev] Using if statements in conf.py

2011-12-05 Thread Maxim Yaskevich

12/5/2011 1:47 PM, Alastair Dent ?:

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?

-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  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.



Hello!

There are different ways to do that:
1. Use os.system("python conf.py param1 param2");
2. Use subprocess python module:
importsubprocess
child = subprocess.Popen("python conf.py param1 param2").


--
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.



Re: [sphinx-dev] Using if statements in conf.py

2011-12-05 Thread Nick Leaton
Why not create two configs?

One for the short version, one for the longer version and then make the
long, or make the short?

On 5 December 2011 10:47, Alastair Dent  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?
>
> -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 
> 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.
>
>


-- 
Nick

-- 
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.



RE: [sphinx-dev] Using if statements in conf.py

2011-12-05 Thread Alastair Dent
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?

-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  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.



Re: [sphinx-dev] Using if statements in conf.py

2011-12-02 Thread Ernesto Posse
On Fri, Dec 2, 2011 at 11:27 AM, Alastair Dent  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.