You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For every element used in needuml/needarch we want to add a link to the need itself to every image it's used in. A generated "used_in_image" option. The current approach is to inject a custom uml-function (like e.g. ref), which will modify the need element when used.
However modifications to the need do not take effect, as they simply happen too late in the workflow.
There is no reason, why format_need_nodes needs to called by process_need_nodes. It could be called later after process_creator. Looks like it was there to avoid redundant findall calls, but it's not redundant (anymore).
However, it's not that trivial as format_need_nodes evaluates the "hide" option. Not doing so before needpie etc could change the diagrams.
Not addressed here in this issue:
How do get the current document within the uml-function
How to add anchor tags to uml-images
Code just for reference:
current_app: sphinx.application.Sphinx|None=Nonedefget_needs() ->dict[str, dict[str, Any]]:
assertcurrent_appassertcurrent_app.env# old way of accessing needs:assertcurrent_app.env.needs_all_needsassertisinstance(current_app.env.needs_all_needs, dict)
returncurrent_app.env.needs_all_needsdefuml_element(need: dict|str):
ifisinstance(need, str):
needs=get_needs()
need=needs[need]
# FIXME: can we access current document through app? and potentially current need?current_document=need["docname"]
# Modifying needs has no effect at this point in time !!needs[need_id]["used_in_image"] +=current_document+".html;"link=sphinx_needs.diagrams_common.calculate_link(
current_app, need, current_document
)
title=need["title"]
need_id=need["id"]
returnf'"[[{link}{title}]]" as {need_id}'defsetup(app: sphinx.application.Sphinx):
globalcurrent_app# noqa: PLW0603current_app=app
The text was updated successfully, but these errors were encountered:
Abstract
For every element used in needuml/needarch we want to add a link to the need itself to every image it's used in. A generated "used_in_image" option. The current approach is to inject a custom uml-function (like e.g. ref), which will modify the need element when used.
However modifications to the need do not take effect, as they simply happen too late in the workflow.
Approach in Detail:
Approach: How-to use needs-render-context with a function without getting an unpickable warning #1206
participant {{element('demo1_A')}}
(I have a workaround for getting all needs into the function via storing the app into a global variable; see also Configuration to extend JinjaFunctions in needuml like in needs-render-context #1207)
need["used_in_image"] = current_document
(full code below)Problem in Detail:
process_creator
process_need_nodes
, specificallyformat_need_nodes
See
sphinx-needs/sphinx_needs/needs.py
Lines 291 to 292 in f3745ff
Possible solution:
format_need_nodes
needs to called byprocess_need_nodes
. It could be called later afterprocess_creator
. Looks like it was there to avoid redundantfindall
calls, but it's not redundant (anymore).format_need_nodes
evaluates the "hide" option. Not doing so before needpie etc could change the diagrams.Not addressed here in this issue:
Code just for reference:
The text was updated successfully, but these errors were encountered: