Skip to content

Commit

Permalink
chore: added json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Apr 26, 2024
1 parent 108b356 commit a66262c
Show file tree
Hide file tree
Showing 11 changed files with 555 additions and 21 deletions.
1 change: 0 additions & 1 deletion devtools/packages/prebuild-options/tasks/generate-docs.ts
Expand Up @@ -149,7 +149,6 @@ ${presetsJson}
}

if (!option.omitExample) {
//out.push('**Example**');
if (
!option.example &&
option.type === ParameterType.Mixed &&
Expand Down
5 changes: 1 addition & 4 deletions devtools/packages/testing/package.json
Expand Up @@ -5,8 +5,5 @@
"main": "index.ts",
"files": [
"/"
],
"bin": {
"lint-mdx": "lint-mdx.mjs"
}
]
}
24 changes: 24 additions & 0 deletions devtools/scripts/generate-schema/generate-schema.ts
@@ -0,0 +1,24 @@
import * as fs from 'fs';
import * as options from '../../../packages/typedoc-plugin-markdown/src/options/declarations';

main();

async function main() {
const { getSchema } = await import('./get-scheme.cjs');
const schema = await getSchema();

for (const key in schema.properties) {
schema.properties[key].default =
options[key].defaultValue || options[key].defaults;
if (schema.properties[key].required) {
delete schema.properties[key].required;
}
}

if (schema.required) {
delete schema.required;
}

const schemaString = JSON.stringify(schema, null, 2);
fs.writeFileSync('./docs/public/schema.json', schemaString);
}
15 changes: 15 additions & 0 deletions devtools/scripts/generate-schema/get-scheme.cjs
@@ -0,0 +1,15 @@
module.exports = {
getSchema: async () => {
/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
const config = {
path: 'packages/typedoc-plugin-markdown/src/options/option-types.ts',
tsconfig: 'tsconfig.schema.json',
type: 'PluginOptions',
topRef: false,
additionalProperties: true,
};
const { createGenerator } = await import('ts-json-schema-generator');
const schema = createGenerator(config).createSchema(config.type);
return schema;
},
};
8 changes: 4 additions & 4 deletions docs/pages/docs/options.mdx
Expand Up @@ -430,7 +430,7 @@ This option either renders properties for classes and interfaces as a list or in

### enumMembersFormat

<Callout emoji="💡">Specify the render style of enumuration members.</Callout>
<Callout emoji="💡">Specify the render style of enumeration members.</Callout>

> Accepts either `"list"` or `"table"`. Defaults to `"list"`.
Expand All @@ -452,7 +452,7 @@ This option either renders members of enums as a list or in tabular format.

> Accepts either `"list"` or `"table"`. Defaults to `"list"`.
This option either renders type declrations as a list or in tabular format.
This option either renders type declarations as a list or in tabular format.

```json filename="typedoc.json"
{
Expand Down Expand Up @@ -614,7 +614,7 @@ By default all comments written inside JsDoc comments will be passed to the outp

This option will escape angle brackets `<` `>` and curly braces `{` `}` written inside JsDoc comments.

This option would typically be used when source code comes from an external library exposing the following poential issues:
This option would typically be used when source code comes from an external library exposing the following potential issues:

- Comments contain raw tags that should be interpreted as code examples.
- Comments contain invalid syntax that (in the case of MDX) will cause breaking parsing errors.
Expand All @@ -634,7 +634,7 @@ This option would typically be used when source code comes from an external libr

> Accepts a string value. Defaults to `"undefined"`.
This option should be used when parsers requiren a custom anchor prefix.
This option should be used when parsers require a custom anchor prefix.

```json filename="typedoc.json"
{
Expand Down

0 comments on commit a66262c

Please sign in to comment.