Skip to content

Conversation

@Josmithr
Copy link

@Josmithr Josmithr commented Oct 7, 2025

Preserves line breaks when emitting TSDoc comments. Ensures information is not lost.

@Josmithr Josmithr changed the title feat(tsdoc): Don't strip line breaks when parsing comments feat(tsdoc): Don't strip line breaks when emitting comments Oct 7, 2025
@Josmithr Josmithr changed the title feat(tsdoc): Don't strip line breaks when emitting comments feat(tsdoc): Don't replace line breaks when emitting comments Oct 7, 2025
@octogonz
Copy link
Collaborator

octogonz commented Oct 7, 2025

This LGTM but I'm currently traveling, so I'm not able to test it.

@iclanton maybe you can try it in the playground?

@Josmithr Josmithr marked this pull request as ready for review October 8, 2025 14:32
@Josmithr Josmithr mentioned this pull request Oct 8, 2025
@iclanton
Copy link
Member

iclanton commented Oct 9, 2025

@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>
@Josmithr
Copy link
Author

Josmithr commented Nov 17, 2025

@Josmithr, can you provide some examples of what this actually changes? Maybe inputs and diffs of the before/after outputs?

@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).

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.

3 participants