From 03b4892dbbf9d24d853b35f4cb1fd1b410d83943 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Fri, 6 Sep 2024 14:22:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`needflow`=20`graphviz`=20?= =?UTF-8?q?title=20for=20parts=20(#1280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The title for parts is actually taken from their `content` field, not `title` --- sphinx_needs/directives/needflow/_graphviz.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sphinx_needs/directives/needflow/_graphviz.py b/sphinx_needs/directives/needflow/_graphviz.py index 5868d283e..a058d677a 100644 --- a/sphinx_needs/directives/needflow/_graphviz.py +++ b/sphinx_needs/directives/needflow/_graphviz.py @@ -369,8 +369,11 @@ def _render_subgraph( def _label(need: NeedsInfoType, align: Literal["left", "right", "center"]) -> str: """Create the graphviz label for a need.""" + # note this is based on the plantuml template DEFAULT_DIAGRAM_TEMPLATE + br = f'
' # note this text wrapping mimics the jinja wordwrap filter + need_title = need["title"] if need["is_need"] else need["content"] title = br.join( br.join( textwrap.wrap( @@ -382,13 +385,13 @@ def _label(need: NeedsInfoType, align: Literal["left", "right", "center"]) -> st break_on_hyphens=True, ) ) - for line in need["title"].splitlines() + for line in need_title.splitlines() ) - name = html.escape(need["type_name"]) + name = html.escape(need["type_name"] + (" (part)" if need["is_part"] else "")) if need["is_need"]: _id = html.escape(need["id"]) else: - _id = f"{html.escape(need['id_parent'])}.{html.escape(need['id'])}" + _id = f'{html.escape(need["id_parent"])}.{html.escape(need["id"])}' font_10 = '' font_12 = '' return f"<{font_12}{name}{br}{title}{br}{font_10}{_id}{br}>"