Skip to content

Feature: Add colorization to js doc comments#2306

Merged
timotheeguerin merged 19 commits into
microsoft:mainfrom
timotheeguerin:feature/doc-comment-color
Sep 12, 2023
Merged

Feature: Add colorization to js doc comments#2306
timotheeguerin merged 19 commits into
microsoft:mainfrom
timotheeguerin:feature/doc-comment-color

Conversation

@timotheeguerin

@timotheeguerin timotheeguerin commented Aug 17, 2023

Copy link
Copy Markdown
Member

fix #1347

Add syntax highlighting to doc comments. Include the syntax definition for the tmlanguage as well as the semantic highlighting.

image

Try it in the playground

@github-actions

Copy link
Copy Markdown
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2306/

Website: https://cadlwebsite.z1.web.core.windows.net/prs/2306/

@timotheeguerin
timotheeguerin marked this pull request as ready for review August 18, 2023 19:28
Comment thread packages/compiler/src/server/tmlanguage.ts
@bterlson

bterlson commented Sep 6, 2023

Copy link
Copy Markdown
Member

Sorry I missed this until now.

I love the colors, definitely. However, I am pretty concerned about coloring the jsdoc keys the same as keywords. In the context of the given example, model gets lost. But I think the problem is worse in model properties where the jsdoc keywords will be much more prominent than the property itself.

Is there another option that might make sense?

@bterlson

bterlson commented Sep 6, 2023

Copy link
Copy Markdown
Member

Eh, looking at it again it looks ok for the model case. Maybe my concern is really just that member names aren't rendered differently and get lost in the list of comments and decorators.

@timotheeguerin

Copy link
Copy Markdown
Member Author

Sorry I missed this until now.

I love the colors, definitely. However, I am pretty concerned about coloring the jsdoc keys the same as keywords. In the context of the given example, model gets lost. But I think the problem is worse in model properties where the jsdoc keywords will be much more prominent than the property itself.

Is there another option that might make sense?

there is definitely some other token we can use than keyword I was just trying to keep the same used in typescript
image

we could not special case the known ones so they all like th @example in the image above

@allenjzhang

Copy link
Copy Markdown
Contributor

like the feature but not sure about the color choices. One of the key benefit for dev doc is to have comment color to allow eyes to easily differentiate between comments and code. So now we want to differentiate tokens in comments further, I would like to suggest color from a muted palette. Maybe from gray or darker (than comment green) green?

@timotheeguerin

Copy link
Copy Markdown
Member Author

like the feature but not sure about the color choices. One of the key benefit for dev doc is to have comment color to allow eyes to easily differentiate between comments and code. So now we want to differentiate tokens in comments further, I would like to suggest color from a muted palette. Maybe from gray or darker (than comment green) green?

We don't really control the actual color. The only thing we can do is give a token for what that chunk of text is. It is then up to the theme to color it. Some theme support more or less coloring. I did give it a different token than keywords but it default to that kind. This is also the same tokenization as typescript does with JSDoc. We could default to another token than keyword but it would also either could be a incorrect meaning and result in completely different colors between themes.

@allenjzhang allenjzhang reopened this Sep 11, 2023
@github-actions

Copy link
Copy Markdown
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2306/

Website: https://tspwebsitepr.z5.web.core.windows.net/prs/2306/

@timotheeguerin
timotheeguerin enabled auto-merge (squash) September 11, 2023 22:37
auto-merge was automatically disabled September 12, 2023 01:41

Pull request was closed

@github-actions

Copy link
Copy Markdown
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2306/

Website: https://tspwebsitepr.z5.web.core.windows.net/prs/2306/

@timotheeguerin
timotheeguerin enabled auto-merge (squash) September 12, 2023 01:46
@timotheeguerin
timotheeguerin merged commit 5db44b5 into microsoft:main Sep 12, 2023
@timotheeguerin
timotheeguerin deleted the feature/doc-comment-color branch September 12, 2023 01:52
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.

Better colorization of doc comments

4 participants