Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"**/fixtures",
"src/generators/legacy-html/assets",
"src/generators/web/ui",
"**/*.d.ts"
"**/*.d.ts",
"scripts/"
]
}
3 changes: 3 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ jobs:
input: './node/doc/api/*.md'
compare: file-size

- target: json
input: './node/doc/api/*.md'

- target: llms-txt
input: './node/doc/api/*.md'
compare: file-size
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export default defineConfig([
globals: { ...globals.nodeBuiltin },
},
rules: {
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/require-jsdoc': [
Expand Down
111 changes: 101 additions & 10 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"eslint-plugin-jsdoc": "^61.5.0",
"eslint-plugin-react-x": "^2.4.0",
"husky": "^9.1.7",
"json-schema-to-typescript": "^15.0.4",
"jsonschema": "^1.5.0",
"lint-staged": "^16.2.7",
"prettier": "3.7.4"
},
Expand All @@ -57,6 +59,7 @@
"globals": "^16.5.0",
"hast-util-to-string": "^3.0.1",
"hastscript": "^9.0.1",
"jsonc-parser": "^3.3.1",
"lightningcss": "^1.30.2",
"mdast-util-slice-markdown": "^2.0.1",
"piscina": "^5.1.4",
Expand Down
34 changes: 34 additions & 0 deletions scripts/generate-json-types.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

/**
* Generates the typedefs for the JSON generator from the JSON schema
*/

import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';

import { compile } from 'json-schema-to-typescript';
import { parse } from 'jsonc-parser';

const GENERATOR_DIR = join(
import.meta.dirname,
'..',
'src',
'generators',
'json'
);

const SCHEMA_PATH = join(GENERATOR_DIR, 'schema.jsonc');
const TYPES_PATH = join(GENERATOR_DIR, 'generated', 'generated.d.ts');

// Read the contents of the JSON schema
const schemaString = await readFile(SCHEMA_PATH, 'utf8');

// Parse the JSON schema into an object
const schema = await parse(schemaString);

// Compile the JSON schema into TypeScript typedefs
const typeDefs = await compile(schema, 'ApiDocSchema');

// Write the types to the expected output path
await writeFile(TYPES_PATH, typeDefs);
4 changes: 4 additions & 0 deletions src/generators/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import addonVerify from './addon-verify/index.mjs';
import apiLinks from './api-links/index.mjs';
import ast from './ast/index.mjs';
import astJs from './ast-js/index.mjs';
import json from './json/index.mjs';
import jsonAll from './json-all/index.mjs';
import jsonSimple from './json-simple/index.mjs';
import jsxAst from './jsx-ast/index.mjs';
import legacyHtml from './legacy-html/index.mjs';
Expand All @@ -30,6 +32,8 @@ export const publicGenerators = {
'llms-txt': llmsTxt,
sitemap,
web,
json,
'json-all': jsonAll,
};

// These ones are special since they don't produce standard output,
Expand Down
Loading
Loading