Skip to content

Conversation

@haxtibal
Copy link
Contributor

@haxtibal haxtibal commented Nov 10, 2025

Previously, a source node field was terminated at the first empty line. A workaround existed where adding literal \n\n was translated to new line.

This change removes the workaround and introduces a more user friendly rule where empty lines are kept as part of a field. To terminate the field we can either simply start the next field, or insert a reserved termination word that ends the field preliminary.

Comment grammar didn't change much. Most notably

  • newlines that belong to field text are now preserved and part of the parse tree
  • auto-dedent: the first non-empty line after the field line determines how much indent is automatically removed from each line

Note: The termination symbol is fixed to "SPDX-Req-End", this should be made configurable in an upcoming PR.

@haxtibal haxtibal force-pushed the tdmg/source_field_newline_endsymbol branch from 207564e to 8d9c65d Compare November 15, 2025 11:26
@haxtibal
Copy link
Contributor Author

haxtibal commented Nov 15, 2025

Please mind the PR description "Most notably newlines that belong to field text are now part of the parse tree".

I.e., line breaks from source node fields are now preserved (it becomes visible when you switch from RST to text rendering). Is it ok? I can adapt our tests, but don't know if it would break users.

I think the change is important in situations like here

 * SPDX-Text:
 * __ftrace_event_enable_disable - enable or disable a trace event.
 * @file: trace event file associated with the event.
 * @enable: 0 or 1 respectively to disable/enable the event (any other value is
 * invalid).
 * @soft_disable: 1 or 0 respectively to mark if the enable parameter IS or
 * IS NOT a soft enable/disable.
 *
 * Function Expectations: [...]

where we have a foreign syntax (kernel-doc) stuffed on top of our node field syntax.

EDIT:
I've also added a trivial field auto-dedent for two reasons:

  • the parser preprocessor adds spurious whitespace in the beginning of each line when it replaces comment characters with whitespace; this shall not be part of a field
  • users may add anything from 0 to n whitespaces at the beginning by their coding style when they write comments

@haxtibal haxtibal force-pushed the tdmg/source_field_newline_endsymbol branch 2 times, most recently from 257b8d3 to 172b18d Compare November 16, 2025 09:43
@haxtibal haxtibal changed the title draft: feat(backend/sdoc_source_code): Allow empty lines in source node fields feat(backend/sdoc_source_code): Allow empty lines in source node fields Nov 16, 2025
haxtibal and others added 3 commits November 19, 2025 17:53
Previously, a source node field was terminated at the first empty line.
A workaround existed where adding literal \n\n was translated to new
line. This removes the workaround and introduces a more user friendly
way, where empty lines don't terminate a field. Instead, either the next
field marker or a reserved termination word ends the field.

Comment grammar didn't change much. Most notaly newlines that belong to
field text are now part of the parse tree.
This should avoid any differences between how the source files are stored on
Linux and Windows developer machines.
@stanislaw stanislaw merged commit 714947e into strictdoc-project:main Nov 19, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants