Skip to content

hotfix: type and build fixes #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Commonly ignored Node.js files
# Vendor Folders
node_modules
npm-debug.log
.npm
.env.*

# Default Output Directory
out
1 change: 1 addition & 0 deletions src/generators/legacy-html-all/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default {
const minified = await minify(generatedAllTemplate, {
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
});

if (output) {
Expand Down
1 change: 1 addition & 0 deletions src/generators/legacy-html/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/generators/legacy-html/utils/buildDropdowns.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
114 changes: 58 additions & 56 deletions src/generators/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<keyof AvailableGenerators>;
// 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<keyof AvailableGenerators>;

// 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<ApiDocReleaseEntry>;
}
// A list of all Node.js major versions and their respective release information
releases: Array<ApiDocReleaseEntry>;
}

export interface GeneratorMetadata<I extends any, O extends any> {
// The name of the Generator. Must match the Key in the AvailableGenerators
name: keyof AvailableGenerators;
export interface GeneratorMetadata<I extends any, O extends any> {
// 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<GeneratorOptions>) => Promise<O>;
/**
* 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<GeneratorOptions>) => Promise<O>;
}
}
Loading