Skip to content

Commit

Permalink
fix: log warning for duplicate part ids when writing markdown from js…
Browse files Browse the repository at this point in the history
…on (#1395)

* fix: use empty string if part prose is None

Signed-off-by: Sharma-Amit <Sharma.Amit@ibm.com>

* test: add test for checking no prose in part

Signed-off-by: Sharma-Amit <Sharma.Amit@ibm.com>

* fix: write warning instead of exit with code 1 when duplicate parts

Signed-off-by: Sharma-Amit <Sharma.Amit@ibm.com>

---------

Signed-off-by: Sharma-Amit <Sharma.Amit@ibm.com>
  • Loading branch information
srmamit committed Jun 1, 2023
1 parent 5427fbb commit 760dd4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/trestle/core/commands/author/catalog_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def test_catalog_duplicate_parts_statement(tmp_trestle_dir: pathlib.Path, monkey
file_utils.insert_text_in_file(md_path, '## Control Statement', control_statement_prose_with_parts)

catalog_assemble = 'trestle author catalog-assemble -o my_catalog -m md_catalog'
test_utils.execute_command_and_assert(catalog_assemble, 1, monkeypatch)
test_utils.execute_command_and_assert(catalog_assemble, 0, monkeypatch)

_, error = capsys.readouterr()
assert 'Duplicate part id ac-2_smt.a' in error
Expand Down
2 changes: 1 addition & 1 deletion trestle/core/markdown/control_markdown_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _read_parts(self, indent: int, ii: int, lines: List[str], parent_id: str,
prop = common.Property(name='label', value=id_text)
part = common.Part(name=name, id=id_, prose=prose, props=[prop])
if id_ in [p.id for p in parts]:
raise TrestleError(
logger.warning(
f'Duplicate part id {id_} is found in markdown '
f'{tree_context.control_id}. Please correct the part label in line {line}.'
)
Expand Down

0 comments on commit 760dd4b

Please sign in to comment.