-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1929 from haxtibal/tdmg/fix_sdoc_fileref
Fix html escaping of source line marks
- Loading branch information
Showing
10 changed files
with
220 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/integration/commands/export/html/escaping/01_escape_input_from_sdoc/input.sdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[DOCUMENT] | ||
TITLE: <b>"escaping" 'document title'</b> | ||
|
||
[SECTION] | ||
TITLE: <b>"escaping" 'section title'</b> | ||
|
||
[TEXT] | ||
STATEMENT: >>> | ||
<b>"escaping" 'text statement'</b> | ||
<<< | ||
|
||
[REQUIREMENT] | ||
UID: REQ-1 | ||
STATEMENT: >>> | ||
<b>"escaping" 'requirement statement'</b> | ||
<<< | ||
|
||
[/SECTION] |
8 changes: 8 additions & 0 deletions
8
tests/integration/commands/export/html/escaping/01_escape_input_from_sdoc/strictdoc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
|
||
features = [ | ||
"DEEP_TRACEABILITY_SCREEN", | ||
"STANDALONE_DOCUMENT_SCREEN", | ||
"TABLE_SCREEN", | ||
"TRACEABILITY_SCREEN", | ||
] |
51 changes: 51 additions & 0 deletions
51
tests/integration/commands/export/html/escaping/01_escape_input_from_sdoc/test.itest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RUN: %strictdoc export %S --output-dir Output/ | filecheck %s --dump-input=fail --check-prefix CHECK-EXPORT | ||
CHECK-EXPORT: Published: <b>"escaping" 'document title'</b> | ||
|
||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input.html | filecheck %s --dump-input=fail --check-prefix CHECK-ALL | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input.html | filecheck %s --dump-input=fail --check-prefix CHECK-INPUT | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-DEEP-TRACE.html | filecheck %s --dump-input=fail --check-prefix CHECK-ALL | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-DEEP-TRACE.html | filecheck %s --dump-input=fail --check-prefix CHECK-DTR | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-TABLE.html | filecheck %s --dump-input=fail --check-prefix CHECK-ALL | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-TABLE.html | filecheck %s --dump-input=fail --check-prefix CHECK-TABLE | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-TRACE.html | filecheck %s --dump-input=fail --check-prefix CHECK-ALL | ||
RUN: %cat %S/Output/html/%THIS_TEST_FOLDER/input-TRACE.html | filecheck %s --dump-input=fail --check-prefix CHECK-TRACE | ||
|
||
# Browser title bar: Document title. | ||
CHECK-ALL: <title><b>"escaping"&nbsp;'document title'</b> - {{Document|Deep Traceability|Table|Traceability}}</title> | ||
|
||
# Left-hand bar: project tree document entry. | ||
CHECK-ALL: class="document_title" | ||
CHECK-ALL-NEXT: title="<b>"escaping"&nbsp;'document title'</b>" | ||
CHECK-ALL-NEXT: data-file_name="input.sdoc" | ||
CHECK-ALL-NEXT: ><b>"escaping"&nbsp;'document title'</b></div> | ||
|
||
# Right-hand bar: Document TOC. | ||
CHECK-ALL: <span class="section-number"> | ||
CHECK-ALL-NEXT: {{[0-9]+}} | ||
CHECK-ALL-NEXT: </span><b>"escaping"&nbsp;'section title'</b> | ||
|
||
# Header: Document path in tree. | ||
CHECK-ALL: class="header__document_title" | ||
CHECK-ALL-NEXT: title="<b>"escaping"&nbsp;'document title'</b>" | ||
CHECK-ALL-NEXT: > | ||
CHECK-ALL-NEXT: <b>"escaping"&nbsp;'document title'</b> | ||
|
||
# Main document: Title. | ||
CHECK-INPUT: <h1 data-testid="document-title"><b>"escaping"&nbsp;'document title'</b></h1> | ||
CHECK-TABLE: <h1 data-testid="document-title"><b>"escaping"&nbsp;'document title'</b></h1> | ||
|
||
# Main document: Section. | ||
CHECK-INPUT: <sdoc-autogen>1. <b>"escaping"&nbsp;'section title'</b></sdoc-autogen> | ||
CHECK-DTR: <sdoc-autogen>1. <b>"escaping"&nbsp;'section title'</b></sdoc-autogen> | ||
CHECK-TABLE: <div class="requirement__title"> | ||
CHECK-TABLE-NEXT: <b>"escaping"&nbsp;'section title'</b> | ||
CHECK-TABLE-NEXT: </div> | ||
CHECK-TRACE: <sdoc-autogen>1. <b>"escaping"&nbsp;'section title'</b></sdoc-autogen> | ||
|
||
# Main document: Text statement. | ||
CHECK-INPUT: <p><b>"escaping"&nbsp;'text statement'</b></p> | ||
CHECK-TABLE: <p><b>"escaping"&nbsp;'text statement'</b></p> | ||
CHECK-TRACE: <p><b>"escaping"&nbsp;'text statement'</b></p> | ||
|
||
# Main document: Requirement statement. | ||
CHECK-ALL: <p><b>"escaping"&nbsp;'requirement statement'</b></p> |
15 changes: 15 additions & 0 deletions
15
tests/integration/commands/export/html/escaping/02_escape_input_from_src_file/file.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# <b>"escaping" 'line mark'</b> @sdoc(REQ-1) | ||
def print_test(): | ||
test1 = """ | ||
<b>"escaping" 'normal src line'</b> | ||
""" | ||
test2 = """<b>"escaping" 'forward range mark before'</b> | ||
<b>"escaping" 'forward range mark after'</b> | ||
""" | ||
print(f"{test1} {test2}") # noqa: T201# | ||
|
||
|
||
# <b>"escaping" 'range mark before'</b> @sdoc[REQ-1] | ||
def hello_world(): | ||
print("hello world") # noqa: T201 | ||
# <b>"escaping" 'range mark after'</b> @sdoc[/REQ-1] |
14 changes: 14 additions & 0 deletions
14
tests/integration/commands/export/html/escaping/02_escape_input_from_src_file/input.sdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[DOCUMENT] | ||
TITLE: HTML escaping of source file content | ||
|
||
[REQUIREMENT] | ||
UID: REQ-1 | ||
STATEMENT: >>> | ||
Source files are external input, their content must be HTML escaped. | ||
<<< | ||
RELATIONS: | ||
- TYPE: File | ||
VALUE: file.py | ||
- TYPE: File | ||
VALUE: file.py | ||
LINE_RANGE: 6, 7 |
5 changes: 5 additions & 0 deletions
5
tests/integration/commands/export/html/escaping/02_escape_input_from_src_file/strictdoc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[project] | ||
|
||
features = [ | ||
"REQUIREMENT_TO_SOURCE_TRACEABILITY", | ||
] |
59 changes: 59 additions & 0 deletions
59
tests/integration/commands/export/html/escaping/02_escape_input_from_src_file/test.itest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
RUN: %strictdoc export %S --output-dir Output/ | filecheck %s --dump-input=fail --check-prefix CHECK-EXPORT | ||
CHECK-EXPORT: Published: HTML escaping of source file content | ||
|
||
RUN: %cat %S/Output/html/_source_files/file.py.html | filecheck %s --dump-input=fail --check-prefix CHECK-SRC | ||
|
||
# Line marker. | ||
CHECK-SRC: <pre class="sdoc-comment"># <b>"escaping"&nbsp;'line mark'</b> @sdoc(<a | ||
CHECK-SRC-NEXT: class="pointer" | ||
CHECK-SRC-NEXT: data-reqid="REQ-1" | ||
CHECK-SRC-NEXT: data-begin="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-end="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-traceability-file-type="this_file" | ||
CHECK-SRC-NEXT: href="../_source_files/file.py.html#REQ-1#{{[0-9]+}}#{{[0-9]+}}" | ||
CHECK-SRC-NEXT: >REQ-1</a>)</pre></div><div id="line-{{[0-9]+}}" class="source__line-number"><pre>2</pre> | ||
|
||
# Normal source code line. | ||
CHECK-SRC: <pre class="highlight"><span class="s2">{{\s+}}<b>"escaping"&nbsp;'normal src line'</b></span></pre> | ||
|
||
# Forward range marker before. | ||
CHECK-SRC: <pre class="sdoc-comment">{{\s+}}<span class="n">test2</span>{{\s+}}<span class="o">=</span> <span class="s2">"""<b>"escaping"&nbsp;'forward range mark before'</b></span>{{\s+}}<a | ||
CHECK-SRC-NEXT: class="pointer" | ||
CHECK-SRC-NEXT: data-reqid="REQ-1" | ||
CHECK-SRC-NEXT: data-begin="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-end="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-traceability-file-type="this_file" | ||
CHECK-SRC-NEXT: href="../_source_files/file.py.html#REQ-1#{{[0-9]+}}#{{[0-9]+}}" | ||
CHECK-SRC-NEXT: >REQ-1</a> | ||
CHECK-SRC-NEXT: </pre> | ||
|
||
# Forward range marker after. | ||
CHECK-SRC: <pre class="sdoc-comment"><span class="s2">{{\s+}}<b>"escaping"&nbsp;'forward range mark after'</b></span>{{\s+}}<a | ||
CHECK-SRC-NEXT: class="pointer" | ||
CHECK-SRC-NEXT: data-reqid="REQ-1" | ||
CHECK-SRC-NEXT: data-begin="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-end="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-traceability-file-type="this_file" | ||
CHECK-SRC-NEXT: href="../_source_files/file.py.html#REQ-1#{{[0-9]+}}#{{[0-9]+}}" | ||
CHECK-SRC-NEXT: >/REQ-1</a> | ||
CHECK-SRC-NEXT: </pre> | ||
|
||
# Range marker before. | ||
CHECK-SRC: <pre class="sdoc-comment"># <b>"escaping"&nbsp;'range mark before'</b> @sdoc[<a | ||
CHECK-SRC-NEXT: class="pointer" | ||
CHECK-SRC-NEXT: data-reqid="REQ-1" | ||
CHECK-SRC-NEXT: data-begin="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-end="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-traceability-file-type="this_file" | ||
CHECK-SRC-NEXT: href="../_source_files/file.py.html#REQ-1#{{[0-9]+}}#{{[0-9]+}}" | ||
CHECK-SRC-NEXT: >REQ-1</a>]</pre> | ||
|
||
# Range marker after. | ||
CHECK-SRC: <pre class="sdoc-comment"># <b>"escaping"&nbsp;'range mark after'</b> @sdoc[<a | ||
CHECK-SRC-NEXT: class="pointer" | ||
CHECK-SRC-NEXT: data-reqid="REQ-1" | ||
CHECK-SRC-NEXT: data-begin="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-end="{{[0-9]+}}" | ||
CHECK-SRC-NEXT: data-traceability-file-type="this_file" | ||
CHECK-SRC-NEXT: href="../_source_files/file.py.html#REQ-1#{{[0-9]+}}#{{[0-9]+}}" | ||
CHECK-SRC-NEXT: >/REQ-1</a>]</pre> |