Skip to content

Commit

Permalink
fix: new line after item list
Browse files Browse the repository at this point in the history
issue: #206
  • Loading branch information
hosseinmd committed Oct 3, 2023
1 parent cdbf931 commit 98c42fe
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,6 @@ function assignOptionalAndDefaultToName({
const tagDescription = tagMatch?.[4] || "";

if (tagMatch) {
console.log(tagMatch);

type = tagValue;
name = "";
description = tagDescription;
Expand Down
7 changes: 5 additions & 2 deletions src/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const stringify = async (
tsdoc,
useTabs,
tabWidth,
jsdocSeparateTagGroups,
} = options;
const gap = " ".repeat(jsdocSpaces);

Expand Down Expand Up @@ -126,8 +127,6 @@ const stringify = async (
TAGS_PEV_FORMATE_DESCRIPTION.includes(tag) ||
!TAGS_ORDER.includes(tag)
) {
description = description.trimEnd();

// Avoid wrapping
descriptionString = description;
} else {
Expand Down Expand Up @@ -162,6 +161,10 @@ const stringify = async (
}
}

if (jsdocSeparateTagGroups) {
descriptionString = descriptionString.trimEnd();
}

tagString += descriptionString.startsWith("\n")
? descriptionString.replace(/^\n[\s]+\n/g, "\n")
: descriptionString.trimStart();
Expand Down
15 changes: 15 additions & 0 deletions tests/__snapshots__/descriptions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,21 @@ function test(value) {
"
`;
exports[`Reference-style Links 3`] = `
"/**
* Testing docBlocks.
*
* @param ...args Arguments.
*
* @returns Something.
*
* - Note: here is a list item in markdown.
*
* @see https://link.example
*/
"
`;
exports[`code in description 1`] = `
"/**
* \`Touchable\`: Taps done right.
Expand Down
11 changes: 0 additions & 11 deletions tests/__snapshots__/tagGroup.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,3 @@ exports[`space after unknownTag 1`] = `
*/
"
`;
exports[`space between note and see 1`] = `
"/**
* A description.
*
* @notDefinedTag A note.
*
* @see http://acme.com
*/
"
`;
23 changes: 23 additions & 0 deletions tests/descriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,3 +1033,26 @@ test("Reference-style Links ", async () => {

expect(result2).toMatchSnapshot();
});

test("Reference-style Links ", async () => {
const result = await subject(
`
/**
* Testing docBlocks.
*
* @param ...args Arguments.
*
* @returns Something.
*
* - Note: here is a list item in markdown.
*
* @see https://link.example
*/
`,
{
jsdocSeparateTagGroups: true,
},
);

expect(result).toMatchSnapshot();
});

0 comments on commit 98c42fe

Please sign in to comment.