nodejs / api-docs-tooling

Node.js's tooling for API generation
https://nodejs.org/api
MIT License
5 stars 5 forks source link

feat: introduce based generator logic #42

Closed ovflowd closed 4 months ago

ovflowd commented 4 months ago

Description

This PR introduces the base generator modules. This should be integrated together with the CLI Pull Request, as the CLI should pass the CLI options to the generators.

Validation

Please verify that the code works and that it is well documented.

Test snippet

import { resolve } from 'node:path';
import createGenerator from './src/generators.mjs';
import createLoader from './src/loader.mjs';
import createParser from './src/parser.mjs';

const { loadFiles } = createLoader();
const { parseApiDocs } = createParser();

const apiDocFiles = loadFiles('../node/doc/api/http.md');

const parsedApiDocs = await parseApiDocs(apiDocFiles);

const { runGenerators } = createGenerator(parsedApiDocs);

await runGenerators({
  generators: ['jsonSimple'],
  output: resolve('.'),
});

Notes: I assume the CLI script will pass the options gotten from the CLI args to the generator; The output property must be a resolved path, and generators the generators they passed on CLI.

ovflowd commented 4 months ago

@canerakdas is this PR good to go? I believe this needs to land first before your CLI PR