Skip to content

Commit

Permalink
fix: preserve newlines in markdown lists (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Mar 12, 2021
1 parent 5b34a49 commit 546a12e
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 310 deletions.
2 changes: 1 addition & 1 deletion src/AnnotationsReader/ExtendedAnnotationsReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ExtendedAnnotationsReader extends BasicAnnotationsReader {

return {
description: comments
.map((comment) => comment.text.replace(/\r/g, "").replace(/(?<=[^\n])\n(?=[^\n])/g, " "))
.map((comment) => comment.text.replace(/\r/g, "").replace(/(?<=[^\n])\n(?=[^\n*-])/g, " "))
.join(" "),
};
}
Expand Down
4 changes: 4 additions & 0 deletions test/config/jsdoc-complex-extended/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export interface MyObject {
*
* The type of this field is integer.
*
* This is of type
* - integer
* - number
*
* @title Number field title
* @exclusiveMaximum 10
* @multipleOf 3
Expand Down
2 changes: 1 addition & 1 deletion test/config/jsdoc-complex-extended/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"numberValue": {
"type": "integer",
"title": "Number field title",
"description": "This field is of integer type. Integer!\n\nThe type of this field is integer.",
"description": "This field is of integer type. Integer!\n\nThe type of this field is integer.\n\nThis is of type\n- integer\n- number",
"exclusiveMaximum": 10,
"multipleOf": 3
},
Expand Down
13 changes: 5 additions & 8 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,16 @@ export function assertValidSchema(
}

const generator = createGenerator(config);

const schema = generator.createSchema(type);
const expected: any = JSON.parse(readFileSync(resolve(`${basePath}/${relativePath}/schema.json`), "utf8"));
const actual: any = JSON.parse(JSON.stringify(schema));
const schemaFile = resolve(`${basePath}/${relativePath}/schema.json`);

if (process.env.UPDATE_SCHEMA) {
writeFileSync(
resolve(`${basePath}/${relativePath}/schema.json`),
stringify(schema, { space: 2 }) + "\n",
"utf8"
);
writeFileSync(schemaFile, stringify(schema, { space: 2 }) + "\n", "utf8");
}

const expected: any = JSON.parse(readFileSync(schemaFile, "utf8"));
const actual: any = JSON.parse(JSON.stringify(schema));

expect(typeof actual).toBe("object");
expect(actual).toEqual(expected);

Expand Down
5 changes: 3 additions & 2 deletions test/vega-lite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ describe("vega-lite", () => {

const generator = createGenerator(config);
const schema = generator.createSchema(type);
const schemaFile = resolve("test/vega-lite/schema.json");

if (process.env.UPDATE_SCHEMA) {
writeFileSync(resolve("test/vega-lite/schema.json"), stringify(schema, { space: 2 }) + "\n", "utf8");
writeFileSync(schemaFile, stringify(schema, { space: 2 }) + "\n", "utf8");
}

const vegaLiteSchema = JSON.parse(readFileSync(resolve("test/vega-lite/schema.json"), "utf8"));
const vegaLiteSchema = JSON.parse(readFileSync(schemaFile, "utf8"));

expect(schema).toEqual(vegaLiteSchema);
});
Expand Down
Loading

0 comments on commit 546a12e

Please sign in to comment.