Skip to content

Add docCommentValue property to Trivia#3230

Merged
ahoppen merged 6 commits intoswiftlang:mainfrom
PhantomInTheWire:feat/docCommentValue
Jan 18, 2026
Merged

Add docCommentValue property to Trivia#3230
ahoppen merged 6 commits intoswiftlang:mainfrom
PhantomInTheWire:feat/docCommentValue

Conversation

@PhantomInTheWire
Copy link
Member

fixes: #1890

  • Adds Trivia.docCommentValue to conveniently extract the text content of the last documentation comment in a trivia collection.
  • Automatically strips comment markers (///, /**, */) and intelligently removes common indentation from multi-line block comments.
  • Implements stateful parsing to correctly handle section breaks, ensuring only the most immediate doc comment is processed.
  • Includes extensive test coverage for various scenarios including mixed comment styles, complex indentation, and interleaved non-doc trivia.

@ahoppen
Copy link
Member

ahoppen commented Jan 11, 2026

If I understand it correctly, this PR is based on top of #2966, right? Thanks for picking that stale PR up! To make sure we give @zyadtaha credit where credit is due for all the work he put into the original PR, would you mind basing you changes on top of his branch so that we retain his original commit and keep him listed as that commit’s author? The author field should be retained if you cherry-pick a commit or rebase it (feel free to read up on the distinction between committer and author in git if you are interested 😉).

A real review will follow, I think it might be easier to get the git logistics sorted out first though.

@PhantomInTheWire
Copy link
Member Author

PhantomInTheWire commented Jan 12, 2026

@ahoppen I think this should be good now

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking the PR up again, @PhantomInTheWire

- Fix blank line stripping to only remove first/last line, not all blank lines
- Add regression test and convert test strings to multi-line format
- Move release notes entry from 602 to 604
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two style comments, otherwise LGTM.

Signed-off-by: Karan <[email protected]>
@PhantomInTheWire
Copy link
Member Author

@swift-ci please test

@PhantomInTheWire
Copy link
Member Author

@swift-ci test macos

@PhantomInTheWire
Copy link
Member Author

@swift-ci test linux

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I forgot a little bit that this is swift-syntax and we haven an RFC process for adding/changing public API. Could you create a forum post as described in there to allow others to weigh in? Once that’s done, we can hit merge. Any potential feedback can be addressed in follow-up PRs.

@PhantomInTheWire
Copy link
Member Author

@swift-ci please test macos

@PhantomInTheWire
Copy link
Member Author

@ahoppen ahoppen merged commit 9b153a9 into swiftlang:main Jan 18, 2026
37 checks passed
@PhantomInTheWire PhantomInTheWire deleted the feat/docCommentValue branch January 18, 2026 20:42
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.

Please add a TriviaPiece.commentValue property

3 participants