Skip to content

Commit 5c5884c

Browse files
authored
hotfix: type and build fixes (#177)
1 parent ba071f5 commit 5c5884c

File tree

5 files changed

+70
-62
lines changed

5 files changed

+70
-62
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Commonly ignored Node.js files
1+
# Vendor Folders
22
node_modules
33
npm-debug.log
4-
.npm
5-
.env.*
4+
5+
# Default Output Directory
6+
out

src/generators/legacy-html-all/index.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default {
9999
const minified = await minify(generatedAllTemplate, {
100100
collapseWhitespace: true,
101101
minifyJS: true,
102+
minifyCSS: true,
102103
});
103104

104105
if (output) {

src/generators/legacy-html/index.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export default {
160160
const minified = await minify(result, {
161161
collapseWhitespace: true,
162162
minifyJS: true,
163+
minifyCSS: true,
163164
});
164165

165166
await writeFile(join(output, `${node.api}.html`), minified);

src/generators/legacy-html/utils/buildDropdowns.mjs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
'use strict';
22

3-
import { coerce, major } from 'semver';
3+
import { major } from 'semver';
44

5-
import { getVersionFromSemVer } from '../../../utils/generators.mjs';
5+
import {
6+
coerceSemVer,
7+
getVersionFromSemVer,
8+
} from '../../../utils/generators.mjs';
69

710
import {
811
DOC_API_BASE_URL_VERSION,
@@ -58,7 +61,7 @@ const buildVersions = (api, added, versions) => {
5861
// All Node.js versions that support the current API; If there's no "introduced_at" field,
5962
// we simply show all versions, as we cannot pinpoint the exact version
6063
const compatibleVersions = versions.filter(({ version }) =>
61-
added ? major(version) >= major(coerce(added)) : true
64+
added ? major(version) >= major(coerceSemVer(added)) : true
6265
);
6366

6467
// Parses the SemVer version into something we use for URLs and to display the Node.js version

src/generators/types.d.ts

+58-56
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,71 @@ import type { SemVer } from 'semver';
22
import type availableGenerators from './index.mjs';
33
import type { ApiDocReleaseEntry } from '../types';
44

5-
// All available generators as an inferable type, to allow Generator interfaces
6-
// to be type complete and runtime friendly within `runGenerators`
7-
export type AvailableGenerators = typeof availableGenerators;
5+
declare global {
6+
// All available generators as an inferable type, to allow Generator interfaces
7+
// to be type complete and runtime friendly within `runGenerators`
8+
export type AvailableGenerators = typeof availableGenerators;
89

9-
// This is the runtime config passed to the API doc generators
10-
export interface GeneratorOptions {
11-
// The path used to output generated files, this is to be considered
12-
// the base path that any generator will use for generating files
13-
// This parameter accepts globs but when passed to generators will contain
14-
// the already resolved absolute path to the output folder
15-
output: string;
10+
// This is the runtime config passed to the API doc generators
11+
export interface GeneratorOptions {
12+
// The path used to output generated files, this is to be considered
13+
// the base path that any generator will use for generating files
14+
// This parameter accepts globs but when passed to generators will contain
15+
// the already resolved absolute path to the output folder
16+
output: string;
1617

17-
// A list of generators to be used in the API doc generation process;
18-
// This is considered a "sorted" list of generators, in the sense that
19-
// if the last entry of this list contains a generated value, we will return
20-
// the value of the last generator in the list, if any.
21-
generators: Array<keyof AvailableGenerators>;
18+
// A list of generators to be used in the API doc generation process;
19+
// This is considered a "sorted" list of generators, in the sense that
20+
// if the last entry of this list contains a generated value, we will return
21+
// the value of the last generator in the list, if any.
22+
generators: Array<keyof AvailableGenerators>;
2223

23-
// Target Node.js version for the generation of the API docs
24-
version: SemVer;
24+
// Target Node.js version for the generation of the API docs
25+
version: SemVer;
2526

26-
// A list of all Node.js major versions and their respective release information
27-
releases: Array<ApiDocReleaseEntry>;
28-
}
27+
// A list of all Node.js major versions and their respective release information
28+
releases: Array<ApiDocReleaseEntry>;
29+
}
2930

30-
export interface GeneratorMetadata<I extends any, O extends any> {
31-
// The name of the Generator. Must match the Key in the AvailableGenerators
32-
name: keyof AvailableGenerators;
31+
export interface GeneratorMetadata<I extends any, O extends any> {
32+
// The name of the Generator. Must match the Key in the AvailableGenerators
33+
name: keyof AvailableGenerators;
3334

34-
version: string;
35+
version: string;
3536

36-
description: string;
37+
description: string;
3738

38-
/**
39-
* The immediate generator that this generator depends on.
40-
* For example, the `html` generator depends on the `react` generator.
41-
*
42-
* If a given generator has no "before" generator, it will be considered a top-level
43-
* generator, and run in parallel.
44-
*
45-
* Assume you pass to the `createGenerator`: ['json', 'html'] as the generators,
46-
* this means both the 'json' and the 'html' generators will be executed and generate their
47-
* own outputs in parallel. If the 'html' generator depends on the 'react' generator, then
48-
* the 'react' generator will be executed first, then the 'html' generator.
49-
*
50-
* But both 'json' and 'html' generators will be executed in parallel.
51-
*
52-
* If you pass `createGenerator` with ['react', 'html'], the 'react' generator will be executed first,
53-
* as it is a top level generator and then the 'html' generator would be executed after the 'react' generator.
54-
*
55-
* The 'ast' generator is the top-level parser, and if 'ast' is passed to `dependsOn`, then the generator
56-
* will be marked as a top-level generator.
57-
*/
58-
dependsOn: keyof AvailableGenerators | 'ast';
39+
/**
40+
* The immediate generator that this generator depends on.
41+
* For example, the `html` generator depends on the `react` generator.
42+
*
43+
* If a given generator has no "before" generator, it will be considered a top-level
44+
* generator, and run in parallel.
45+
*
46+
* Assume you pass to the `createGenerator`: ['json', 'html'] as the generators,
47+
* this means both the 'json' and the 'html' generators will be executed and generate their
48+
* own outputs in parallel. If the 'html' generator depends on the 'react' generator, then
49+
* the 'react' generator will be executed first, then the 'html' generator.
50+
*
51+
* But both 'json' and 'html' generators will be executed in parallel.
52+
*
53+
* If you pass `createGenerator` with ['react', 'html'], the 'react' generator will be executed first,
54+
* as it is a top level generator and then the 'html' generator would be executed after the 'react' generator.
55+
*
56+
* The 'ast' generator is the top-level parser, and if 'ast' is passed to `dependsOn`, then the generator
57+
* will be marked as a top-level generator.
58+
*/
59+
dependsOn: keyof AvailableGenerators | 'ast';
5960

60-
/**
61-
* Generators are abstract and the different generators have different sort of inputs and outputs.
62-
* For example, a MDX generator would take the raw AST and output MDX with React Components;
63-
* Whereas a JSON generator would take the raw AST and output JSON;
64-
* Then a React generator could receive either the raw AST or the MDX output and output React Components.
65-
* (depending if they support such I/O)
66-
*
67-
* Hence you can combine different generators to achieve different outputs.
68-
*/
69-
generate: (input: I, options: Partial<GeneratorOptions>) => Promise<O>;
61+
/**
62+
* Generators are abstract and the different generators have different sort of inputs and outputs.
63+
* For example, a MDX generator would take the raw AST and output MDX with React Components;
64+
* Whereas a JSON generator would take the raw AST and output JSON;
65+
* Then a React generator could receive either the raw AST or the MDX output and output React Components.
66+
* (depending if they support such I/O)
67+
*
68+
* Hence you can combine different generators to achieve different outputs.
69+
*/
70+
generate: (input: I, options: Partial<GeneratorOptions>) => Promise<O>;
71+
}
7072
}

0 commit comments

Comments
 (0)