sphinx-intl errors if conf.py contains tag logic
aetter opened this issue · 5 comments
I use tags to separate "internal" and "external" content in my documentation. So .. only:: internal
and .. only:: external
.
Then I build with sphinx-build -b html -t external _build/external-html/
or -t internal
.
In conf.py
, I have several statements like this:
if tags.has('external'):
html_copy_source = False
This statement causes sphinx-intl
to fail on build:
$ make clean gettext
rm -rf _build/*
sphinx-build -b gettext -t external . _build/locale
Running Sphinx v1.4.9
...
Build finished. The message catalogs are in _build/locale.
$ sphinx-intl update -p _build/locale/ -l fr
Traceback (most recent call last):
File "/usr/local/bin/sphinx-intl", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 1057, in invoke
Command.invoke(self, ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Library/Python/2.7/site-packages/sphinx_intl/commands.py", line 154, in main
cfg = read_config(ctx.config)
File "/Library/Python/2.7/site-packages/sphinx_intl/commands.py", line 38, in read_config
execfile_(os.path.basename(path), namespace)
File "/Library/Python/2.7/site-packages/sphinx_intl/pycompat.py", line 84, in execfile_
exec_(code, _globals)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 508, in exec_
exec("""exec _code_ in _globs_, _locs_""")
File "<string>", line 1, in <module>
File "conf.py", line 51, in <module>
if tags.has('external'):
NameError: name 'tags' is not defined
I can scrub the if statements before running sphinx-intl
, but obviously that's not ideal. Thanks for any help or guidance here!
Thanks for your reporting! I think it's a bug of sphinx-intl. I'll fix it
fixed.
Running Sphinx version 1.6.2 - having the same problem NameError: name 'tags' is not defined
. The tags
actually get never defined inside conf.py
(not imported as well). The docs say it is supposed to just magically work.
Sphinx 1.6.2 is too old and not supported now. Please try with 2.0 again. It is the version only official supported. If it also errored, please file a new issue please.
Thanks,
How to define tags in conf.py
? For example, if I simply:
tags.add('footag')
even after importing them by: from sphinx.util.tags import Tags
, I get the error: "tags" is not defined