Issue with sphinxneeds directives during latexpdf build
latexpdf build leads to an exception if I use .. needextract:: is used. The same happens also if .. needtable:: is used
The html build works fine .....
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sphinx/events.py", line 94, in emit
results.append(listener.handler(self.app, *args))
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/directives/need.py", line 394, in process_need_nodes
print_need_nodes(app, doctree, fromdocname, found_needs_nodes)
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/directives/need.py", line 423, in print_need_nodes
build_need(layout, node_need, app, fromdocname=fromdocname)
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 157, in build_need
new_need_node = lh.get_need_table()
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 317, in get_need_table
func["func"](**func["configs"])
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 1081, in _grid_simple
head_entry += self.get_section("head")
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 339, in get_section
line_ready = self._func_replace(line_parsed)
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 438, in _func_replace
result = func(*func_args, **func_kargs)
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 563, in meta_id
id_ref = make_refnode(
File "/usr/local/lib/python3.10/site-packages/sphinx/util/nodes.py", line 561, in make_refnode
node['refuri'] = (builder.get_relative_uri(fromdocname, todocname) +
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 138, in get_relative_uri
return self.get_target_uri(to, typ)
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 132, in get_target_uri
raise NoUri(docname, typ)
sphinx.errors.NoUri: ('xxxxxx', None)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sphinx/cmd/build.py", line 281, in build_main
app.build(args.force_all, args.filenames)
File "/usr/local/lib/python3.10/site-packages/sphinx/application.py", line 347, in build
self.builder.build_update()
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 307, in build_update
self.build(['__all__'], to_build)
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 376, in build
self.write(docnames, list(updated_docnames), method)
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 285, in write
doctree = self.assemble_doctree(
File "/usr/local/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 349, in assemble_doctree
self.env.resolve_references(largetree, indexfile, self)
File "/usr/local/lib/python3.10/site-packages/sphinx_monkeypatch/__init__.py", line 173, in _resolve_references
self.apply_post_transforms(doctree, fromdocname)
File "/usr/local/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 642, in apply_post_transforms
self.events.emit('doctree-resolved', doctree, docname)
File "/usr/local/lib/python3.10/site-packages/sphinx/events.py", line 94, in emit
results.append(listener.handler(self.app, *args))
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/needs.py", line 417, in process_caller
check_func(app, doctree, fromdocname, current_nodes[check_node])
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/directives/needextract.py", line 126, in process_needextract
need_extract = create_need(
File "/usr/local/lib/python3.10/site-packages/sphinx_needs/layout.py", line 80, in create_need
env.resolve_references(node_container, docname, env.app.builder)
File "/usr/local/lib/python3.10/site-packages/sphinx_monkeypatch/__init__.py", line 173, in _resolve_references
self.apply_post_transforms(doctree, fromdocname)
File "/usr/local/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 642, in apply_post_transforms
self.events.emit('doctree-resolved', doctree, docname)
File "/usr/local/lib/python3.10/site-packages/sphinx/events.py", line 105, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function process_need_nodes at 0x7f09ceace5f0> for event 'doctree-resolved' threw an exception (exception: ('xxxxxxx', None))
Extension error (sphinx_needs.directives.need):
Handler <function process_need_nodes at 0x7f09ceace5f0> for event 'doctree-resolved' threw an exception (exception: ('xxxxxxx', None))
make: *** [Makefile:31: latexpdf] Error 1
* The terminal process "/bin/sh '-c', 'make latexpdf'" terminated with exit code: 2.
* Terminal will be reused by tasks, press any key to close it.
The .. needtable:: directive works in my case (windows) for various builders (latex, latexpdf, html and confluence). Is it working fine when you build for latex?
@daniel3097 Just an information to the project setup. I have many different files and needs (used for the html build) but, there is only one file out of all files which is additionally build as PDF (via latexpdf). So, what I figured out after your comment is the following:
1.) There is no issue with e.g.: needtable and needextractc for latex as well as latexpdf build, if I have everting in the file which is build via latexpdf. No use of needs defined in other files.
2.) The exception occurs only, if I move the .. tcd:: TCD 1 .... and .. tcd:: TCD 2.... to another file.
Working example located in one rst file:
.. tcd:: TCD 1
:id: TCD_001
:tags: requirement
This is an example ....
.. tcd:: TCD 2
:id: TCD_002
:tags: requirement
This is another example ...
.. needtable::
:types: tcd
:style: table
:columns: id, title, status
.. needextract::
:filter: id in ['TCD_001', 'TCD_002']
@DirkBodenschatz :
I tried your example and i also faced issues (but it looked different that yours). Made clean improved a bit - but still errors.
hi What helped in my case was when i removed :sytle: table in ...needtable::
.. needtable:: :types: req :columns: id, title, status
.. needextract:: :filter: id in ['R_MIIO-01', 'R_MIIO-02']
i hope this helps in your case as well.
the pdflatex path looked attractive to me as well to generate a pdf. but its "tough" - so i started exploring the ebook path (wasn't much better) and the confluence path (works well).
On linux https://github.com/useblocks/sphinx-simplepdf might be worth to try (i have no experience, but it looks impressive)