From 913e07573a8d2852ab5e3f0a678dd50d246b7eaf Mon Sep 17 00:00:00 2001 From: Tobias Deiminger Date: Mon, 1 Jul 2024 16:38:10 +0200 Subject: [PATCH] LINKs: Fix link to anchor in other sdoc This kind of linking worked for [FREETEXT] (was covered by tests), but not for [TEXT] (was not covered by tests) nodes. Root cause was that Anchor.parent is an SDocNodeField which has no parent_or_including_document. That property is defined on the SDocNodeField.parent SDocNode. So we need Anchor.parent.parent. Fixes #1905. --- strictdoc/backend/sdoc/models/anchor.py | 4 ++-- .../input.sdoc | 9 +++++++++ .../input2.sdoc | 17 +++++++++++++++++ .../test.itest | 9 +++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/strictdoc/backend/sdoc/models/anchor.py b/strictdoc/backend/sdoc/models/anchor.py index 622611e3f..2c1dd9f86 100644 --- a/strictdoc/backend/sdoc/models/anchor.py +++ b/strictdoc/backend/sdoc/models/anchor.py @@ -30,11 +30,11 @@ def get_display_title(self) -> str: def document(self): if self.parent.parent.__class__.__name__ == "SDocDocument": return self.parent.parent - return self.parent.parent.document + return self.parent_node().document @property def parent_or_including_document(self): - return self.parent.parent_or_including_document + return self.parent_node().parent_or_including_document def parent_node(self) -> Any: # Anchor -> FreeText -> Section|Document diff --git a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input.sdoc b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input.sdoc index c226da534..7f416748c 100644 --- a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input.sdoc +++ b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input.sdoc @@ -12,4 +12,13 @@ See the [LINK: AD2] for more details. See the [LINK: Interface_Control_Document] for more details. [/FREETEXT] +[TEXT] +STATEMENT: >>> +See the [LINK: AD4] for more details. + +See the [LINK: AD5] for more details. + +See the [LINK: Supplemental Guide] for more details. +<<< + [/SECTION] diff --git a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input2.sdoc b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input2.sdoc index a8fcd3b17..d04064127 100644 --- a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input2.sdoc +++ b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/input2.sdoc @@ -23,4 +23,21 @@ Anchors end. [/FREETEXT] +[TEXT] +STATEMENT: >>> +[ANCHOR: AD4] + +1) AD4. Threat Model. + +[ANCHOR: AD5, Software Tests] + +2) AD5. Software Tests. + +[ANCHOR: Supplemental Guide] + +3) AD6. Supplemental Guide. + +Anchors end. +<<< + [/SECTION] diff --git a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/test.itest b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/test.itest index 6546a7925..e8438d959 100644 --- a/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/test.itest +++ b/tests/integration/commands/export/html/markup/03_referencing_anchor_with_LINK_external/test.itest @@ -5,6 +5,9 @@ RUN: %cat %S/Output/html/03_referencing_anchor_with_LINK_external/input.html | f CHECK-HTML-DOC:

See the {{.*}}AD1 for more details.

CHECK-HTML-DOC:

See the {{.*}}Software requirements specification for more details.

CHECK-HTML-DOC:

See the {{.*}}Interface_Control_Document for more details.

+CHECK-HTML-DOC:

See the {{.*}}AD4 for more details.

+CHECK-HTML-DOC:

See the {{.*}}Software Tests for more details.

+CHECK-HTML-DOC:

See the {{.*}}Supplemental Guide for more details.

RUN: %cat %S/Output/html/03_referencing_anchor_with_LINK_external/input2.html | filecheck %s --dump-input=fail --check-prefix CHECK-HTML-DOC2 CHECK-HTML-DOC2:AD2. Software requirements specification. CHECK-HTML-DOC2:AD3. Interface Control Document. +CHECK-HTML-DOC2:AD4. Threat Model. +CHECK-HTML-DOC2:AD5. Software Tests. +CHECK-HTML-DOC2:AD6. Supplemental Guide.