Skip to content

feat: automate fetching and sanitization of webpack ecosystem readmes#122

Open
ryzrr wants to merge 2 commits into
mainfrom
feat/automated-readme-fetcher
Open

feat: automate fetching and sanitization of webpack ecosystem readmes#122
ryzrr wants to merge 2 commits into
mainfrom
feat/automated-readme-fetcher

Conversation

@ryzrr
Copy link
Copy Markdown
Member

@ryzrr ryzrr commented Jun 5, 2026

Issue Link : #103

Summary
Introduced fetch-readmes.mjs which fetches the readme of all loaders and plugins present in the webpack org and passes the md file to pipeline to generate the documentation.

What kind of change does this PR introduce?
New Feature (Build/Automation Script).

Did you add tests for your changes?
NO

Does this PR introduce a breaking change?
NO

If relevant, what needs to be documented once your changes are merged or what have you already documented?
NA

Use of AI
Yes, for testing and refinement of the regex and sanitization logic

Copilot AI review requested due to automatic review settings June 5, 2026 14:55
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-doc-kit Ready Ready Preview, Comment Jun 6, 2026 4:42pm

Request Review

@ryzrr
Copy link
Copy Markdown
Member Author

ryzrr commented Jun 5, 2026

@avivkeller PTAL!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an automation script to pull README content from webpack/* loader and plugin repositories, lightly sanitize/normalize it, and emit Markdown pages that can be consumed by the existing doc generation pipeline.

Changes:

  • Introduce scripts/fetch-readmes.mjs to discover repos in the webpack org and fetch/write README-based docs.
  • Wire the new script into package.json npm scripts (including build).
  • Ignore generated pages/loaders and pages/plugins output directories.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/fetch-readmes.mjs New GitHub API fetch + README sanitization + page generation script for loaders/plugins.
package.json Adds build targets for fetching readmes and runs them as part of npm run build.
.gitignore Ignores generated loaders/plugins pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/fetch-readmes.mjs
Comment thread scripts/fetch-readmes.mjs
Comment thread scripts/fetch-readmes.mjs Outdated
const runLoaders = args.includes('--loaders') || args.length === 0;
const runPlugins = args.includes('--plugins') || args.length === 0;

const root = new URL('..', import.meta.url).pathname;
Comment thread package.json
Comment thread scripts/fetch-readmes.mjs
Comment thread scripts/fetch-readmes.mjs
Comment thread scripts/fetch-readmes.mjs
Comment thread scripts/fetch-readmes.mjs Outdated
console.log(`Failed: ${name} — ${result.status}`);
continue;
}
const content = `---\nlayout: ${layout}\n---\n\n${processContent(result.text)}`;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a custom layout? I think the default layout works fine in this scenario

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the default would work too , actually i thought that some custom component would be required for site.json ,that's why i putted it . I’ll drop the frontmatter injection entirely

Comment thread scripts/fetch-readmes.mjs Outdated
const runLoaders = args.includes('--loaders') || args.length === 0;
const runPlugins = args.includes('--plugins') || args.length === 0;

const root = new URL('..', import.meta.url).pathname;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import.meta.dirname?

Comment thread scripts/fetch-readmes.mjs
@ryzrr
Copy link
Copy Markdown
Member Author

ryzrr commented Jun 6, 2026

Implemented few fixups and additional changes.

Comment thread scripts/fetch-readmes.mjs
Comment on lines +61 to +107
// TODO: remove this allowlist once Shiki silently skips unknown languages instead of build errors.
const SUPPORTED_LANGS = new Set([
'bash',
'c',
'c++',
'cjs',
'coffee',
'coffeescript',
'console',
'cpp',
'diff',
'docker',
'dockerfile',
'glsl',
'gql',
'graphql',
'http',
'ini',
'java',
'javascript',
'js',
'json',
'jsx',
'mjs',
'powershell',
'ps',
'ps1',
'regex',
'regexp',
'sh',
'shell',
'shellscript',
'shellsession',
'sql',
'ts',
'tsx',
'typescript',
'xml',
'yaml',
'yml',
'zsh',
]);

const sanitizeCodeFences = content =>
content.replace(/^```([a-zA-Z0-9_+-]+)\b/gm, (match, lang) =>
SUPPORTED_LANGS.has(lang.toLowerCase()) ? match : '```'
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread scripts/fetch-readmes.mjs
Comment on lines +110 to +124
const GFM_ALERT_LABELS = {
NOTE: 'Note',
TIP: 'Tip',
IMPORTANT: 'Important',
WARNING: 'Warning',
CAUTION: 'Caution',
};
const GFM_ALERT_RE =
/^([ \t]*>[ \t]*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*$/gim;

const transformGfmAlerts = content =>
content.replace(
GFM_ALERT_RE,
(_, prefix, type) => `${prefix}**${GFM_ALERT_LABELS[type]}:**`
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants