You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that most Sphinx roles, when used in the description of an argparse subcommand, cause sphinx-argparse to crash. The ones listed under "Other semantic markup" on the Roles Sphinx documentation page seems to work correctly, though.
Here is a minimal Sphinx project to reproduce this problem:
importargparsedefget_parser():
parser=argparse.ArgumentParser()
subparsers=parser.add_subparsers()
subparsers.add_parser('subcmd', description=':file:`role` makes sphinx-argparse fail')
returnparser
Build command (full virtualenv paths omitted for brevity)
$ rm html -rf ; PYTHONPATH=. sphinx-build -v . html
Running Sphinx v1.7.2
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] contents
Traceback (most recent call last):
File "docutils/statemachine.py", line 307, in next_line
self.line = self.input_lines[self.line_offset]
File "docutils/statemachine.py", line 1152, in __getitem__
return self.data[i]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "docutils/statemachine.py", line 230, in run
self.next_line()
File "docutils/statemachine.py", line 310, in next_line
raise EOFError
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sphinx/cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "sphinx/application.py", line 331, in build
self.builder.build_update()
File "sphinx/builders/__init__.py", line 338, in build_update
'out of date' % len(to_build))
File "sphinx/builders/__init__.py", line 351, in build
updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
File "sphinx/environment/__init__.py", line 565, in update
self._read_serial(docnames, self.app)
File "sphinx/environment/__init__.py", line 584, in _read_serial
self.read_doc(docname, app)
File "sphinx/environment/__init__.py", line 659, in read_doc
doctree = read_doc(self.app, self, self.doc2path(docname))
File "sphinx/io.py", line 294, in read_doc
pub.publish()
File "docutils/core.py", line 217, in publish
self.settings)
File "docutils/readers/__init__.py", line 72, inreadself.parse()
File "docutils/readers/__init__.py", line 78, in parse
self.parser.parse(self.input, document)
File "sphinx/parsers.py", line 85, in parse
self.statemachine.run(inputstring, document, inliner=self.inliner)
File "docutils/parsers/rst/states.py", line 171, in run
input_source=document['source'])
File "docutils/statemachine.py", line 239, in run
context, state, transitions)
File "docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File "docutils/parsers/rst/states.py", line 2326, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "docutils/parsers/rst/states.py", line 2338, in explicit_construct
return method(self, expmatch)
File "docutils/parsers/rst/states.py", line 2081, in directive
directive_class, match, type_name, option_presets)
File "docutils/parsers/rst/states.py", line 2130, in run_directive
result = directive_instance.run()
File "sphinxarg/ext.py", line 486, in run
settings=self.state.document.settings))
File "sphinxarg/ext.py", line 192, in print_subcommands
forelementin renderList(desc, markDownHelp):
File "sphinxarg/ext.py", line 66, in renderList
Parser().parse('\n\n'.join(l) + '\n', document)
File "docutils/parsers/rst/__init__.py", line 191, in parse
self.statemachine.run(inputlines, document, inliner=self.inliner)
File "docutils/parsers/rst/states.py", line 171, in run
input_source=document['source'])
File "docutils/statemachine.py", line 245, in run
result = state.eof(context)
File "docutils/parsers/rst/states.py", line 2696, in eof
self.blank(None, context, None)
File "docutils/parsers/rst/states.py", line 2688, in blank
context, self.state_machine.abs_line_number() - 1)
File "docutils/parsers/rst/states.py", line 418, in paragraph
textnodes, messages = self.inline_text(text, lineno)
File "docutils/parsers/rst/states.py", line 427, in inline_text
return self.inliner.parse(text, lineno, self.memo, self.parent)
File "docutils/parsers/rst/states.py", line 645, in parse
lineno)
File "docutils/parsers/rst/states.py", line 787, in interpreted_or_phrase_ref
lineno)
File "docutils/parsers/rst/states.py", line 871, in interpreted
nodes, messages2 = role_fn(role, rawsource, text, lineno, self)
File "sphinx/roles.py", line 292, in emph_literal_role
env = inliner.document.settings.env
AttributeError: 'Values' object has no attribute 'env'
Exception occurred:
File "sphinx/roles.py", line 292, in emph_literal_role
env = inliner.document.settings.env
AttributeError: 'Values' object has no attribute 'env'
The full traceback has been saved in /tmp/sphinx-err-kdcf92c8.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
The text was updated successfully, but these errors were encountered:
klorenz
added a commit
to klorenz/sphinx-argparse
that referenced
this issue
Jan 15, 2021
It seems that most Sphinx roles, when used in the description of an
argparse
subcommand, cause sphinx-argparse to crash. The ones listed under "Other semantic markup" on the Roles Sphinx documentation page seems to work correctly, though.Here is a minimal Sphinx project to reproduce this problem:
conf.py
contents.rst
sphinxtest.py
Build command (full virtualenv paths omitted for brevity)
The text was updated successfully, but these errors were encountered: