The user builds Sphinx documentation with Sphinx-Needs and SVG diagrams.
The needs_build_json configuration is enabled in conf.py.
The extension loads the needs.json file generated by Sphinx-Needs.
For each SVG, the extension parses its content to find xlink:href attributes.
If an xlink:href attribute contains a Sphinx-Needs reference pattern (e.g., :need:`MY_NEED_ID), the extension attempts to resolve it using the loaded needs.json data.
The resolved URI (e.g., ../needs_doc.html#MY_NEED_ID) replaces the reference pattern.
The modified SVG file is saved, making the link clickable in the generated HTML.
Alternative Flows:
No `needs.json` found: The extension proceeds without resolving Sphinx-Needs references, logging a message if needs_build_json is enabled.
Preconditions:
Sphinx documentation build is initiated.
SVG diagrams are present in the build output’s image directory.
Sphinx-Needs extension is active and needs_build_json is set to True.
A needs.json file is generated and accessible.
Postconditions:
SVG diagrams have clickable links to Sphinx-Needs where references were present.
The user sets sphinx_diagram_connect_verbose = True in their conf.py.
During the Sphinx build, for every successfully resolved xlink:href in an SVG, the extension logs an informative message indicating the original and resolved URI.
Preconditions:
The sphinx_diagram_connect extension is enabled in conf.py.
Postconditions:
Detailed logging messages about reference resolution are displayed during the build.