Skip to content

Commit a0d9b4f

Browse files
authored
Merge pull request #2522 from strictdoc-project/stanislaw/remove_sdoc_marker
chore(backend/sdoc_source_code): remove legacy @sdoc/nosdoc
2 parents 535c2a7 + 515e328 commit a0d9b4f

File tree

38 files changed

+366
-372
lines changed

38 files changed

+366
-372
lines changed

developer/fixit/check_comments.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"pragma",
1515
"pylint",
1616
"@relation",
17-
"@sdoc",
1817
"type:",
1918
]
2019

docs/strictdoc_01_user_guide.sdoc

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,10 +2735,6 @@ To connect a source file to a requirement, a dedicated ``@relation`` marker must
27352735

27362736
For language-specific parsing of source code, e.g., Python and C, make sure to enable the corresponding option, see [LINK: SECTION-UG-Language-aware-parsing-of-source-code].
27372737

2738-
.. warning::
2739-
2740-
The legacy ``@sdoc`` marker is still supported by StrictDoc but is deprecated. ``@relation`` is the new correct marker name.
2741-
27422738
It is also possible to use @relation markers and be compatible with Doxygen. See [LINK: SECTION-UG-Doxygen].
27432739

27442740
**1\) Linking a file to a requirement**
@@ -2930,6 +2926,28 @@ To establish a backward link from a source file to an SDoc node:
29302926

29312927
[[/SECTION]]
29322928

2929+
[[SECTION]]
2930+
MID: b893f545d95d457e8366928c467a2f5d
2931+
TITLE: Ignoring source code markers
2932+
2933+
[TEXT]
2934+
MID: 5c9881f6fa2847b3b95ef0cad131cfb3
2935+
STATEMENT: >>>
2936+
Sometimes, it is necessary to ignore ``@relation(...)`` markers in a specific section of a file. This can be done using the special skip keyword, as shown below:
2937+
2938+
.. code-block::
2939+
2940+
# @relation(skip, scope=range_start)
2941+
# @relation(REQ-001, scope=range_start)
2942+
...
2943+
# @relation(REQ-001, scope=range_end)
2944+
# @relation(skip, scope=range_end)
2945+
2946+
In this example, the ``skip``-relation causes StrictDoc to ignore the ``REQ-001`` requirement, so that it does not appear in the traceability information.
2947+
<<<
2948+
2949+
[[/SECTION]]
2950+
29332951
[[SECTION]]
29342952
MID: c9da7df725564208971e7ee058ad8d73
29352953
UID: SECTION-UG-Parsing-SDoc-source-nodes

docs/strictdoc_04_release_notes.sdoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ TITLE: Unreleased
5252
[TEXT]
5353
MID: 12345f3b28ea4bfe9ca8afe6b21826a8
5454
STATEMENT: >>>
55-
This release includes several bug fixes and improvements for edge cases.
55+
This release includes the removal of legacy @sdoc markers, several bug fixes, and enhancements for edge cases.
56+
57+
The legacy ``@sdoc`` marker has been removed from the codebase. From now on, only the ``@relation`` markers are recognized when linking requirements with source code files.
5658

5759
An edge case has been fixed where StrictDoc’s FileFinder was detecting Linux pipe files that could not be processed meaningfully by StrictDoc’s source file generator. With this release, such files are now ignored.
5860

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ classifiers = [
4747
"Programming Language :: Python :: Implementation :: PyPy",
4848
]
4949

