-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Describe the bug
bug
Sphinx -- or more precisely sphinx_design -- crashes when a .. tab-set:: directive contains something other than .. tab-item::.
The following example document illustrates this:
(conf.py is generated from sphinx-quickstart and sphinx_design is added to extensions).
Tab Test document
=================
.. tab-set::
.. tab-item:: A
A content
foo <------------------ This line is the culprit
.. tab-item:: B
B content
Results in:
Traceback (most recent call last):
File ".../site-packages/sphinx/cmd/build.py", line 432, in build_main
app.build(args.force_all, args.filenames)
File ".../site-packages/sphinx/application.py", line 426, in build
self.builder.build_update()
File ".../site-packages/sphinx/builders/__init__.py", line 375, in build_update
self.build(
File ".../site-packages/sphinx/builders/__init__.py", line 454, in build
self.write(docnames, updated_docnames, method)
File ".../site-packages/sphinx/builders/__init__.py", line 735, in write
self.write_documents(docnames)
File ".../site-packages/sphinx/builders/__init__.py", line 749, in write_documents
self._write_serial(sorted_docnames)
File ".../site-packages/sphinx/builders/__init__.py", line 765, in _write_serial
doctree = self.env.get_and_resolve_doctree(docname, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../site-packages/sphinx/environment/__init__.py", line 701, in get_and_resolve_doctree
self.apply_post_transforms(doctree, docname)
File ".../site-packages/sphinx/environment/__init__.py", line 773, in apply_post_transforms
transformer.apply_transforms()
File ".../site-packages/sphinx/transforms/__init__.py", line 92, in apply_transforms
super().apply_transforms() # type: ignore[misc]
^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../site-packages/docutils/transforms/__init__.py", line 182, in apply_transforms
transform.apply(**kwargs)
File ".../site-packages/sphinx/transforms/post_transforms/__init__.py", line 46, in apply
self.run(**kwargs)
File ".../site-packages/sphinx_design/tabs.py", line 244, in run
tab_label, tab_content = tab_item.children
^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
The version used was sphinx-design 0.6.1.
expectation
I expect sphinx-design not to crash but produce a warning/error message similar to an unknown directive/unkown option/malformed list-table, .... and ignoring the .. tab-set:: directive and its contents.
sphinx-design could even fail more gracefully by reporting the error but parse .. tab-set:: as best as possible, i.e. collect all .. tab-item:: directive and ignore the rest. In this scenario the build output should then contain the tabs which sphinx-design was able to identify.
P.S: Please provide an accurate error location when reporting the reStructuredText error, e.g. line 10 in the example document above.
Reproduce the bug
See example above
List your environment
No response