Skip to content

Commit 18626c9

Browse files
authored
Merge pull request #2492 from strictdoc-project/stanislaw/section
chore(tests/integration): migrate remaining itests from [SECTION] to [[SECTION]]
2 parents 4b741ca + 18390f3 commit 18626c9

File tree

106 files changed

+282
-12087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+282
-12087
lines changed

strictdoc/backend/reqif/p01_sdoc/reqif_to_sdoc_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from strictdoc.backend.sdoc.models.model import (
3737
SDocDocumentIF,
3838
SDocNodeIF,
39-
SDocSectionIF,
4039
)
4140
from strictdoc.backend.sdoc.models.node import SDocNode, SDocNodeField
4241
from strictdoc.backend.sdoc.models.reference import (
@@ -383,7 +382,7 @@ def create_document(
383382
def create_requirement_from_spec_object(
384383
spec_object: ReqIFSpecObject,
385384
context: P01_ReqIFToSDocBuildContext,
386-
parent_section: Union[SDocSectionIF, SDocDocumentIF, SDocNodeIF],
385+
parent_section: Union[SDocDocumentIF, SDocNodeIF],
387386
document_reference: DocumentReference,
388387
reqif_bundle: ReqIFBundle,
389388
level: int,

strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
ParentReqReference,
5252
Reference,
5353
)
54-
from strictdoc.backend.sdoc.models.section import SDocSection
5554
from strictdoc.core.document_iterator import DocumentCachingIterator
5655
from strictdoc.core.document_tree import DocumentTree
5756
from strictdoc.helpers.cast import assert_cast
@@ -282,14 +281,6 @@ def convert_document_tree(
282281
for node_, _ in document_iterator.all_content(
283282
print_fragments=False
284283
):
285-
if isinstance(node_, SDocSection):
286-
raise AssertionError(
287-
"[SECTION] tags are deprecated when using ReqIF export/import. "
288-
"Use [[SECTION]] tags instead. "
289-
"See the migration guide for more details: "
290-
"https://strictdoc.readthedocs.io/en/latest/latest/docs/strictdoc_01_user_guide.html#SECTION-UG-NODE-MIGRATION"
291-
)
292-
293284
if not isinstance(node_, SDocNode):
294285
continue
295286
leaf_or_composite_node = assert_cast(node_, SDocNode)

strictdoc/backend/sdoc/models/constants.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@
4343
ParentReqReference,
4444
Reference,
4545
)
46-
from strictdoc.backend.sdoc.models.section import SDocSection
4746

4847
SECTION_MODELS = [
49-
SDocSection,
5048
DocumentFromFile,
5149
SDocNode,
5250
SDocNodeField,

strictdoc/backend/sdoc/models/document_from_file.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SDocDocumentIF,
1212
SDocElementIF,
1313
SDocNodeIF,
14-
SDocSectionIF,
1514
)
1615
from strictdoc.backend.sdoc.models.node import SDocCompositeNode
1716
from strictdoc.helpers.auto_described import auto_described
@@ -21,10 +20,10 @@
2120
class DocumentFromFile(SDocDocumentFromFileIF):
2221
def __init__(
2322
self,
24-
parent: Union[SDocDocumentIF, SDocSectionIF],
23+
parent: Union[SDocDocumentIF, SDocNodeIF],
2524
file: str,
2625
) -> None:
27-
self.parent: Union[SDocDocumentIF, SDocSectionIF] = parent
26+
self.parent: Union[SDocDocumentIF, SDocNodeIF] = parent
2827
self.file: str = file
2928

3029
self.ng_has_requirements: bool = False
@@ -85,9 +84,7 @@ def configure_with_resolved_document(
8584

8685
if isinstance(including_document_or_section, SDocDocumentIF):
8786
including_document = including_document_or_section
88-
elif isinstance(
89-
including_document_or_section, (SDocSectionIF, SDocCompositeNode)
90-
):
87+
elif isinstance(including_document_or_section, SDocCompositeNode):
9188
including_document_: Optional[SDocDocumentIF] = (
9289
including_document_or_section.get_document()
9390
)

strictdoc/backend/sdoc/models/document_grammar.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __init__(
4141
@staticmethod
4242
def create_default(
4343
parent: Optional[SDocDocumentIF],
44-
create_section_element: bool = False,
4544
enable_mid: bool = False,
4645
) -> "DocumentGrammar":
4746
text_element: GrammarElement = (
@@ -131,13 +130,12 @@ def create_default(
131130

132131
elements: List[GrammarElement] = []
133132

134-
if create_section_element:
135-
section_element: GrammarElement = (
136-
DocumentGrammar.create_default_section_element(
137-
enable_mid=enable_mid
138-
)
133+
section_element: GrammarElement = (
134+
DocumentGrammar.create_default_section_element(
135+
enable_mid=enable_mid
139136
)
140-
elements.append(section_element)
137+
)
138+
elements.append(section_element)
141139

142140
elements.append(text_element)
143141
elements.append(requirement_element)

strictdoc/backend/sdoc/models/model.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SDocNodeFieldIF(ABC):
5252
class SDocNodeIF(ABC):
5353
reserved_mid: MID
5454
mid_permanent: bool
55-
parent: Union["SDocNodeIF", "SDocDocumentIF", "SDocSectionIF"]
55+
parent: Union["SDocNodeIF", "SDocDocumentIF"]
5656
node_type: str
5757
section_contents: List["SDocElementIF"]
5858
ng_level: Optional[int]
@@ -108,39 +108,6 @@ def blacklist_if_needed(self) -> None:
108108
raise NotImplementedError
109109

110110

111-
class SDocSectionIF(ABC):
112-
reserved_mid: MID
113-
reserved_uid: Optional[str]
114-
mid_permanent: bool
115-
parent: Union["SDocDocumentIF", "SDocSectionIF"]
116-
section_contents: List["SDocElementIF"]
117-
ng_level: Optional[int]
118-
ng_resolved_custom_level: Optional[str]
119-
ng_whitelisted: bool
120-
ng_has_requirements: bool
121-
autogen: bool
122-
123-
@abstractmethod
124-
def get_document(self) -> Optional["SDocDocumentIF"]:
125-
raise NotImplementedError
126-
127-
@abstractmethod
128-
def get_prefix(self) -> str:
129-
raise NotImplementedError
130-
131-
@abstractmethod
132-
def get_debug_info(self) -> str:
133-
raise NotImplementedError
134-
135-
@abstractmethod
136-
def get_display_title(self, include_toc_number: bool = True) -> str:
137-
raise NotImplementedError
138-
139-
@abstractmethod
140-
def blacklist_if_needed(self) -> None:
141-
raise NotImplementedError
142-
143-
144111
class SDocGrammarIF:
145112
pass
146113

@@ -192,7 +159,7 @@ def blacklist_if_needed(self) -> None:
192159

193160

194161
class SDocDocumentFromFileIF(ABC):
195-
parent: Union[SDocDocumentIF, SDocSectionIF]
162+
parent: Union[SDocDocumentIF, SDocNodeIF]
196163
ng_resolved_custom_level: Optional[str]
197164
ng_whitelisted: bool
198165
autogen: bool
@@ -211,15 +178,13 @@ def section_contents(self) -> List[SDocDocumentIF]:
211178

212179
SDocElementIF = Union[
213180
SDocNodeIF,
214-
SDocSectionIF,
215181
SDocDocumentIF,
216182
SDocDocumentFromFileIF,
217183
]
218184

219185

220186
SDocIteratedElementIF = Union[
221187
SDocNodeIF,
222-
SDocSectionIF,
223188
SDocDocumentIF,
224189
]
225190

strictdoc/backend/sdoc/models/node.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
SDocDocumentIF,
2222
SDocElementIF,
2323
SDocNodeIF,
24-
SDocSectionIF,
2524
)
2625
from strictdoc.backend.sdoc.models.reference import (
2726
ChildReqReference,
@@ -103,7 +102,7 @@ def get_text_value(self) -> str:
103102
class SDocNode(SDocNodeIF):
104103
def __init__(
105104
self,
106-
parent: Union[SDocDocumentIF, SDocSectionIF, SDocNodeIF],
105+
parent: Union[SDocDocumentIF, SDocNodeIF],
107106
node_type: str,
108107
fields: List[SDocNodeField],
109108
relations: List[Reference],
@@ -116,7 +115,7 @@ def __init__(
116115
assert isinstance(node_type, str)
117116
assert isinstance(relations, list), relations
118117

119-
self.parent: Union[SDocDocumentIF, SDocSectionIF, SDocNodeIF] = parent
118+
self.parent: Union[SDocDocumentIF, SDocNodeIF] = parent
120119

121120
self.node_type: str = node_type
122121

@@ -259,7 +258,10 @@ def get_display_title(
259258
if self.reserved_uid is not None:
260259
return self.reserved_uid
261260
if self.node_type == "TEXT":
262-
if isinstance(self.parent, SDocSectionIF):
261+
if (
262+
isinstance(self.parent, SDocNode)
263+
and self.parent.node_type == "SECTION"
264+
):
263265
return f'Text node from section "{self.parent.get_display_title()}"'
264266
if isinstance(self.parent, SDocDocumentIF):
265267
return f'Text node from document "{self.parent.get_display_title()}"'
@@ -778,7 +780,7 @@ def _update_has_meta(self) -> None:
778780
class SDocCompositeNode(SDocNode):
779781
def __init__(
780782
self,
781-
parent: Union[SDocDocumentIF, SDocSectionIF, SDocNodeIF],
783+
parent: Union[SDocDocumentIF, SDocNodeIF],
782784
**fields: Any,
783785
) -> None:
784786
super().__init__(parent, **fields, is_composite=True)

0 commit comments

Comments
 (0)