50-
# @sdoc[SDOC-SRS-89]
50+
# @relation(SDOC-SRS-89, scope=range_start)
5151
dependencies = [
5252
"textx >= 4.0.0, == 4.*",
5353
"lark >= 1.2.2",
@@ -104,7 +104,7 @@ dependencies = [
104104
"plotly",
105105
"pandas"
106106
]
107-
# @sdoc[/SDOC-SRS-89]
107+
# @relation(SDOC-SRS-89, scope=range_end)
108108

109109
[project.optional-dependencies]
110110
development = [

strictdoc/backend/sdoc_source_code/grammar.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@
1717
;
1818
1919
RangeMarker[noskipws]:
20-
// It is a hard-won result: it is important that the "@sdoc" is within the
21-
// regex. Putting it next to the regex as "@sdoc" does not work.
20+
// It is a hard-won result: it is important that the "@relation" is within the
21+
// regex. Putting it next to the regex as "@relation" does not work.
2222
// TODO: It would be great to check this with the TextX developers.
23-
(
24-
/^.*?@sdoc/
25-
(begin_or_end = "[/" | begin_or_end = "[")
26-
(reqs_objs += Req[', ']) ']' '\n'?
27-
)
28-
|
29-
(
3023
/^.*?@relation/
3124
'('
3225
(reqs_objs += Req[', ']) ', scope=' scope=/(range_start|range_end)/ (", role=" role=/{REGEX_ROLE}/)? ')' '\n'?
33-
)
3426
;
3527
3628
FunctionRangeMarker[noskipws]:
@@ -39,18 +31,12 @@
3931
;
4032
4133
LineMarker[noskipws]:
42-
// It is a hard-won result: it is important that the "@sdoc" is within the
43-
// regex. Putting it next to the regex as "@sdoc" does not work.
34+
// It is a hard-won result: it is important that the "@relation" is within the
35+
// regex. Putting it next to the regex as "@relation" does not work.
4436
// TODO: It would be great to check this with the TextX developers.
45-
(
46-
/^.*?@sdoc/
47-
"(" (reqs_objs += Req[', ']) ')' '\n'?
48-
)
49-
|
50-
(
37+
5138
/^.*?@relation/
5239
"(" (reqs_objs += Req[', ']) ', scope=line' (", role=" role=/{REGEX_ROLE}/)? ")" '\n'?
53-
)
5440
;
5541
5642
Req[noskipws]:

strictdoc/backend/sdoc_source_code/marker_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ def _parse_relation_marker(
163163
function_marker.set_description(f"class {entity_name}")
164164
markers.append(function_marker)
165165
elif relation_scope in ("range_start", "range_end"):
166-
start_or_end = relation_scope == "range_start"
167166
range_marker = RangeMarker(
168167
None,
169-
"[" if start_or_end else "[/",
170168
requirements,
169+
scope=relation_scope,
171170
role=relation_role,
172171
)
173172
range_marker.ng_source_line_begin = (
@@ -178,7 +177,6 @@ def _parse_relation_marker(
178177
)
179178
range_marker.ng_range_line_begin = line_start
180179
range_marker.ng_range_line_end = line_end
181-
range_marker.ng_new_relation_keyword = True
182180
markers.append(range_marker)
183181
elif relation_scope == "line":
184182
line_marker = LineMarker(None, requirements, role=relation_role)

strictdoc/backend/sdoc_source_code/models/function_range_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
self.ng_marker_line: Optional[int] = None
5151
self.ng_marker_column: Optional[int] = None
5252

53-
self.ng_is_nodoc = "nosdoc" in self.reqs
53+
self.ng_is_nodoc = "skip" in self.reqs
5454

5555
self.begin_or_end: bool = True
5656

strictdoc/backend/sdoc_source_code/models/line_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(
2828
self.ng_range_line_begin: Optional[int] = None
2929
self.ng_range_line_end: Optional[int] = None
3030

31-
self.ng_is_nodoc: bool = "nosdoc" in self.reqs
31+
self.ng_is_nodoc: bool = "skip" in self.reqs
3232
self.begin_or_end = True
3333

3434
def is_begin(self) -> bool:

strictdoc/backend/sdoc_source_code/models/range_marker.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ class RangeMarker:
1313
def __init__(
1414
self,
1515
parent: Any,
16-
begin_or_end: str,
1716
reqs_objs: List[Req],
1817
scope: str = "",
1918
role: Optional[str] = None,
2019
) -> None:
2120
assert isinstance(reqs_objs, list)
2221
self.parent: Any = parent
23-
assert len(begin_or_end) > 0 or scope is not None
2422

25-
self.begin_or_end: str
26-
if len(begin_or_end) > 0:
27-
self.begin_or_end = begin_or_end
28-
else:
29-
assert scope in ("range_start", "range_end")
30-
self.begin_or_end = "[" if scope == "range_start" else "[/"
31-
self.ng_new_relation_keyword = True
23+
assert scope in ("range_start", "range_end")
24+
self.begin_or_end: bool = scope == "range_start"
3225

3326
self.reqs_objs: List[Req] = reqs_objs
3427
self.reqs: List[str] = list(map(lambda req: req.uid, reqs_objs))
@@ -51,14 +44,13 @@ def __init__(
5144
self.ng_range_line_begin: Optional[int] = None
5245
self.ng_range_line_end: Optional[int] = None
5346

54-
self.ng_is_nodoc: bool = "nosdoc" in self.reqs
55-
self.ng_new_relation_keyword = scope is not None and len(scope) > 0
47+
self.ng_is_nodoc: bool = "skip" in self.reqs
5648

5749
def is_begin(self) -> bool:
58-
return self.begin_or_end == "["
50+
return self.begin_or_end
5951

6052
def is_end(self) -> bool:
61-
return self.begin_or_end == "[/"
53+
return not self.begin_or_end
6254

6355
def is_range_marker(self) -> bool:
6456
return True

strictdoc/backend/sdoc_source_code/parse_context.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
@relation(SDOC-SRS-33, scope=file)
33
"""
44

5-
from typing import Any, Dict, List, Optional
5+
from typing import Any, Dict, List, Optional, Union
66

7+
from strictdoc.backend.sdoc_source_code.models.function_range_marker import (
8+
FunctionRangeMarker,
9+
)
10+
from strictdoc.backend.sdoc_source_code.models.line_marker import LineMarker
711
from strictdoc.backend.sdoc_source_code.models.range_marker import RangeMarker
812
from strictdoc.helpers.file_stats import SourceFileStats
913

@@ -12,8 +16,10 @@ class ParseContext:
1216
def __init__(
1317
self, filename: Optional[str], file_stats: SourceFileStats
1418
) -> None:
15-
self.filename: Optional[str] = filename
19+
self.filename: str = filename if filename else "<no filename>"
1620
self.file_stats: SourceFileStats = file_stats
1721
self.markers: List[Any] = []
18-
self.marker_stack: List[RangeMarker] = []
22+
self.marker_stack: List[
23+
Union[RangeMarker, FunctionRangeMarker, LineMarker]
24+
] = []
1925
self.map_reqs_to_markers: Dict[str, Any] = {}

0 commit comments

Comments
 (0)