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 diff --git a/sphinx_needs/roles/need_incoming.py b/sphinx_needs/roles/need_incoming.py index ece951aef..d7443b41c 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,17 @@ 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( diff --git a/sphinx_needs/roles/need_outgoing.py b/sphinx_needs/roles/need_outgoing.py index b777c9328..51a20698e 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,12 @@ 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. diff --git a/sphinx_needs/utils.py b/sphinx_needs/utils.py index cdf4d2fa0..516dd1cba 100644 --- a/sphinx_needs/utils.py +++ b/sphinx_needs/utils.py @@ -16,6 +16,7 @@ from sphinx_needs.config import LinkOptionsType, NeedsSphinxConfig from sphinx_needs.data import NeedsInfoType, SphinxNeedsData from sphinx_needs.defaults import NEEDS_PROFILING +from sphinx_needs.errors import NoUri from sphinx_needs.logging import get_logger try: @@ -195,7 +196,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)