diff --git a/CHANGELOG.md b/CHANGELOG.md index cb08a5d..4dd315e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ generated in the following situations: ### 3.0.0-dev +* [TRLC_RST] Render soft-wrapped description lines as a single RST + paragraph instead of splitting each line into its own paragraph. + Insert a blank line to start a new paragraph. + * [TRLC, BAZEL] Removed the support for the CVC5 binary, and hence the `--use-cvc5-binary` option is no longer available. The option `--verify` now uses the CVC5 Python package diff --git a/tools/trlc_rst/README.md b/tools/trlc_rst/README.md index 12f91c6..208fd6e 100644 --- a/tools/trlc_rst/README.md +++ b/tools/trlc_rst/README.md @@ -60,7 +60,7 @@ The following formatting is supported in requirement `description` fields: | Code block | line ending with `::` followed by indented content | RST literal block | | Bullet list | lines starting with `-` | RST bullet list | | Numbered list | lines starting with `1.`, `2.`, … | RST enumerated list | -| Line breaks | any non-empty line | separated by blank lines in RST | +| Soft wraps | consecutive non-empty lines | joined into one RST paragraph; insert a blank line to start a new paragraph | ### Command-line Usage diff --git a/tools/trlc_rst/tests/paragraph-breaks/output.rst b/tools/trlc_rst/tests/paragraph-breaks/output.rst new file mode 100644 index 0000000..318aca3 --- /dev/null +++ b/tools/trlc_rst/tests/paragraph-breaks/output.rst @@ -0,0 +1,10 @@ +Requirements +============ +.. requirement:definition:: T.REQ_paragraph_breaks + + The system shall do X + when condition Y is met. + + This is a separate paragraph that + must not be merged with the first. + diff --git a/tools/trlc_rst/tests/paragraph-breaks/reqs.trlc b/tools/trlc_rst/tests/paragraph-breaks/reqs.trlc new file mode 100644 index 0000000..863b179 --- /dev/null +++ b/tools/trlc_rst/tests/paragraph-breaks/reqs.trlc @@ -0,0 +1,11 @@ +package T + +Requirement REQ_paragraph_breaks { + description = ''' + The system shall do X + when condition Y is met. + + This is a separate paragraph that + must not be merged with the first. + ''' +} diff --git a/tools/trlc_rst/tests/paragraph-breaks/schema.rsl b/tools/trlc_rst/tests/paragraph-breaks/schema.rsl new file mode 100644 index 0000000..cf14224 --- /dev/null +++ b/tools/trlc_rst/tests/paragraph-breaks/schema.rsl @@ -0,0 +1,5 @@ +package T + +type Requirement { + description optional String +} diff --git a/tools/trlc_rst/tests/soft-wraps/output.rst b/tools/trlc_rst/tests/soft-wraps/output.rst new file mode 100644 index 0000000..dc37cb6 --- /dev/null +++ b/tools/trlc_rst/tests/soft-wraps/output.rst @@ -0,0 +1,8 @@ +Requirements +============ +.. requirement:definition:: T.REQ_soft_wraps + + The system shall do X + when condition Y is met + and Z is configured. + diff --git a/tools/trlc_rst/tests/soft-wraps/reqs.trlc b/tools/trlc_rst/tests/soft-wraps/reqs.trlc new file mode 100644 index 0000000..b615d37 --- /dev/null +++ b/tools/trlc_rst/tests/soft-wraps/reqs.trlc @@ -0,0 +1,9 @@ +package T + +Requirement REQ_soft_wraps { + description = ''' + The system shall do X + when condition Y is met + and Z is configured. + ''' +} diff --git a/tools/trlc_rst/tests/soft-wraps/schema.rsl b/tools/trlc_rst/tests/soft-wraps/schema.rsl new file mode 100644 index 0000000..cf14224 --- /dev/null +++ b/tools/trlc_rst/tests/soft-wraps/schema.rsl @@ -0,0 +1,5 @@ +package T + +type Requirement { + description optional String +} diff --git a/tools/trlc_rst/trlc_rst.py b/tools/trlc_rst/trlc_rst.py index c121ccc..a57bc84 100644 --- a/tools/trlc_rst/trlc_rst.py +++ b/tools/trlc_rst/trlc_rst.py @@ -473,7 +473,8 @@ def _preprocess_description(description: str, indent: int = 3) -> str: - RST directives: ``.. image::``, ``.. figure::``, etc. with options - Bullet lists: Lines starting with - - Numbered lists: Lines starting with 1., 2., etc. - - Line breaks: Preserved between all content lines""" + - Soft wraps: Consecutive non-empty lines are joined into a single + RST paragraph; insert a blank line to start a new paragraph.""" if not description: return description @@ -574,16 +575,6 @@ def _md_image_sub(m): next_line.lstrip() ) - # Add blank line after non-list lines to preserve line breaks - # (unless next line is empty, we're at the end, or we're in a code block) - elif ( - not is_list_item - and not in_code_block - and i < len(lines) - 1 - and lines[i + 1].strip() - ): - processed_lines.append("") - prev_was_list_item = is_list_item else: # Preserve empty lines for paragraph separation