Skip to content

Commit

Permalink
fix: not capitalizing pre formated tags
Browse files Browse the repository at this point in the history
issue: #143
  • Loading branch information
hosseinmd committed Mar 25, 2022
1 parent af1ac33 commit b5beeb7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/descriptionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AllOptions } from "./types";
import { capitalizer, formatCode } from "./utils";
import fromMarkdown from "mdast-util-from-markdown";
import { Root, Content, Link, Image, Text, List } from "mdast";
import { TAGS_PEV_FORMATE_DESCRIPTION } from "./roles";

const TABLE = "2@^5!~#sdE!_TABLE";

Expand Down Expand Up @@ -108,7 +109,12 @@ function formatDescription(
return `\n\n${TABLE}\n\n${_3 ? _3.slice(1) : ""}`;
},
);
if (options.jsdocCapitalizeDescription) text = capitalizer(text);
if (
options.jsdocCapitalizeDescription &&
!TAGS_PEV_FORMATE_DESCRIPTION.includes(tag)
) {
text = capitalizer(text);
}

text = `${tagStringLength ? `${"!".repeat(tagStringLength - 1)}?` : ""}${
text.startsWith("```") ? "\n" : ""
Expand Down Expand Up @@ -267,7 +273,10 @@ function formatDescription(
_paragraph = _paragraph.replace(/\s+/g, " "); // Make single line
if (options.jsdocCapitalizeDescription)
if (
options.jsdocCapitalizeDescription &&
!TAGS_PEV_FORMATE_DESCRIPTION.includes(tag)
)
_paragraph = capitalizer(_paragraph);
if (options.jsdocDescriptionWithDot)
_paragraph = _paragraph.replace(/([\w\p{L}])$/u, "$1."); // Insert dot if needed
Expand Down
5 changes: 5 additions & 0 deletions tests/__snapshots__/main.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ exports[`jsdoc tags 1`] = `
"
`;
exports[`jsdoc tags 2`] = `
"/** @default 'i am a value' i am the description */
"
`;
exports[`non-escapable character 1`] = `
"/**
* \\\\
Expand Down
10 changes: 10 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,16 @@ test("jsdoc tags", () => {
);

expect(result2).toMatchSnapshot();

const result3 = subject(
`
/**
* @default 'i am a value' i am the description
*/
`,
);

expect(result3).toMatchSnapshot();
});

test("example ", () => {
Expand Down

0 comments on commit b5beeb7

Please sign in to comment.