Skip to content

Commit 729901f

Browse files
Merge branch 'main' into fix-theme-toggle
2 parents 1ec7936 + 9122dbe commit 729901f

85 files changed

Lines changed: 1597 additions & 1523 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/auto-merge.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Auto-merge PRs
2+
3+
on:
4+
schedule:
5+
- cron: '*/15 * * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
12+
jobs:
13+
auto-merge:
14+
if: github.repository == 'nodejs/doc-kit'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
20+
with:
21+
egress-policy: audit
22+
23+
- uses: nodejs/web-team/actions/auto-merge-prs@b087df186d25f8792fb85cc7794f68718726b8ee
24+
with:
25+
merge-method: queue

docs/generators.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export async function generate(input, worker) {
137137

138138
/**
139139
* Transform metadata entries to MyFormat
140-
* @param {Array<ApiDocMetadataEntry>} entries
140+
* @param {Array<MetadataEntry>} entries
141141
* @param {import('semver').SemVer} version
142142
* @returns {string}
143143
*/
@@ -241,7 +241,7 @@ export async function* generate(input, worker) {
241241
};
242242

243243
// Stream chunks as they complete
244-
for await (const chunkResult of worker.stream(input, input, deps)) {
244+
for await (const chunkResult of worker.stream(input, deps)) {
245245
// Process chunk result if needed
246246
yield chunkResult;
247247
}
@@ -316,7 +316,7 @@ export async function processChunk(fullInput, itemIndices, deps) {
316316
*/
317317
export async function* generate(input, worker) {
318318
// Stream results as workers complete chunks
319-
for await (const chunkResult of worker.stream(input, input, {})) {
319+
for await (const chunkResult of worker.stream(input, {})) {
320320
// Yield immediately - downstream can start processing
321321
yield chunkResult;
322322
}
Lines changed: 38 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@node-core/doc-kit",
33
"type": "module",
4-
"version": "1.0.0",
4+
"version": "1.0.2",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/nodejs/doc-kit.git"

src/__tests__/metadata.test.mjs

Lines changed: 0 additions & 97 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import type { MetadataEntry } from '../metadata/types';
2+
13
export type Generator = GeneratorMetadata<
24
{},
3-
Generate<Array<ApiDocMetadataEntry>, Promise<Record<string, string>>>
5+
Generate<Array<MetadataEntry>, Promise<Record<string, string>>>
46
>;

src/generators/ast-js/generate.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function* generate(_, worker) {
5050

5151
// Parse the Javascript sources into ASTs in parallel using worker threads
5252
// source is both the items list and the fullInput since we use sliceInput
53-
for await (const chunkResult of worker.stream(files, files)) {
53+
for await (const chunkResult of worker.stream(files)) {
5454
yield chunkResult;
5555
}
5656
}

src/generators/ast/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const STABILITY_INDEX_URL = 'documentation.html#stability-index';

src/generators/ast/generate.mjs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import { extname } from 'node:path';
66
import { globSync } from 'tinyglobby';
77
import { VFile } from 'vfile';
88

9+
import { STABILITY_INDEX_URL } from './constants.mjs';
910
import getConfig from '../../utils/configuration/index.mjs';
10-
import createQueries from '../../utils/queries/index.mjs';
11+
import { QUERIES } from '../../utils/queries/index.mjs';
1112
import { getRemark } from '../../utils/remark.mjs';
1213

13-
const { updateStabilityPrefixToLink } = createQueries();
14-
1514
const remarkProcessor = getRemark();
1615

1716
/**
@@ -26,9 +25,14 @@ export async function processChunk(inputSlice, itemIndices) {
2625
const results = [];
2726

2827
for (const path of filePaths) {
29-
const vfile = new VFile({ path, value: await readFile(path, 'utf-8') });
30-
31-
updateStabilityPrefixToLink(vfile);
28+
const content = await readFile(path, 'utf-8');
29+
const vfile = new VFile({
30+
path,
31+
value: content.replace(
32+
QUERIES.stabilityIndexPrefix,
33+
match => `[${match}](${STABILITY_INDEX_URL})`
34+
),
35+
});
3236

3337
results.push({
3438
tree: remarkProcessor.parse(vfile),
@@ -52,7 +56,7 @@ export async function* generate(_, worker) {
5256
);
5357

5458
// Parse markdown files in parallel using worker threads
55-
for await (const chunkResult of worker.stream(files, files)) {
59+
for await (const chunkResult of worker.stream(files)) {
5660
yield chunkResult;
5761
}
5862
}

src/generators/json-simple/generate.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { join } from 'node:path';
66
import { remove } from 'unist-util-remove';
77

88
import getConfig from '../../utils/configuration/index.mjs';
9-
import createQueries from '../../utils/queries/index.mjs';
9+
import { UNIST } from '../../utils/queries/index.mjs';
1010

1111
/**
1212
* Generates the simplified JSON version of the API docs
@@ -16,17 +16,14 @@ import createQueries from '../../utils/queries/index.mjs';
1616
export async function generate(input) {
1717
const config = getConfig('json-simple');
1818

19-
// Iterates the input (ApiDocMetadataEntry) and performs a few changes
19+
// Iterates the input (MetadataEntry) and performs a few changes
2020
const mappedInput = input.map(node => {
2121
// Deep clones the content nodes to avoid affecting upstream nodes
2222
const content = JSON.parse(JSON.stringify(node.content));
2323

2424
// Removes numerous nodes from the content that should not be on the "body"
2525
// of the JSON version of the API docs as they are already represented in the metadata
26-
remove(content, [
27-
createQueries.UNIST.isStabilityNode,
28-
createQueries.UNIST.isHeading,
29-
]);
26+
remove(content, [UNIST.isStabilityNode, UNIST.isHeading]);
3027

3128
return { ...node, content };
3229
});

0 commit comments

Comments
 (0)