Skip to content

Improve rendering of JSDoc comment text with displayparts #43390

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

Merged
merged 20 commits into from
Apr 9, 2021
Merged

Improve rendering of JSDoc comment text with displayparts #43390

merged 20 commits into from
Apr 9, 2021

Conversation

sangxxh
Copy link
Contributor

@sangxxh sangxxh commented Mar 26, 2021

Fixes #43085

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Mar 26, 2021
@sangxxh sangxxh marked this pull request as ready for review March 26, 2021 10:35
@sandersn
Copy link
Member

sandersn commented Mar 26, 2021

Well, I was actually thinking of changing the internal displaypart code to match the tag. The code that needs to change is in src/services/jsDoc.ts:140 -- getCommentDisplayParts. Right now everything results in a textPart (or spacePart), but there are lots more to choose from, many of which match parts of existing jsdoc. See all the -Part functions in src/services/utilities.ts.

VS Code already does some formatting itself, so it may be hard to see the difference if you're testing with it.
Edit: There are already quite a few baselines that dump jsdoc, so you might not need to write any new tests. Be sure to run all the tests after you get a significant change to find which tests to copy/modify.

@sangxxh sangxxh changed the title [WIP] Improve rendering of JSDoc comment text with displayparts Improve rendering of JSDoc comment text with displayparts Mar 27, 2021
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Besides the below comments, there needs to be new tests+baselines for @callback and @typedef. At least, I didn't see any in the existing tests.

function addComment(s: string, constructDisplayPartFunc?: ConstructSpecificDisplayPartFunction) {
return comment
? [!!constructDisplayPartFunc ? constructDisplayPartFunc(s) : textPart(s), spacePart(), ...getDisplayPartsFromComment(comment, checker)]
: [textPart(s)];
Copy link
Member

Choose a reason for hiding this comment

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

this is more a note to myself, but all of jsdoc.ts' displayparts code might need to be reworked to use a DisplayPartWriter in a subsequent PR. It looks like that's what the rest of service uses instead of building display parts themselves.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Some style suggestions

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Just a couple of cleanup requests

@sandersn sandersn merged commit a354a77 into microsoft:master Apr 9, 2021
@sangxxh sangxxh deleted the issue/43085-improve-render-jsdoc-comment-with-displayparts branch April 9, 2021 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve rendering of JSDoc comment text with displayparts
3 participants