-
Notifications
You must be signed in to change notification settings - Fork 148
feat(tsdoc): Don't replace line breaks when emitting comments #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
tsdoc/src/__tests__/__snapshots__/DocNodeTransforms.test.ts.snap
Outdated
Show resolved
Hide resolved
|
This LGTM but I'm currently traveling, so I'm not able to test it. @iclanton maybe you can try it in the playground? |
common/changes/@microsoft/tsdoc/josmithr-dont-strip-line-breaks_2025-10-07-21-19.json
Outdated
Show resolved
Hide resolved
|
@Josmithr, can you provide some examples of what this actually changes? Maybe inputs and diffs of the before/after outputs? |
…s_2025-10-07-21-19.json Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
@iclanton Sorry, I completely missed the notifications on this and have been working in other areas. The main goal here is to preserve the doc author's line breaks when parsing the comments. This makes round-tripping of comments non-lossy. For example, consider this multi-line TSDoc comment: /**
* Hello
* world
* !
*/Round-tripping this comment through TSDoc's current parser and emitter will yield: /**
* Hello world!
*/Which potentially loses important information. Where with my above changes you would get the original comment with its original line formatting. A particularly relevant case that can be useful to tools consuming the parsed comment is preservation of list-like syntax. Consider the following: /**
* Prerequisites:
* - Foo
* - Bar
*/This is currently parsed the same as: /**
* Prerequisites: - Foo - Bar
*/Which loses important contextual information. Hopefully that makes sense. Happy to provide more context or capture more of this with tests (if desired and if I can get some guidance as to where such tests should go). |
Preserves line breaks when emitting TSDoc comments. Ensures information is not lost.