File tree 10 files changed +71
-2
lines changed
strictdoc/export/html/generators
integration/features/file_traceability/_markers
02_file_marker_regression
unit/strictdoc/backend/sdoc_source_code/readers
10 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -232,9 +232,12 @@ def get_pygmented_source_lines(
232
232
)
233
233
234
234
for marker in coverage_info .markers :
235
- marker_line = marker .ng_source_line_begin
235
+ marker_line = (
236
+ marker .ng_range_line_begin
237
+ if marker .is_begin ()
238
+ else marker .ng_range_line_end
239
+ )
236
240
assert isinstance (marker_line , int )
237
-
238
241
source_marker_tuple : SourceMarkerTuple
239
242
if isinstance (
240
243
pygmented_source_file_lines [marker_line - 1 ], SourceMarkerTuple
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ """
2
+ @relation(REQ-1, scope=file)
3
+ """
4
+ from typing import Optional
5
+
6
+
7
+ class SDocDocumentContext :
8
+ def __init__ (self ) -> None :
9
+ self .title_number_string : Optional [str ] = None
Original file line number Diff line number Diff line change
1
+ [DOCUMENT]
2
+ TITLE: Hello world doc
3
+
4
+ [REQUIREMENT]
5
+ UID: REQ-1
6
+ TITLE: Requirement Title
7
+ STATEMENT: Requirement Statement
Original file line number Diff line number Diff line change
1
+ [project ]
2
+
3
+ features = [
4
+ " REQUIREMENT_TO_SOURCE_TRACEABILITY" ,
5
+ " SOURCE_FILE_LANGUAGE_PARSERS" ,
6
+ ]
Original file line number Diff line number Diff line change
1
+ REQUIRES: PYTHON_39_OR_HIGHER
2
+
3
+ # This test ensures that the entire file marker is correctly displayed as
4
+ # covering the file from its first line and until the last line.
5
+ # It fixes this issue:
6
+ # Bug: Source View screen: Entire file marker is one line off #2237
7
+ # https://github.com/strictdoc-project/strictdoc/issues/2237
8
+
9
+ RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail
10
+ CHECK: Published: Hello world doc
11
+
12
+ RUN: %check_exists --file "%S/Output/html/_source_files/file.py.html"
13
+
14
+ RUN: %cat %S/Output/html/_source_files/file.py.html | filecheck %s --dump-input=fail --check-prefix CHECK-SOURCE-FILE
15
+ CHECK-SOURCE-FILE: <span class="source__range-definition">1 - 9 | entire file</span>
Original file line number Diff line number Diff line change @@ -482,6 +482,35 @@ def function_1():
482
482
assert marker .reqs_objs [1 ].ng_source_column == 9
483
483
484
484
485
+ def test_080_file_marker ():
486
+ """
487
+ Test a basic file range relation marker.
488
+ """
489
+
490
+ source_input = b"""\
491
+ \" \" \"
492
+ @relation(REQ-1, scope=file)
493
+ \" \" \"
494
+
495
+ @auto_described
496
+ class SDocDocumentContext:
497
+ def __init__(self) -> None:
498
+ self.title_number_string: Optional[str] = None
499
+ """
500
+
501
+ reader = SourceFileTraceabilityReader_Python ()
502
+
503
+ document = reader .read (source_input )
504
+ markers = document .markers
505
+ marker = markers [0 ]
506
+ assert marker .reqs == ["REQ-1" ]
507
+ assert marker .ng_source_line_begin == 2
508
+ assert marker .ng_range_line_begin == 1
509
+ assert marker .ng_range_line_end == 8
510
+ assert marker .reqs_objs [0 ].ng_source_line == 2
511
+ assert marker .reqs_objs [0 ].ng_source_column == 11
512
+
513
+
485
514
def test_validation_01_one_range_marker_begin_req_not_equal_to_end_req ():
486
515
source_input = b"""
487
516
# @relation(REQ-001, scope=range_start)
You can’t perform that action at this time.
0 commit comments