Skip to content

Commit

Permalink
fix: long single word in description
Browse files Browse the repository at this point in the history
issue: #94
  • Loading branch information
hosseinmd committed Mar 6, 2021
1 parent 242f23e commit 18ba560
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const stringify = (
tagString += description;
} else {
const [, firstWord] = /^\s*(\S+)/.exec(description) || ["", ""];
if (tagString.length + firstWord.length > printWidth) {
if (
tag !== DESCRIPTION &&
tagString.length + firstWord.length > printWidth
) {
// the tag is already longer than we are allowed to, so let's start at a new line
tagString += "\n " + formatDescription(tag, description, options);
} else {
Expand Down
10 changes: 8 additions & 2 deletions tests/__snapshots__/paragraph.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ exports[`\`#\` in text 1`] = `
"
`;

exports[`Long words 1`] = `
"/**
* 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
*/
"
`;

exports[`New Lines with star 1`] = `
"/**
* Simplifies the token stream to ease the matching with the expected token stream.
Expand Down Expand Up @@ -83,8 +90,7 @@ exports[`Non-english description with dot 1`] = `
*/
/**
*
* Unicode(ユニコード)は、符号化文字集合や文字符号化方式などを定めた、文字コードの業界規格。文字集合(文字セット)が単一の大規模文字セットであること(「Uni」という名はそれに由来する)などが特徴である.
* Unicode(ユニコード)は、符号化文字集合や文字符号化方式などを定めた、文字コードの業界規格。文字集合(文字セット)が単一の大規模文字セットであること(「Uni」という名はそれに由来する)などが特徴である.
*
* @see https://ja.wikipedia.org/wiki/Unicode
*/
Expand Down
16 changes: 16 additions & 0 deletions tests/paragraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,22 @@ test("# in block code", () => {

expect(result1).toMatchSnapshot();
});

test("Long words", () => {
const result2 = subject(
`
/**
* 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
*/
`,
{
jsdocSingleLineComment: false,
},
);

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

/**
* If this is a vertical ScrollView scrolls to the bottom.
* If this is a horizontal ScrollView scrolls to the right.
Expand Down

0 comments on commit 18ba560

Please sign in to comment.