Skip to content

Commit a5c9e8d

Browse files
committed
make tsc configurable
1 parent e7fe055 commit a5c9e8d

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@
100100
}
101101
},
102102
"$ref": "#/$defs/ConfigurationSchema"
103-
}
103+
}

src/Configuration.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ export const ConfigurationSchema = Schema.Struct({
7272
description: "Whether or not @since tags for each module export should be required.",
7373
default: true
7474
}),
75+
tscExecutable: Schema.optional(Schema.String).annotations({
76+
description:
77+
"The path to the TypeScript compiler executable that docgen should use when invoking the compiler programmatically.",
78+
default: "tsc"
79+
}),
80+
runExamples: Schema.optional(Schema.Boolean).annotations({
81+
description:
82+
"Whether or not docgen should attempt to run example code snippets and include the output in the generated documentation.",
83+
default: false
84+
}),
7585
exclude: Schema.optional(Schema.Array(Schema.String)).annotations({
7686
description: "An array of glob strings specifying files that should be excluded from the documentation.",
7787
default: []
@@ -101,6 +111,7 @@ export interface ConfigurationShape {
101111
readonly enforceDescriptions: boolean
102112
readonly enforceExamples: boolean
103113
readonly enforceVersion: boolean
114+
readonly tscExecutable: string
104115
readonly runExamples: boolean
105116
readonly exclude: ReadonlyArray<string>
106117
readonly parseCompilerOptions: Record<string, unknown>
@@ -294,6 +305,16 @@ export const load = (args: {
294305
Option.getOrElse(() => args.outDir)
295306
)
296307

308+
const runExamples = config.pipe(
309+
Option.flatMapNullable((config) => config.runExamples),
310+
Option.getOrElse(() => args.runExamples)
311+
)
312+
313+
const tscExecutable = config.pipe(
314+
Option.flatMapNullable((config) => config.tscExecutable),
315+
Option.getOrElse(() => "tsc")
316+
)
317+
297318
return Configuration.of({
298319
...args,
299320
srcDir,
@@ -303,7 +324,9 @@ export const load = (args: {
303324
srcLink,
304325
exclude,
305326
examplesCompilerOptions,
306-
parseCompilerOptions
327+
parseCompilerOptions,
328+
runExamples,
329+
tscExecutable
307330
})
308331
})
309332

0 commit comments

Comments
 (0)