Skip to content

Commit 0f7f932

Browse files
authored
Merge pull request #2510 from strictdoc-project/stanislaw/included_documents_html2pdf
feat(html2pdf): enable correct resolution of LINKs when included document is printed to bundle document
2 parents ce035c6 + de02428 commit 0f7f932

File tree

22 files changed

+80
-8
lines changed

22 files changed

+80
-8
lines changed

docs/strictdoc_20_L1_Open_Requirements_Tool.sdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,18 @@ This section captures the requirements related to "Requirements exchange" as out
11211121
The Requirements Tool should fundamentally support the exchange of documentation and requirements with other tools. Importing data into this tool and exporting data from it to other tools should be straightforward. The key focus of this section's requirements is on enabling seamless access to requirements and documentation data.
11221122
<<<
11231123

1124+
[REQUIREMENT]
1125+
MID: 086eb992322d4c43ad91a40f6c9f9952
1126+
UID: SDOC-SSS-96
1127+
STATUS: Active
1128+
TITLE: PDF export
1129+
STATEMENT: >>>
1130+
The Requirements Tool shall support exporting documentation content to PDF, both individual documents and complete documentation trees.
1131+
<<<
1132+
RATIONALE: >>>
1133+
PDF is one of the most common formats for reviewing documentation.
1134+
<<<
1135+
11241136
[REQUIREMENT]
11251137
MID: 73e70548c2cf415f94adbf1066d5fe4b
11261138
UID: SDOC-SSS-58

docs/strictdoc_21_L2_StrictDoc_Requirements.sdoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,13 +741,18 @@ RELATIONS:
741741
MID: f2fd90ad8a2946e7b085233a9c7a8a75
742742
UID: SDOC-SRS-51
743743
STATUS: Active
744-
TITLE: Export to printable HTML pages (HTML2PDF)
744+
TITLE: Export to HTML content to PDF (HTML2PDF)
745745
STATEMENT: >>>
746-
StrictDoc shall provide export to printable HTML pages.
746+
StrictDoc shall allow exporting documents and entire documentation trees to PDF.
747+
<<<
748+
RATIONALE: >>>
749+
As required by the parent requirement, PDF is one of the most common documentation formats.
747750
<<<
748751
RELATIONS:
749752
- TYPE: Parent
750753
VALUE: DO178-5
754+
- TYPE: Parent
755+
VALUE: SDOC-SSS-96
751756

752757
[REQUIREMENT]
753758
MID: 8811f0ef33de4365bc66a602a8c184f6

docs_extra/DO178_requirements.sdoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ TITLE: PDF and HTML publishing
173173
STATEMENT: >>>
174174
StrictDoc shall support publication of documents to HTML and PDF formats.
175175
<<<
176-
COMMENT: >>>
177-
N: Sphinx is nice for release.
178-
<<<
179176

180177
[REQUIREMENT]
181178
MID: 8b73ce9efcc840b2be272d5aaef08e70

strictdoc/core/actions/export_action.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def export(self) -> None:
105105
specific_documents=(DocumentType.DOCUMENT,),
106106
)
107107

108+
# @relation(SDOC-SRS-51, scope=range_start)
108109
if "html2pdf" in self.project_config.export_formats:
109110
output_html2pdf_root = os.path.join(
110111
self.project_config.output_dir, "html2pdf"
@@ -128,6 +129,7 @@ def export(self) -> None:
128129
output_html2pdf_root,
129130
flat_assets=True,
130131
)
132+
# @relation(SDOC-SRS-51, scope=range_end)
131133

132134
if "rst" in self.project_config.export_formats:
133135
output_rst_root = os.path.join(

strictdoc/core/traceability_index.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,8 @@ def clone_to_bundle_document(
989989
- The bundle is generated to the root of the output folder (level=0).
990990
- Some variables do not contribute (yet) to the final result, so they
991991
are marked as NOT_RELEVANT.
992+
993+
@relation(SDOC-SRS-51, scope=function)
992994
"""
993995
traceability_index_copy = deepcopy(self)
994996
bundle_document = SDocDocument(

strictdoc/export/html/renderers/link_renderer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def render_node_link(
114114
assert isinstance(node, (SDocNode, Anchor)), node
115115
assert isinstance(document_type, DocumentType), type(document_type)
116116
local_link = self.render_local_anchor(node)
117+
118+
# If the context document is a bundle, all contained documents are
119+
# merged into this bundle document. In this case, all links are local,
120+
# so there is no need to resolve links to external documents.
121+
if context_document is not None and context_document.is_bundle_document:
122+
return f"#{local_link}"
123+
117124
including_document = node.get_including_document()
118125
if (
119126
including_document is not None

tests/integration/features/html2pdf/01_empty_document/test.itest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# @relation(SDOC-SRS-51, scope=file)
2+
13
REQUIRES: TEST_HTML2PDF
24

35
RUN: %strictdoc export %S --formats=html2pdf --output-dir %T | filecheck %s --dump-input=fail

tests/integration/features/html2pdf/01_empty_document/test_pdf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
@relation(SDOC-SRS-51, scope=file)
3+
"""
4+
15
from pypdf import PdfReader
26

37
reader = PdfReader("Output/html2pdf/pdf/input.pdf")

tests/integration/features/html2pdf/02_three_top_level_requirements/test.itest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# @relation(SDOC-SRS-51, scope=file)
2+
13
REQUIRES: TEST_HTML2PDF
24

35
RUN: %strictdoc export %S --formats=html2pdf --output-dir %T | filecheck %s --dump-input=fail

tests/integration/features/html2pdf/02_three_top_level_requirements/test_pdf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
@relation(SDOC-SRS-51, scope=file)
3+
"""
4+
15
from pypdf import PdfReader
26

37
reader = PdfReader("Output/html2pdf/pdf/input.pdf")

0 commit comments

Comments
 (0)