Skip to content

Conversation

@timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Jun 23, 2023

fix #2095

Formatter will now format doc comment above directives and decorators. This only applies to doc comments. Regular line comments and block comments will remain where they are

#suppress "no-x" "X is needed"
@dec1
/**
 * Doc comment
 */
@dec2
model Foo {}

formats to

/**
 * Doc comment
 */
#suppress "no-x" "X is needed"
@dec1
@dec2
model Foo {}

Addition to the parser

BlockComment node has an optional property parsedAsDocs if the block comment was also parsed as a DocNode

Fix in the parser

The DocNode pos and end where showing not showing an accurate location. With single line doc comment pos===end and was pointing to /**<S><E> this is single line */

Changed it to point to <S>/** this is single line */<E>

@github-actions
Copy link
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/2114/

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

@timotheeguerin
Copy link
Member Author

@mikeharder another formatter change, this one might be happening in the spec repo

@timotheeguerin timotheeguerin changed the title Print doc comments at the top Print doc comments above directive and decorators Jun 23, 2023
@timotheeguerin timotheeguerin enabled auto-merge (squash) June 26, 2023 16:42
@timotheeguerin timotheeguerin merged commit 4515877 into microsoft:main Jun 26, 2023
@timotheeguerin timotheeguerin deleted the formatter/move-doc-comments-top branch June 26, 2023 16:53
mikeharder added a commit to mikeharder/azure-rest-api-specs that referenced this pull request Jun 26, 2023
mikeharder added a commit to Azure/azure-rest-api-specs that referenced this pull request Jun 26, 2023
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.

[Formatter] Should the doc comment be formatted above the decorators

2 participants