Re: [PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-17 Thread Tomi Ollila
On Tue, Jul 14 2020, Floris Bruynooghe wrote:

> On Sat 11 Jul 2020 at 10:20 -0300, David Bremner wrote:
>
>> I don't love the use of exec, but it is getting unwieldy to pass
>
> It's already a config file written in Python which is a terrible sin.
> So no need to apologise, I think it makes sense in this context.
>
>> configuration options on the sphinx-build command line, and I
>> anticipate further use of conditionals.
>> ---
>>  configure  |  8 
>>  doc/Makefile.local |  2 +-
>>  doc/conf.py| 11 ---
>>  3 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 80cbac4f..177432db 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
>>  PLATFORM=${platform}
>>  EOF
>>  
>> +cat > sphinx.config <> +# Generate by configure, run from doc/conf.py
>
> Minor insignificant typo: Generated

Just to tease David more, I think I had that fixed in my suggestion ;)
LFTM with this typo fixed.

Tomi

>
>> +EOF
>> +if [ $WITH_EMACS = "1" ]; then
>> +printf "tags.add('WITH_EMACS')\n" >> sphinx.config
>> +fi
>> +printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
>> +
>>  # Finally, after everything configured, inform the user how to continue.
>>  cat <>  
>> diff --git a/doc/Makefile.local b/doc/Makefile.local
>> index 769438ed..598b6028 100644
>> --- a/doc/Makefile.local
>> +++ b/doc/Makefile.local
>> @@ -4,7 +4,7 @@ dir := doc
>>  
>>  # You can set these variables from the command line.
>>  SPHINXOPTS:= -q
>> -SPHINXBUILD   = WITH_EMACS=${WITH_EMACS} RSTI_DIR=$(realpath emacs) 
>> sphinx-build
>> +SPHINXBUILD   = sphinx-build
>>  DOCBUILDDIR  := $(dir)/_build
>>  
>>  # Internal variables.
>> diff --git a/doc/conf.py b/doc/conf.py
>> index 70987ac5..fdff2a2c 100644
>> --- a/doc/conf.py
>> +++ b/doc/conf.py
>> @@ -22,6 +22,13 @@ for pathdir in ['.', '..']:
>>  with open(version_file,'r') as infile:
>>  version=infile.read().replace('\n','')
>>  
>> +# read generated config
>> +for pathdir in ['.', '..']:
>> +conf_file = os.path.join(location,pathdir,'sphinx.config')
>> +if os.path.exists(conf_file):
>> +with open(conf_file,'r') as infile:
>> +exec(''.join(infile.readlines()))
>> +
>>  # The full version, including alpha/beta/rc tags.
>>  release = version
>>  
>> @@ -29,12 +36,10 @@ release = version
>>  # directories to ignore when looking for source files.
>>  exclude_patterns = ['_build']
>>  
>> -if os.environ.get('WITH_EMACS') == '1':
>> +if tags.has('WITH_EMACS'):
>>  # Hacky reimplementation of include to workaround limitations of
>>  # sphinx-doc
>>  lines = ['.. include:: /../emacs/rstdoc.rsti\n\n'] # in the source tree
>> -rsti_dir = os.environ.get('RSTI_DIR')
>> -# the other files are from the build tree
>>  for file in ('notmuch.rsti', 'notmuch-lib.rsti', 'notmuch-show.rsti', 
>> 'notmuch-tag.rsti'):
>>  lines.extend(open(rsti_dir+'/'+file))
>>  rst_epilog = ''.join(lines)
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-15 Thread David Bremner
Tomi Ollila  writes:
>
> perhaps instead of multiple redirections to the file, 
>
> {
> echo "# Generated by configure, run from doc/conf.py"
> echo
> if [ $WITH_EMACS = "1" ]; then
> printf "tags.add('WITH_EMACS')\n"
> fi 
> printf "rsti_dir = '%s'\n" "$(realpath emacs)"
>
> } > sphinx.config
> 

Sorry, I dropped the ball there. I did actually make this change at some
point but I rebased it away. I can do a cleanup patch.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-14 Thread Floris Bruynooghe
On Sat 11 Jul 2020 at 17:00 +0300, Tomi Ollila wrote:

