sphinx-doc / sphinx-intl

A Sphinx utility that make it easy to translate and to apply translations.
https://sphinx-intl.readthedocs.io/
BSD 2-Clause "Simplified" License
74 stars 38 forks source link

sphinx-intl is not reading SPHINXOPTS #17

Closed clalarco closed 7 years ago

clalarco commented 7 years ago

Hi:

I use tags inside conf.py for some variables required by the filenames, in particular to set htmlhelp_basename.

To do this I use SPHINXOPTS=-tdoc1 or SPHINXOPTS=-tdoc2, and in conf.py:

if tags.has('doc1'):
    htmlhelp_basename = 'doc1'
elif tags.has('doc2'):
    htmlhelp_basename = 'doc2'

However, these options are not used when reading conf.py, hence the sphinx-intl fails.

Any help will be appreciated, thanks.

shimizukawa commented 7 years ago

Hi,

sphinx-intl is no a part of sphinx. So "hence the sphinx-build fails." is related to sphinx instead of sphinx-intl I think.

If the problem is related to the sphinx-intl command, please let me know a bit more detailed situation. If you are having problems with sphinx-build command, please report it to https://github.com/sphinx-doc/sphinx/issues.

Thanks.

clalarco commented 7 years ago

I fixed the typo, I meant sphinx-intl, not sphinx-build.

shimizukawa commented 7 years ago

Thanks for updating the information. I still can't understand why sphinx-intl fails when you can't specify htmlhelp_basename ? How was it displayed when failing?

clalarco commented 7 years ago

Yeah, this variable was created by me a long time ago :S

Here's some steps to reproduce the issue from a blank project:

  1. Create a blank project using sphinx-quickstart. Set required fields and leave all the rest as default.
  2. Edit conf.py where master_doc is set and locale directory (and a print to show tags):
# The master toctree document.
print("tags: " + str([t for t in tags]))
if tags.has('doc1'):
    master_doc = 'index_doc1'
elif tags.has('doc2'):
    master_doc = 'index_doc2'

# Add locale directory:
locale_dirs = ['locale/']
  1. make a copy of index.rst to index_doc1.rst and index_doc2.rst

  2. Create doc1 and doc2 (works fine):

$SPHINXOPTS="-tdoc1" make singlehtml`
tags: ['doc1']
...
$SPHINXOPTS="-tdoc2" make singlehtml`
tags: ['doc2']
...
  1. Create gettext for doc1 and doc2 (also works fine) index.pot, index_doc1.pot and index_doc2.pot are created at _build\gettext directory:
    $SPHINXOPTS="-tdoc1" make gettext`
    tags: ['doc1']
    ...
$SPHINXOPTS="-tdoc2" make gettext`
tags: ['doc2']
...
  1. Create po from pot files. It fails:
    $SPHINXOPTS="-tdoc1" sphinx-intl update -l es -p _build/gettext
    tags: []
    ...
    File "conf.py", line 151, in <module>
    (master_doc, 'doc.tex', u'doc Documentation',
    NameError: name 'master_doc' is not defined
clalarco commented 7 years ago

I did a pull request with a proposal.

shimizukawa commented 7 years ago

Thanks!