feat: automate fetching and sanitization of webpack ecosystem readmes#122
feat: automate fetching and sanitization of webpack ecosystem readmes#122ryzrr wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@avivkeller PTAL! |
There was a problem hiding this comment.
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.mjsto discover repos in thewebpackorg and fetch/write README-based docs. - Wire the new script into
package.jsonnpm scripts (includingbuild). - Ignore generated
pages/loadersandpages/pluginsoutput 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.
| const runLoaders = args.includes('--loaders') || args.length === 0; | ||
| const runPlugins = args.includes('--plugins') || args.length === 0; | ||
|
|
||
| const root = new URL('..', import.meta.url).pathname; |
| console.log(`Failed: ${name} — ${result.status}`); | ||
| continue; | ||
| } | ||
| const content = `---\nlayout: ${layout}\n---\n\n${processContent(result.text)}`; |
There was a problem hiding this comment.
Do we need a custom layout? I think the default layout works fine in this scenario
There was a problem hiding this comment.
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
| const runLoaders = args.includes('--loaders') || args.length === 0; | ||
| const runPlugins = args.includes('--plugins') || args.length === 0; | ||
|
|
||
| const root = new URL('..', import.meta.url).pathname; |
|
Implemented few fixups and additional changes. |
| // 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 : '```' | ||
| ); |
| 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]}:**` | ||
| ); |
Issue Link : #103
Summary
Introduced
fetch-readmes.mjswhich 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