diff --git a/.gitignore b/.gitignore index 1dc047ad..ff95866d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -# Commonly ignored Node.js files +# Vendor Folders node_modules npm-debug.log -.npm -.env.* + +# Default Output Directory +out diff --git a/src/generators/legacy-html-all/index.mjs b/src/generators/legacy-html-all/index.mjs index 13607b4d..a2abdb2e 100644 --- a/src/generators/legacy-html-all/index.mjs +++ b/src/generators/legacy-html-all/index.mjs @@ -99,6 +99,7 @@ export default { const minified = await minify(generatedAllTemplate, { collapseWhitespace: true, minifyJS: true, + minifyCSS: true, }); if (output) { diff --git a/src/generators/legacy-html/index.mjs b/src/generators/legacy-html/index.mjs index 5bad9d01..33358c33 100644 --- a/src/generators/legacy-html/index.mjs +++ b/src/generators/legacy-html/index.mjs @@ -160,6 +160,7 @@ export default { const minified = await minify(result, { collapseWhitespace: true, minifyJS: true, + minifyCSS: true, }); await writeFile(join(output, `${node.api}.html`), minified); diff --git a/src/generators/legacy-html/utils/buildDropdowns.mjs b/src/generators/legacy-html/utils/buildDropdowns.mjs index 8b769ed1..0ec0d879 100644 --- a/src/generators/legacy-html/utils/buildDropdowns.mjs +++ b/src/generators/legacy-html/utils/buildDropdowns.mjs @@ -1,8 +1,11 @@ 'use strict'; -import { coerce, major } from 'semver'; +import { major } from 'semver'; -import { getVersionFromSemVer } from '../../../utils/generators.mjs'; +import { + coerceSemVer, + getVersionFromSemVer, +} from '../../../utils/generators.mjs'; import { DOC_API_BASE_URL_VERSION, @@ -58,7 +61,7 @@ const buildVersions = (api, added, versions) => { // All Node.js versions that support the current API; If there's no "introduced_at" field, // we simply show all versions, as we cannot pinpoint the exact version const compatibleVersions = versions.filter(({ version }) => - added ? major(version) >= major(coerce(added)) : true + added ? major(version) >= major(coerceSemVer(added)) : true ); // Parses the SemVer version into something we use for URLs and to display the Node.js version diff --git a/src/generators/types.d.ts b/src/generators/types.d.ts index bbeaaf0b..348ceed4 100644 --- a/src/generators/types.d.ts +++ b/src/generators/types.d.ts @@ -2,69 +2,71 @@ import type { SemVer } from 'semver'; import type availableGenerators from './index.mjs'; import type { ApiDocReleaseEntry } from '../types'; -// All available generators as an inferable type, to allow Generator interfaces -// to be type complete and runtime friendly within `runGenerators` -export type AvailableGenerators = typeof availableGenerators; +declare global { + // All available generators as an inferable type, to allow Generator interfaces + // to be type complete and runtime friendly within `runGenerators` + export type AvailableGenerators = typeof availableGenerators; -// This is the runtime config passed to the API doc generators -export interface GeneratorOptions { - // The path used to output generated files, this is to be considered - // the base path that any generator will use for generating files - // This parameter accepts globs but when passed to generators will contain - // the already resolved absolute path to the output folder - output: string; + // This is the runtime config passed to the API doc generators + export interface GeneratorOptions { + // The path used to output generated files, this is to be considered + // the base path that any generator will use for generating files + // This parameter accepts globs but when passed to generators will contain + // the already resolved absolute path to the output folder + output: string; - // A list of generators to be used in the API doc generation process; - // This is considered a "sorted" list of generators, in the sense that - // if the last entry of this list contains a generated value, we will return - // the value of the last generator in the list, if any. - generators: Array; + // A list of generators to be used in the API doc generation process; + // This is considered a "sorted" list of generators, in the sense that + // if the last entry of this list contains a generated value, we will return + // the value of the last generator in the list, if any. + generators: Array; - // Target Node.js version for the generation of the API docs - version: SemVer; + // Target Node.js version for the generation of the API docs + version: SemVer; - // A list of all Node.js major versions and their respective release information - releases: Array; -} + // A list of all Node.js major versions and their respective release information + releases: Array; + } -export interface GeneratorMetadata { - // The name of the Generator. Must match the Key in the AvailableGenerators - name: keyof AvailableGenerators; + export interface GeneratorMetadata { + // The name of the Generator. Must match the Key in the AvailableGenerators + name: keyof AvailableGenerators; - version: string; + version: string; - description: string; + description: string; - /** - * The immediate generator that this generator depends on. - * For example, the `html` generator depends on the `react` generator. - * - * If a given generator has no "before" generator, it will be considered a top-level - * generator, and run in parallel. - * - * Assume you pass to the `createGenerator`: ['json', 'html'] as the generators, - * this means both the 'json' and the 'html' generators will be executed and generate their - * own outputs in parallel. If the 'html' generator depends on the 'react' generator, then - * the 'react' generator will be executed first, then the 'html' generator. - * - * But both 'json' and 'html' generators will be executed in parallel. - * - * If you pass `createGenerator` with ['react', 'html'], the 'react' generator will be executed first, - * as it is a top level generator and then the 'html' generator would be executed after the 'react' generator. - * - * The 'ast' generator is the top-level parser, and if 'ast' is passed to `dependsOn`, then the generator - * will be marked as a top-level generator. - */ - dependsOn: keyof AvailableGenerators | 'ast'; + /** + * The immediate generator that this generator depends on. + * For example, the `html` generator depends on the `react` generator. + * + * If a given generator has no "before" generator, it will be considered a top-level + * generator, and run in parallel. + * + * Assume you pass to the `createGenerator`: ['json', 'html'] as the generators, + * this means both the 'json' and the 'html' generators will be executed and generate their + * own outputs in parallel. If the 'html' generator depends on the 'react' generator, then + * the 'react' generator will be executed first, then the 'html' generator. + * + * But both 'json' and 'html' generators will be executed in parallel. + * + * If you pass `createGenerator` with ['react', 'html'], the 'react' generator will be executed first, + * as it is a top level generator and then the 'html' generator would be executed after the 'react' generator. + * + * The 'ast' generator is the top-level parser, and if 'ast' is passed to `dependsOn`, then the generator + * will be marked as a top-level generator. + */ + dependsOn: keyof AvailableGenerators | 'ast'; - /** - * Generators are abstract and the different generators have different sort of inputs and outputs. - * For example, a MDX generator would take the raw AST and output MDX with React Components; - * Whereas a JSON generator would take the raw AST and output JSON; - * Then a React generator could receive either the raw AST or the MDX output and output React Components. - * (depending if they support such I/O) - * - * Hence you can combine different generators to achieve different outputs. - */ - generate: (input: I, options: Partial) => Promise; + /** + * Generators are abstract and the different generators have different sort of inputs and outputs. + * For example, a MDX generator would take the raw AST and output MDX with React Components; + * Whereas a JSON generator would take the raw AST and output JSON; + * Then a React generator could receive either the raw AST or the MDX output and output React Components. + * (depending if they support such I/O) + * + * Hence you can combine different generators to achieve different outputs. + */ + generate: (input: I, options: Partial) => Promise; + } }