Skip to content

Commit d5930e0

Browse files
cAttteGerrit0
authored andcommitted
feat: use 'pretty' option when generating json
1 parent b3c856e commit d5930e0

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

bin/typedoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ async function run(app) {
6666
}
6767
const json = app.options.getValue("json");
6868
if (json) {
69-
await app.generateJson(project, json);
69+
const pretty = app.options.getValue("pretty");
70+
await app.generateJson(project, json, pretty);
7071
}
7172

7273
if (!out && !json) {
@@ -87,7 +88,8 @@ async function run(app) {
8788
}
8889
const json = app.options.getValue("json");
8990
if (json) {
90-
await app.generateJson(project, json);
91+
const pretty = app.options.getValue("pretty");
92+
await app.generateJson(project, json, pretty);
9193
}
9294

9395
if (!out && !json) {

scripts/rebuild_specs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async function rebuildRendererTest() {
107107
app.options.setValue("entryPoints", app.expandInputFiles([src]));
108108
const project = app.convert();
109109
await app.generateDocs(project, out);
110-
await app.generateJson(project, path.join(out, "specs.json"));
110+
await app.generateJson(project, path.join(out, "specs.json"), true);
111111

112112
/**
113113
* Avoiding sync methods here is... difficult.

src/lib/application.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,14 @@ export class Application extends ChildableComponent<
387387
/**
388388
* Run the converter for the given set of files and write the reflections to a json file.
389389
*
390-
* @param out The path and file name of the target file.
391-
* @returns TRUE if the json file could be written successfully, otherwise FALSE.
390+
* @param out The path and file name of the target file.
391+
* @param format Whether the JSON data should be formatted with tabs.
392+
* @returns Whether the JSON file could be written successfully.
392393
*/
393394
public async generateJson(
394395
project: ProjectReflection,
395-
out: string
396+
out: string,
397+
format = true
396398
): Promise<void> {
397399
out = Path.resolve(out);
398400
const eventData = {
@@ -403,7 +405,9 @@ export class Application extends ChildableComponent<
403405
begin: eventData,
404406
end: eventData,
405407
});
406-
await FS.promises.writeFile(out, JSON.stringify(ser, null, "\t"));
408+
409+
const space = format ? "\t" : "";
410+
await FS.promises.writeFile(out, JSON.stringify(ser, null, space));
407411
this.logger.success("JSON written to %s", out);
408412
}
409413

0 commit comments

Comments
 (0)