useblocks / sphinx-needs

Adds needs/requirements to sphinx
https://sphinx-needs.readthedocs.io/en/latest/index.html
MIT License
211 stars 66 forks source link

needextract fails - latex builder with multiple latex output #347

Open gregegg opened 3 years ago

gregegg commented 3 years ago

Hi there -- thank you for publishing this amazing plugin. I am running into trouble with the latex builder. The following information is redacted from the actual source documents -- I can share more information privately if needed.

I am using sphinx=4.0.2 and sphinxcontrib-needs=0.7.1 In my conf.py, I have

latex_documents = [
   ('srd', 'SRD.tex', 'Software Requirements Document',
    'author', 'manual'),
   ('um', 'UM.tex', 'User\'s Manual',
    'author', 'manual'),
]

I define a need in srd.rst, and then have .. needextract in both srd.rst and um.rst.

The html builder successfully builds the srd.html and um.html. The latex builder successfully builds srd.tex but then fails on um.tex, and yields the following error message:

processing SRD.tex... srd
resolving references...
done
writing... done
processing UM.tex... um
resolving references...
failed

Extension error (sphinxcontrib.needs.directives.needextract):
Handler <function process_needextract at 0x7fb162671f80> for event 'doctree-resolved' threw an exception (exception: ('srd', None))

I suspect that the handling of external needs is contributing to this somehow. I have tried to step through and debug it myself, but I am lost in the listeners. I hope it is enough to explain the behavior and give a clue on how to fix it?

danwos commented 3 years ago

Thanks for reporting this bug. I'm not 100% sure, how I can reproduce this error. Would it be possible for you to setup a small example and upload it to a git repo? This would help a lot and I can be sure I got your points.

But overall, I'm not an expert in latex and co. And right now, Sphinx-Needs has no builder specific handling, as all Need-Nodes gets transformed to standard docutils-nodes, so that the later docutils-node-tree does contain standard rst-nodes only. After that the specific builder starts to translate it to the specific output. So up to now, everything which has worked for html has never thrown an exception during latex or other builds.

So this bug looks quite strange and I hope I can reproduce and fix it.

gregegg commented 3 years ago

I will work to get you this example. Thank you!

gregegg commented 3 years ago

Please see example repo here: https://github.com/gregegg/needextract_347

Thank you!