Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion strictdoc/backend/sdoc/grammar/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
(relations += Reference)
)?

section_contents *= SpaceThenRequirement
section_contents *= SectionOrRequirement

'\n'
'[[/' node_type_close = RequirementType ']]' '\n'
Expand Down
12 changes: 10 additions & 2 deletions strictdoc/backend/sdoc/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from strictdoc.helpers.auto_described import auto_described
from strictdoc.helpers.cast import assert_cast
from strictdoc.helpers.exception import StrictDocException
from strictdoc.helpers.mid import MID
from strictdoc.helpers.string import ensure_newline

Expand Down Expand Up @@ -121,10 +122,17 @@ def __init__(
] = parent

self.node_type: str = node_type
# FIXME: MERGE NODES

if node_type_close is not None and len(node_type_close) > 0:
assert node_type == node_type_close
if node_type != node_type_close:
raise StrictDocException(
"[[NODE]] syntax error: "
"Opening and closing tags must match: "
f"opening: {node_type}, closing: {node_type_close}."
)
assert is_composite
else:
assert not is_composite

self.is_composite: bool = is_composite

Expand Down
1 change: 1 addition & 0 deletions strictdoc/backend/sdoc/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def get_default_processors(self):
"SDocSection": self.process_section,
"DocumentFromFile": self.process_document_from_file,
"SDocCompositeNode": self.process_composite_requirement,
"SDocCompositeNodeNew": self.process_requirement,
"SDocNode": self.process_requirement,
"SDocNodeField": self.process_node_field,
}
Expand Down
1 change: 1 addition & 0 deletions strictdoc/server/reload_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def create(
+ cls.expand_folder("dist", max_depth=3)
+ cls.expand_folder("tests", max_depth=15)
+ cls.expand_folder("output", max_depth=15)
+ cls.expand_folder("Output", max_depth=15)
)

# Changing typical StrictDoc's own source code files should trigger
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from strictdoc.backend.sdoc.reader import SDReader
from strictdoc.backend.sdoc.writer import SDWriter
from strictdoc.helpers.exception import StrictDocException


def test_001_minimal_doc(default_project_config):
Expand Down Expand Up @@ -964,6 +965,30 @@ def test_089_document_config_use_mid(default_project_config):
assert input_sdoc == output


def test__validation__30__composite_node_start_end_tags_do_not_match():
input_sdoc = """\
[DOCUMENT]
TITLE: Test Doc

[[REQUIREMENT]]
UID: TITLE

[[/FOOBAR]]
""".lstrip()

reader = SDReader()

with pytest.raises(Exception) as exc_info:
_ = reader.read(input_sdoc)

assert exc_info.type is StrictDocException
assert exc_info.value.args[0] == (
"[[NODE]] syntax error: "
"Opening and closing tags must match: "
"opening: REQUIREMENT, closing: FOOBAR."
)


def test_edge_case_01_minimal_requirement(default_project_config):
input_sdoc = """
[DOCUMENT]
Expand Down
Loading