Skip to content

Commit e708165

Browse files
authored
Add more compact comment option (#443)
1 parent 14353af commit e708165

File tree

16 files changed

+15630
-47257
lines changed

16 files changed

+15630
-47257
lines changed

examples/stripe-openapi2.ts

Lines changed: 1695 additions & 5157 deletions
Large diffs are not rendered by default.

examples/stripe-openapi3.ts

Lines changed: 4699 additions & 14169 deletions
Large diffs are not rendered by default.

src/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { OpenAPI2, OpenAPI2Reference, OpenAPI2SchemaObject, OpenAPI3 } from "./types";
22

33
export function comment(text: string): string {
4+
const commentText = text.trim();
5+
6+
// if single-line comment
7+
if (commentText.indexOf("\n") === -1) {
8+
return `/** ${commentText} */\n`;
9+
}
10+
11+
// if multi-line comment
412
return `/**
5-
* ${text.trim().replace("\n+$", "").replace(/\n/g, "\n * ")}
13+
* ${commentText.replace(/\n/g, "\n * ")}
614
*/
715
`;
816
}

0 commit comments

Comments
 (0)