From 3cd3bb170d5320e4e28dedfcb027db93e43e59ed Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:01:07 +0200 Subject: [PATCH 1/7] Catch NoUri in col_row_maker --- sphinx_needs/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx_needs/utils.py b/sphinx_needs/utils.py index 3ce307977..adbffdec2 100644 --- a/sphinx_needs/utils.py +++ b/sphinx_needs/utils.py @@ -12,6 +12,7 @@ from docutils import nodes from jinja2 import Environment, Template from sphinx.application import BuildEnvironment, Sphinx +from sphinx.errors import NoUri from sphinx_needs.config import LinkOptionsType, NeedsSphinxConfig from sphinx_needs.data import NeedsInfoType, SphinxNeedsData @@ -239,7 +240,7 @@ def row_col_maker( if link_part: ref_col["refuri"] += "." + link_part - except KeyError: + except (KeyError, NoUri): para_col += text_col else: ref_col.append(text_col) From bdd48e818a1686f4b16cd5d06625230375126830 Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:04:34 +0200 Subject: [PATCH 2/7] Update utils.py --- sphinx_needs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_needs/utils.py b/sphinx_needs/utils.py index adbffdec2..d0e89a572 100644 --- a/sphinx_needs/utils.py +++ b/sphinx_needs/utils.py @@ -12,12 +12,12 @@ from docutils import nodes from jinja2 import Environment, Template from sphinx.application import BuildEnvironment, Sphinx -from sphinx.errors import NoUri from sphinx_needs.config import LinkOptionsType, NeedsSphinxConfig from sphinx_needs.data import NeedsInfoType, SphinxNeedsData from sphinx_needs.defaults import NEEDS_PROFILING from sphinx_needs.logging import get_logger +from sphinx_needs.errors import NoUri try: from typing import TypedDict From 25579c36a370eed89d28583a989ae778eed117e0 Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:04:49 +0200 Subject: [PATCH 3/7] Update utils.py --- sphinx_needs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_needs/utils.py b/sphinx_needs/utils.py index d0e89a572..3e5dd9ad8 100644 --- a/sphinx_needs/utils.py +++ b/sphinx_needs/utils.py @@ -16,8 +16,8 @@ from sphinx_needs.config import LinkOptionsType, NeedsSphinxConfig from sphinx_needs.data import NeedsInfoType, SphinxNeedsData from sphinx_needs.defaults import NEEDS_PROFILING -from sphinx_needs.logging import get_logger from sphinx_needs.errors import NoUri +from sphinx_needs.logging import get_logger try: from typing import TypedDict From 64ee6eed4d7c33c13e3f288d1deaa4f158c70a21 Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:09:19 +0200 Subject: [PATCH 4/7] Update need_outgoing.py --- sphinx_needs/roles/need_outgoing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sphinx_needs/roles/need_outgoing.py b/sphinx_needs/roles/need_outgoing.py index b777c9328..de7f5de99 100644 --- a/sphinx_needs/roles/need_outgoing.py +++ b/sphinx_needs/roles/need_outgoing.py @@ -54,8 +54,8 @@ def process_need_outgoing( and need_id_main in needs_all_needs and need_id_part in needs_all_needs[need_id_main]["parts"] ): + target_need = needs_all_needs[need_id_main] try: - target_need = needs_all_needs[need_id_main] if need_id_part and need_id_part in target_need["parts"]: part_content = target_need["parts"][need_id_part]["content"] target_title = ( @@ -107,8 +107,10 @@ def process_need_outgoing( node_link_container += new_node_ref except NoUri: - # If the given need id can not be found, we must pass here.... - pass + # If the given need id can not be found, + # we make an emphasis to still show the need id + # This allows to show traceability in cross documents cases. + node_link_container += nodes.emphasis(target_need["id"],target_need["id"]) else: # Let's add a normal text here instead of a link. From 93c905d32161d83f3d79794e9a0fcc922ca800c4 Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:11:44 +0200 Subject: [PATCH 5/7] Update need_incoming.py --- sphinx_needs/roles/need_incoming.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sphinx_needs/roles/need_incoming.py b/sphinx_needs/roles/need_incoming.py index ece951aef..ee21ae1cd 100644 --- a/sphinx_needs/roles/need_incoming.py +++ b/sphinx_needs/roles/need_incoming.py @@ -40,8 +40,8 @@ def process_need_incoming( for index, back_link in enumerate(links_back): # If need back_link target exists, let's create the reference if back_link in all_needs: + target_need = all_needs[back_link] try: - target_need = all_needs[back_link] if needs_config.show_link_title: link_text = f'{target_need["title"]}' @@ -82,13 +82,15 @@ def process_need_incoming( node_link_container += new_node_ref - # If we have several links, we add an empty text between them - if index + 1 < len(links_back): - node_link_container += nodes.Text(", ") - except NoUri: - # If the given need id can not be found, we must pass here.... - pass + # If the given need id can not be found, + # we make an emphasis to still show the need id + # This allows to show traceability in cross documents cases. + node_link_container += nodes.emphasis(target_need["id"],target_need["id"]) + + # If we have several links, we add an empty text between them + if index + 1 < len(links_back): + node_link_container += nodes.Text(", ") else: logger.warning( From ebf9d064b6eb4fbf77004f194dd7358696b5effd Mon Sep 17 00:00:00 2001 From: Pierre Fournier Date: Tue, 23 Jul 2024 11:14:06 +0200 Subject: [PATCH 6/7] Update AUTHORS --- AUTHORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS b/AUTHORS index b37fbbb7c..f43d13e9d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -39,3 +39,5 @@ Christian Wappler Chris Sewell Simon Leiner + +Pierre Fournier From 242acfa18b0d9a89cfd606d4637e381e8caa23d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:30:53 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sphinx_needs/roles/need_incoming.py | 4 +++- sphinx_needs/roles/need_outgoing.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sphinx_needs/roles/need_incoming.py b/sphinx_needs/roles/need_incoming.py index ee21ae1cd..d7443b41c 100644 --- a/sphinx_needs/roles/need_incoming.py +++ b/sphinx_needs/roles/need_incoming.py @@ -86,7 +86,9 @@ def process_need_incoming( # If the given need id can not be found, # we make an emphasis to still show the need id # This allows to show traceability in cross documents cases. - node_link_container += nodes.emphasis(target_need["id"],target_need["id"]) + node_link_container += nodes.emphasis( + target_need["id"], target_need["id"] + ) # If we have several links, we add an empty text between them if index + 1 < len(links_back): diff --git a/sphinx_needs/roles/need_outgoing.py b/sphinx_needs/roles/need_outgoing.py index de7f5de99..51a20698e 100644 --- a/sphinx_needs/roles/need_outgoing.py +++ b/sphinx_needs/roles/need_outgoing.py @@ -110,7 +110,9 @@ def process_need_outgoing( # If the given need id can not be found, # we make an emphasis to still show the need id # This allows to show traceability in cross documents cases. - node_link_container += nodes.emphasis(target_need["id"],target_need["id"]) + node_link_container += nodes.emphasis( + target_need["id"], target_need["id"] + ) else: # Let's add a normal text here instead of a link.