Skip to content

Commit

Permalink
fix: add to dot to non-English descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Feb 13, 2021
1 parent c864ba0 commit 6445702
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/descriptionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function formatDescription(
paragraph = capitalizer(paragraph);
if (options.jsdocDescriptionWithDot)
paragraph = paragraph.replace(
/([\wäöüÄÖÜß])$/g,
/([\w\p{L}])$/u,
"$1.",
); // Insert dot if needed

Expand Down
48 changes: 37 additions & 11 deletions tests/__snapshots__/paragraph.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,21 @@ exports[`\`#\` in text 1`] = `
"
`;

exports[`Germany description with dot 1`] = `
exports[`New Lines with star 1`] = `
"/**
* Simplifies the token stream to ease the matching with the expected token stream.
*
* - Strings are kept as-is
* - In arrays each value is transformed individually
* - Values that are empty (empty arrays or strings only containing whitespace)
*
* @param {TokenStream} tokenStream
* @returns {SimplifiedTokenStream}
*/
"
`;

exports[`Non-english description with dot 1`] = `
"/**
* Wir brauchen hier eine effizientere Lösung. Die generierten Dateien sind zu groß.
*
Expand All @@ -39,19 +53,31 @@ exports[`Germany description with dot 1`] = `
*
* @param a Ssss.
*/
"
`;
exports[`New Lines with star 1`] = `
"/**
* Simplifies the token stream to ease the matching with the expected token stream.
/**
* Unicode est un standard informatique qui permet des échanges de textes dans
* différentes langues, à un niveau mondial. Il est développé par le Consortium
* Unicode, qui vise au codage de texte écrit en donnant à tout caractère de
* n'importe quel système d'écriture un nom et un identifiant numérique, et ce
* de manière unifiée, quels que soient la plate-forme informatique ou le
* logiciel utilisé.
*
* @see https://fr.wikipedia.org/wiki/Unicode
*/
/**
* Юнико́д[1] (чаще всего) или Унико́д[2] (англ. Unicode) — стандарт кодирования
* символов, включающий в себя знаки почти всех письменных языков мира[3]. В
* настоящее время стандарт является преобладающим в Интернете.
*
* - Strings are kept as-is
* - In arrays each value is transformed individually
* - Values that are empty (empty arrays or strings only containing whitespace)
* @see https://ru.wikipedia.org/wiki/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4
*/
/**
*
* @param {TokenStream} tokenStream
* @returns {SimplifiedTokenStream}
* Unicode(ユニコード)は、符号化文字集合や文字符号化方式などを定めた、文字コードの業界規格。文字集合(文字セット)が単一の大規模文字セットであること(「Uni」という名はそれに由来する)などが特徴である.
*
* @see https://ja.wikipedia.org/wiki/Unicode
*/
"
`;
Expand Down
23 changes: 21 additions & 2 deletions tests/paragraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ test("empty lines", () => {
expect(result1).toMatchSnapshot();
});

test("Germany description with dot", () => {
test("Non-english description with dot", () => {
const result = subject(
`/**
Expand All @@ -473,7 +473,26 @@ test("Germany description with dot", () => {
* @param a ssss
*/`,
*/
/**
* Unicode est un standard informatique qui permet des échanges de textes dans différentes langues, à un niveau mondial. Il est développé par le Consortium Unicode, qui vise au codage de texte écrit en donnant à tout caractère de n'importe quel système d'écriture un nom et un identifiant numérique, et ce de manière unifiée, quels que soient la plate-forme informatique ou le logiciel utilisé
*
* @see https://fr.wikipedia.org/wiki/Unicode
*/
/**
* Юнико́д[1] (чаще всего) или Унико́д[2] (англ. Unicode) — стандарт кодирования символов, включающий в себя знаки почти всех письменных языков мира[3]. В настоящее время стандарт является преобладающим в Интернете
*
* @see https://ru.wikipedia.org/wiki/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4
*/
/**
* Unicode(ユニコード)は、符号化文字集合や文字符号化方式などを定めた、文字コードの業界規格。文字集合(文字セット)が単一の大規模文字セットであること(「Uni」という名はそれに由来する)などが特徴である
*
* @see https://ja.wikipedia.org/wiki/Unicode
*/
`,
{
jsdocDescriptionWithDot: true,
},
Expand Down

0 comments on commit 6445702

Please sign in to comment.