useblocks / sphinx-needs

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

Crash when cross referencing across multiple latex documents: WARNING: unknown node type: <NeedOutgoing: <inline...>> #1136

Closed partofthething closed 6 months ago

partofthething commented 7 months ago

Sphinx-needs is working great when I run the html builder, and has been fine with the latex builder. However, I just re-configured my latex_documents setting to break the latex build into multiple pdfs, along the lines of:

latex_documents = [
     (
        "requirements/index",
        "srsd.tex",
        "Software Requirement Specification Document",
        "Author",
        "manual",
        False,
    ),
    (
        "sdid/index",
        "sdid.tex",
        "Design and Implementation Document",
        "Author",
        "manual",
        False,
    ),
    (
        "tests/index",
        "str.tex",
        "Software Test Report",
        "Author",
        "manual",
        False,
    ),
]

After doing this and then running make latex, I'm receiving this error:

writing... C:\path\to\file.rst:134: WARNING: unknown node type: <NeedOutgoing: <inline...>>
failed

Exception occurred:
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 2041, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.latex.LaTeXTranslator'> departing unknown node type: NeedOutgoing

The full traceback is:

# Platform:         win32; (Windows-10-10.0.19045-SP0)
# Sphinx version:   7.2.7+tp0
# Python version:   3.9.11 (CPython)
# Docutils version: 0.20.1
# Jinja2 version:   3.1.2
# Pygments version: 2.16.1

# Last messages:
#   development/patterns/table
#   development/accessing_server
#   development/debugging
#   development/data_migrations
#   development/repo_sharing
#   
#   resolving references...
#   done
#   writing...
#   failed

# Loaded extensions:
#   sphinx.ext.mathjax (7.2.7+tp0)
#   alabaster (0.7.13)
#   sphinxcontrib.applehelp (1.0.7)
#   sphinxcontrib.devhelp (1.0.5)
#   sphinxcontrib.htmlhelp (2.0.4)
#   sphinxcontrib.serializinghtml (1.1.9)
#   sphinxcontrib.qthelp (1.0.6)
#   sphinx.ext.autodoc.preserve_defaults (7.2.7+tp0)
#   sphinx.ext.autodoc.type_comment (7.2.7+tp0)
#   sphinx.ext.autodoc.typehints (7.2.7+tp0)
#   sphinx.ext.autodoc (7.2.7+tp0)
#   sphinx.ext.napoleon (7.2.7+tp0)
#   sphinx.ext.autosummary (7.2.7+tp0)
#   sphinx.ext.todo (7.2.7+tp0)
#   sphinx.ext.graphviz (7.2.7+tp0)
#   sphinx.ext.ifconfig (7.2.7+tp0)
#   sphinx.ext.extlinks (7.2.7+tp0)
#   sphinxcontrib.apidoc (0.4.0)
#   sphinx.ext.intersphinx (7.2.7+tp0)
#   sphinx_data_viewer (0.1.2)
#   sphinxcontrib.jquery (4.1)
#   sphinx_needs (2.0.0)
#   sphinxcontrib.test_reports (1.0.2)
#   sphinxcontrib.plantuml (unknown version)
#   sphinxcontrib_django (unknown version)
#   myst_parser (2.0.0)

# Traceback:
Traceback (most recent call last):
  File "C:\venvs\venv39\lib\site-packages\sphinx\cmd\build.py", line 338, in build_main
    app.build(args.force_all, args.filenames)
  File "C:\venvs\venv39\lib\site-packages\sphinx\application.py", line 355, in build
    self.builder.build_update()
  File "C:\venvs\venv39\lib\site-packages\sphinx\builders\__init__.py", line 290, in build_update
    self.build(['__all__'], to_build)
  File "C:\venvs\venv39\lib\site-packages\sphinx\builders\__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "C:\venvs\venv39\lib\site-packages\sphinx\builders\latex\__init__.py", line 318, in write
    docwriter.write(doctree, destination)
  File "C:\venvs\venv39\lib\site-packages\docutils\writers\__init__.py", line 80, in write
    self.translate()
  File "C:\venvs\venv39\lib\site-packages\sphinx\writers\latex.py", line 88, in translate
    self.document.walkabout(visitor)
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 14 more times]
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 199, in walkabout
    visitor.dispatch_departure(self)
  File "C:\venvs\venv39\lib\site-packages\sphinx\util\docutils.py", line 602, in dispatch_departure
    super().dispatch_departure(node)
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 2019, in dispatch_departure
    return method(node)
  File "C:\venvs\venv39\lib\site-packages\docutils\nodes.py", line 2041, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.latex.LaTeXTranslator'> departing unknown node type: NeedOutgoing

Notably, even normal cross-references with :ref: end up rendering as plain text rather than an actual hyperlink in this build mode (and I made an issue for that on the sphinx repo), but at least they show the name of the link and allow the PDF to be built.

I'd ideally love to get working hyperlink references between these individual PDFs, but it would be awesome if the system rendered the requirements, implementations, and test directives to PDF, with the ID's of the links shown as plain text

danwos commented 6 months ago

Argh, latex my old nemesis ;) To be honest, I don't have much knowledge about latex and especially the Sphinx-Builder for it. So I can not help here.

All I can say is, that for a similar use case, we are using Sphinx-SimplePDF as PDF builder. And as this is based on the HTML builder, the Sphinx-Needs support is really good.

danwos commented 6 months ago

Duplicate of #1035