forked from prettier/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support nestled JSDoc comments (prettier#13445)
- Loading branch information
Showing
8 changed files
with
341 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#### Support nestled JSDoc comments (#13445 by @thorn0) | ||
|
||
This kind of comments is used to document overloaded functions (see https://github.com/jsdoc/jsdoc/issues/1017). | ||
|
||
<!-- prettier-ignore --> | ||
```jsx | ||
// Input | ||
/** | ||
* @template T | ||
* @param {Type} type | ||
* @param {T} value | ||
* @return {Value} | ||
*//** | ||
* @param {Type} type | ||
* @return {Value} | ||
*/ | ||
function value(type, value) { | ||
if (arguments.length === 2) { | ||
return new ConcreteValue(type, value); | ||
} else { | ||
return new Value(type); | ||
} | ||
} | ||
|
||
// Prettier stable | ||
/** | ||
* @template T | ||
* @param {Type} type | ||
* @param {T} value | ||
* @return {Value} | ||
*/ /** | ||
* @param {Type} type | ||
* @return {Value} | ||
*/ | ||
function value(type, value) { | ||
if (arguments.length === 2) { | ||
return new ConcreteValue(type, value); | ||
} else { | ||
return new Value(type); | ||
} | ||
} | ||
|
||
// Prettier main | ||
/** | ||
* @template T | ||
* @param {Type} type | ||
* @param {T} value | ||
* @return {Value} | ||
*//** | ||
* @param {Type} type | ||
* @return {Value} | ||
*/ | ||
function value(type, value) { | ||
if (arguments.length === 2) { | ||
return new ConcreteValue(type, value); | ||
} else { | ||
return new Value(type); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function isIndentableBlockComment(comment) { | ||
// If the comment has multiple lines and every line starts with a star | ||
// we can fix the indentation of each line. The stars in the `/*` and | ||
// `*/` delimiters are not included in the comment value, so add them | ||
// back first. | ||
const lines = `*${comment.value}*`.split("\n"); | ||
return lines.length > 1 && lines.every((line) => line.trimStart()[0] === "*"); | ||
} | ||
|
||
export default isIndentableBlockComment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{{{{{{{ | ||
o={ | ||
/** | ||
* A | ||
*//** | ||
* B | ||
*/ | ||
|
||
} | ||
}}}}}}} |
Oops, something went wrong.