Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4f650bd
feat(progress-bar): setup basic
AugustinMauroy Sep 11, 2024
a3e7623
test: progress-bar
AugustinMauroy Sep 11, 2024
b96cfd0
fix: code style
AugustinMauroy Sep 12, 2024
9180963
fix: code style
AugustinMauroy Sep 12, 2024
3d1760f
fix: code style
AugustinMauroy Sep 12, 2024
5e879ff
fix + update
AugustinMauroy Oct 14, 2024
6297b0d
fix: codespell
AugustinMauroy Oct 14, 2024
9e75a18
wip
AugustinMauroy Oct 22, 2024
2cfc4e1
Merge branch 'main' into feat(progress-bar)
AugustinMauroy Oct 22, 2024
4701dcb
remove
AugustinMauroy Oct 22, 2024
2dbc286
add withe-spaces
AugustinMauroy Nov 18, 2024
aa799c5
remove useless await
AugustinMauroy Nov 18, 2024
62f3486
WIP(spinner)
AugustinMauroy Dec 22, 2024
076815d
use clack
AugustinMauroy Dec 22, 2024
c64aa3e
Merge branch 'main' into feat(progress-bar)
AugustinMauroy Jan 19, 2025
5c5884c
hotfix: type and build fixes (#177)
ovflowd Jan 20, 2025
8ec63c9
refactor(addon-verify): some improvements (#175)
araujogui Jan 20, 2025
cfee887
hotfix: correctly use dedent
ovflowd Jan 20, 2025
1da598d
doc: improve accessibility of expandable lists
aduh95 Jan 26, 2025
a4ea425
doc: add "Skip to content" button
aduh95 Jan 26, 2025
cb66e80
doc: fix styles of the expandable TOC
aduh95 Jan 26, 2025
6c234f6
meta: bump actions/upload-artifact from 4.5.0 to 4.6.0 (#189)
dependabot[bot] Feb 2, 2025
bf1fe58
meta: bump actions/setup-node from 4.1.0 to 4.2.0 (#188)
dependabot[bot] Feb 2, 2025
ef6f16f
meta: bump step-security/harden-runner from 2.10.2 to 2.10.4 (#187)
dependabot[bot] Feb 2, 2025
4019ac0
meta: bump github/codeql-action from 3.28.0 to 3.28.8 (#186)
dependabot[bot] Feb 2, 2025
9091505
meta: bump lint-staged from 15.3.0 to 15.4.3 (#185)
dependabot[bot] Feb 2, 2025
5321cb9
meta: bump glob from 11.0.0 to 11.0.1 (#184)
dependabot[bot] Feb 2, 2025
5751332
meta: bump semver from 7.6.3 to 7.7.0 (#183)
dependabot[bot] Feb 2, 2025
92b7f03
meta: bump commander from 13.0.0 to 13.1.0 (#182)
dependabot[bot] Feb 2, 2025
8e3d276
meta: bump @types/node from 22.10.3 to 22.13.0 (#180)
dependabot[bot] Feb 2, 2025
653672e
meta: bump shiki from 1.24.4 to 2.2.0 (#181)
dependabot[bot] Feb 2, 2025
1c86005
meta: bump the lint group with 4 updates (#179)
dependabot[bot] Feb 2, 2025
3452cf2
doc: make MDN links to global classes more consistent (#190)
aduh95 Feb 7, 2025
11a7953
feat apilinks.json generator (#153)
flakey5 Feb 11, 2025
20d1cac
meta: bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#202)
dependabot[bot] Mar 1, 2025
9a3c811
meta: bump step-security/harden-runner from 2.10.4 to 2.11.0 (#201)
dependabot[bot] Mar 1, 2025
546f284
meta: bump actions/upload-artifact from 4.6.0 to 4.6.1 (#200)
dependabot[bot] Mar 1, 2025
1206535
meta: bump github/codeql-action from 3.28.8 to 3.28.10 (#199)
dependabot[bot] Mar 1, 2025
c6c1408
meta: bump hastscript from 9.0.0 to 9.0.1 (#198)
dependabot[bot] Mar 1, 2025
0a05afb
meta: bump semver from 7.7.0 to 7.7.1 (#197)
dependabot[bot] Mar 1, 2025
d162314
meta: bump remark-gfm from 4.0.0 to 4.0.1 (#195)
dependabot[bot] Mar 1, 2025
d896c77
meta: bump @types/node from 22.13.0 to 22.13.8 (#194)
dependabot[bot] Mar 1, 2025
588d8f2
meta: bump the lint group with 4 updates (#193)
dependabot[bot] Mar 1, 2025
c26adb4
meta: bump prettier from 3.4.2 to 3.5.2 in the fromat group (#192)
dependabot[bot] Mar 1, 2025
adefb11
workflow(pr): improve (#203)
AugustinMauroy Mar 2, 2025
4eb8286
feat(progress-bar): setup basic
AugustinMauroy Sep 11, 2024
984022e
test: progress-bar
AugustinMauroy Sep 11, 2024
766bae6
fix: code style
AugustinMauroy Sep 12, 2024
5479cab
fix: code style
AugustinMauroy Sep 12, 2024
2769920
fix: code style
AugustinMauroy Sep 12, 2024
6b1308d
fix + update
AugustinMauroy Oct 14, 2024
47c2765
fix: codespell
AugustinMauroy Oct 14, 2024
3a00ed5
wip
AugustinMauroy Oct 22, 2024
0c22339
remove
AugustinMauroy Oct 22, 2024
89228fd
add withe-spaces
AugustinMauroy Nov 18, 2024
f311669
remove useless await
AugustinMauroy Nov 18, 2024
9124051
WIP(spinner)
AugustinMauroy Dec 22, 2024
89e377e
use clack
AugustinMauroy Dec 22, 2024
b45d230
Merge branch 'feat(progress-bar)' of https://github.com/nodejs/api-do…
AugustinMauroy Mar 4, 2025
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
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"prettier": "3.3.3"
},
"dependencies": {
"cli-progress": "^3.12.0",
"commander": "^12.1.0",
"github-slugger": "^2.0.0",
"glob": "^11.0.0",
Expand Down
11 changes: 11 additions & 0 deletions src/loader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { extname } from 'node:path';
import { globSync } from 'glob';
import { VFile } from 'vfile';

import createProgressBar from './utils/progressBar.mjs';

/**
* This method creates a simple abstract "Loader", which technically
* could be used for different things, but here we want to use it to load
Expand All @@ -26,8 +28,17 @@ const createLoader = () => {
filePath => extname(filePath) === '.md'
);

const progressBar = createProgressBar('Loading files');
progressBar.start(resolvedFiles.length, 0);
Comment thread
AugustinMauroy marked this conversation as resolved.
Outdated

return resolvedFiles.map(async filePath => {
const fileContents = await readFile(filePath, 'utf-8');
progressBar.increment();
// normally we stop the progress bar when the loop is done
// but here we return the loop so we need to stop it when the last file is loaded
if (progressBar.value === progressBar.total) {
Comment thread
ovflowd marked this conversation as resolved.
Outdated
progressBar.stop();
}

return new VFile({ path: filePath, value: fileContents });
});
Expand Down
14 changes: 13 additions & 1 deletion src/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import createQueries from './queries.mjs';

import { getRemark } from './utils/remark.mjs';
import { createNodeSlugger } from './utils/slugger.mjs';
import createProgressBar from './utils/progressBar.mjs';

/**
* Creates an API doc parser for a given Markdown API doc file
Expand Down Expand Up @@ -177,7 +178,18 @@ const createParser = () => {
const parseApiDocs = async apiDocs => {
// We do a Promise.all, to ensure that each API doc is resolved asynchronously
// but all need to be resolved first before we return the result to the caller
const resolvedApiDocEntries = await Promise.all(apiDocs.map(parseApiDoc));

const progressBar = createProgressBar('Parsing API Docs');
progressBar.start(apiDocs.length, 0);

const resolvedApiDocEntries = await Promise.all(
apiDocs.map(async apiDoc => {
progressBar.increment();
return await parseApiDoc(apiDoc);
Comment thread
AugustinMauroy marked this conversation as resolved.
Outdated
})
);

progressBar.stop();

return resolvedApiDocEntries.flat();
};
Expand Down
8 changes: 8 additions & 0 deletions src/utils/generators.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { coerce } from 'semver';

import createProgressBar from './progressBar.mjs';

/**
* Groups all the API metadata nodes by module (`api` property) so that we can process each different file
* based on the module it belongs to.
Expand All @@ -12,14 +14,20 @@ export const groupNodesByModule = nodes => {
/** @type {Map<string, Array<ApiDocMetadataEntry>>} */
const groupedNodes = new Map();

const progressBar = createProgressBar(groupNodesByModule.name);
progressBar.start(nodes.length, 0);
Comment thread
ovflowd marked this conversation as resolved.
Outdated

for (const node of nodes) {
if (!groupedNodes.has(node.api)) {
groupedNodes.set(node.api, []);
}

groupedNodes.get(node.api).push(node);
progressBar.increment();
}

progressBar.stop();

return groupedNodes;
};

Expand Down
24 changes: 24 additions & 0 deletions src/utils/progressBar.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { styleText } from 'node:util';

import cliProgress from 'cli-progress';

/**
*
Comment thread
AugustinMauroy marked this conversation as resolved.
Outdated
* Create a progress bar instance
* with our custom format
*
* @param {string} label
* @returns {import('cli-progress').SingleBar}
*/
function createProgressBar(label = '') {
const format = ` ${styleText(['bold', 'green'], '{bar}')} | ${label} {percentage}% | {value}/{total}`;

return new cliProgress.SingleBar({
format,
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true,
});
}

export default createProgressBar;
15 changes: 15 additions & 0 deletions src/utils/tests/progressBar.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import assert from 'node:assert';
import { test } from 'node:test';

import cliProgress from 'cli-progress';

import createProgressBar from '../progressBar.mjs';

/**
* Simple test to unsure that the progress bar is created
* and we assume that it's work with ou style
*/
test('createProgressBar returns an instance of SingleBar', () => {
const bar = createProgressBar();
assert.ok(bar instanceof cliProgress.SingleBar);
});