Skip to content

Commit

Permalink
Merge pull request #23530 from hide212131/fix-multi-line-javadoc-comment
Browse files Browse the repository at this point in the history
fix jdl multi-line javadoc issue
  • Loading branch information
DanielFran authored Sep 16, 2023
2 parents f21f0cb + 77bea9e commit b68e3d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generators/server/support/doc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const formatDocAsJavaDoc = (text, indentSize = 0) => {
}
text = escapeDoubleQuotes(text);
const indent = ' '.repeat(indentSize);
const rows = ['/**', ...text.split('/n').map(row => ` * ${row}`), ' */'].map(row => `${indent}${row}`);
const rows = ['/**', ...text.split('\\n').map(row => ` * ${row}`), ' */'].map(row => `${indent}${row}`);
return rows.join('\n');
};

Expand Down
6 changes: 6 additions & 0 deletions generators/server/support/doc.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ describe('generator - server - support - doc', () => {
expect(formatDocAsJavaDoc('Comment="KO"', 1)).toBe(' /**\n * Comment=\\"KO\\"\n */');
});
});
describe('when passing a comment with newlines', () => {
it('formats the comment correctly with line breaks', () => {
const comment = 'This is the first line.\\nAnd this is the second.';
expect(formatDocAsJavaDoc(comment, 1)).toBe(' /**\n * This is the first line.\n * And this is the second.\n */');
});
});
});

describe('formatDocAsApiDescription', () => {
Expand Down

0 comments on commit b68e3d4

Please sign in to comment.