> On Sat, Jul 11 2020, David Bremner wrote:
>
>> I don't love the use of exec, but it is getting unwieldy to pass
>> configuration options on the sphinx-build command line, and I
>> anticipate further use of conditionals.
>
> Perhaps less "opinions" in commit message.
>
> (and as I think I don't comment 2/2, s/seperate/separate/ there)
>
>
>> ---
>>  configure  |  8 
>>  doc/Makefile.local |  2 +-
>>  doc/conf.py| 11 ---
>>  3 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 80cbac4f..177432db 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
>>  PLATFORM=${platform}
>>  EOF
>>  
>> +cat > sphinx.config <> +# Generate by configure, run from doc/conf.py
>> +EOF
>> +if [ $WITH_EMACS = "1" ]; then
>> +printf "tags.add('WITH_EMACS')\n" >> sphinx.config
>> +fi
>> +printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
>> +
>
> perhaps instead of multiple redirections to the file, 
>
> {
> echo "# Generated by configure, run from doc/conf.py"
> echo
> if [ $WITH_EMACS = "1" ]; then
> printf "tags.add('WITH_EMACS')\n"
> fi 
> printf "rsti_dir = '%s'\n" "$(realpath emacs)"
>
> } > sphinx.config
> 
> alternative (someone might think less readable... ;/):
>
>  exec 3>&1 1> sphinx.config
>
>  echo "# Generated by configure, run from doc/conf.py"
>  ...
>
>  exec 1>&3 3>&-

I'd probably prefer this last one, but I don't mind any of the solutions or
even the current one.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-14 Thread Floris Bruynooghe
On Sat 11 Jul 2020 at 10:20 -0300, David Bremner wrote:

> I don't love the use of exec, but it is getting unwieldy to pass

It's already a config file written in Python which is a terrible sin.
So no need to apologise, I think it makes sense in this context.

> configuration options on the sphinx-build command line, and I
> anticipate further use of conditionals.
> ---
>  configure  |  8 
>  doc/Makefile.local |  2 +-
>  doc/conf.py| 11 ---
>  3 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index 80cbac4f..177432db 100755
> --- a/configure
> +++ b/configure
> @@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
>  PLATFORM=${platform}
>  EOF
>  
> +cat > sphinx.config < +# Generate by configure, run from doc/conf.py

Minor insignificant typo: Generated

> +EOF
> +if [ $WITH_EMACS = "1" ]; then
> +printf "tags.add('WITH_EMACS')\n" >> sphinx.config
> +fi
> +printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
> +
>  # Finally, after everything configured, inform the user how to continue.
>  cat <  
> diff --git a/doc/Makefile.local b/doc/Makefile.local
> index 769438ed..598b6028 100644
> --- a/doc/Makefile.local
> +++ b/doc/Makefile.local
> @@ -4,7 +4,7 @@ dir := doc
>  
>  # You can set these variables from the command line.
>  SPHINXOPTS:= -q
> -SPHINXBUILD   = WITH_EMACS=${WITH_EMACS} RSTI_DIR=$(realpath emacs) 
> sphinx-build
> +SPHINXBUILD   = sphinx-build
>  DOCBUILDDIR  := $(dir)/_build
>  
>  # Internal variables.
> diff --git a/doc/conf.py b/doc/conf.py
> index 70987ac5..fdff2a2c 100644
> --- a/doc/conf.py
> +++ b/doc/conf.py
> @@ -22,6 +22,13 @@ for pathdir in ['.', '..']:
>  with open(version_file,'r') as infile:
>  version=infile.read().replace('\n','')
>  
> +# read generated config
> +for pathdir in ['.', '..']:
> +conf_file = os.path.join(location,pathdir,'sphinx.config')
> +if os.path.exists(conf_file):
> +with open(conf_file,'r') as infile:
> +exec(''.join(infile.readlines()))
> +
>  # The full version, including alpha/beta/rc tags.
>  release = version
>  
> @@ -29,12 +36,10 @@ release = version
>  # directories to ignore when looking for source files.
>  exclude_patterns = ['_build']
>  
> -if os.environ.get('WITH_EMACS') == '1':
> +if tags.has('WITH_EMACS'):
>  # Hacky reimplementation of include to workaround limitations of
>  # sphinx-doc
>  lines = ['.. include:: /../emacs/rstdoc.rsti\n\n'] # in the source tree
> -rsti_dir = os.environ.get('RSTI_DIR')
> -# the other files are from the build tree
>  for file in ('notmuch.rsti', 'notmuch-lib.rsti', 'notmuch-show.rsti', 
> 'notmuch-tag.rsti'):
>  lines.extend(open(rsti_dir+'/'+file))
>  rst_epilog = ''.join(lines)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-11 Thread Tomi Ollila
On Sat, Jul 11 2020, David Bremner wrote:

> I don't love the use of exec, but it is getting unwieldy to pass
> configuration options on the sphinx-build command line, and I
> anticipate further use of conditionals.

Perhaps less "opinions" in commit message.

(and as I think I don't comment 2/2, s/seperate/separate/ there)


> ---
>  configure  |  8 
>  doc/Makefile.local |  2 +-
>  doc/conf.py| 11 ---
>  3 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index 80cbac4f..177432db 100755
> --- a/configure
> +++ b/configure
> @@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
>  PLATFORM=${platform}
>  EOF
>  
> +cat > sphinx.config < +# Generate by configure, run from doc/conf.py
> +EOF
> +if [ $WITH_EMACS = "1" ]; then
> +printf "tags.add('WITH_EMACS')\n" >> sphinx.config
> +fi
> +printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
> +

perhaps instead of multiple redirections to the file, 

{
echo "# Generated by configure, run from doc/conf.py"
echo
if [ $WITH_EMACS = "1" ]; then
printf "tags.add('WITH_EMACS')\n"
fi 
printf "rsti_dir = '%s'\n" "$(realpath emacs)"

} > sphinx.config

alternative (someone might think less readable... ;/):

 exec 3>&1 1> sphinx.config

 echo "# Generated by configure, run from doc/conf.py"
 ...

 exec 1>&3 3>&-


>  # Finally, after everything configured, inform the user how to continue.
>  cat <

[PATCH 1/2] doc: replace use of environment variables with a generated config

2020-07-11 Thread David Bremner
I don't love the use of exec, but it is getting unwieldy to pass
configuration options on the sphinx-build command line, and I
anticipate further use of conditionals.
---
 configure  |  8 
 doc/Makefile.local |  2 +-
 doc/conf.py| 11 ---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 80cbac4f..177432db 100755
--- a/configure
+++ b/configure
@@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
 PLATFORM=${platform}
 EOF
 
+cat > sphinx.config <> sphinx.config
+fi
+printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
+
 # Finally, after everything configured, inform the user how to continue.
 cat <