Fix doc attribute parsing to properly handle block comments#1130
Merged
emilio merged 1 commit intomozilla:mainfrom Feb 21, 2026
Merged
Fix doc attribute parsing to properly handle block comments#1130emilio merged 1 commit intomozilla:mainfrom
emilio merged 1 commit intomozilla:mainfrom
Conversation
15f6769 to
423f63a
Compare
The existing parsing logic is flawed, as it concatenates consecutive lines, e.g. this: /** This is the first paragraph. */ ...becomes this: /** * # Heading This is the first paragraph. */ Lists are also effected.
423f63a to
300c731
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing parsing logic is flawed, as it concatenates consecutive lines, e.g. this:
...becomes this (correct):
But the same thing as a block comment:
...becomes this (broken):
The current splitting logic (introduced in #454) tries to join together lines in the same paragraph but without properly parsing and interpreting the markdown, leading to removing semantically-important line breaks.
It also allows for broken syntax if a
/is placed at the beginning of a line, since there is no leading space after the*marker (creating a*/which closes the comment block).The simpler approach in this PR is to simply split on newlines, which makes the parsing behaviour of block doc comments more consistent with single-line doc comments. We also add a single space at the start of each line, which is normally included in single-line doc comments but not in the block variant and prevents us accidentally creating a
*/.EDIT: I also realised I had to remove "common" whitespace between all lines in the block, or else block doc comments within modules are parsed with leading whitespace included, which is usually not intended. I have included tests for all new functionality and slightly modified the
documentation_attrtest for the new behaviour.