refactor: split build-docs.js into focused lib modules#2235
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
refactor: split build-docs.js into lib modules
refactor: split build-docs.js into focused lib modules
Jul 27, 2026
Copilot created this pull request from a session on behalf of
pelikhan
July 27, 2026 07:26
View session
pelikhan
reviewed
Jul 27, 2026
| @@ -0,0 +1,1231 @@ | |||
| 'use strict'; | |||
Contributor
Author
There was a problem hiding this comment.
Done. The CSS template literals have been extracted into two standalone source files:
scripts/lib/alerts.css— alert callout stylesscripts/lib/docs.css— full workshop SPA styles
docs-css.js now reads them with fs.readFileSync at build time. generateHljsCss() stays in JS since it must compose content from npm packages at runtime. All 8 tests pass (commit refactor: extract CSS template strings into .css source files).
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scripts/build-docs.jswas a 1967-line monolith mixing utility functions, markdown plugin setup, file processing, CSS generation, and the HTML template — making it hard to review diffs or run targeted type checks.Changes
scripts/lib/utils.js— pure helpers:escapeHtml,prefixCssSelectors,flattenTokenText,isExternalWebLink,addExternalLinkTargetAttrsscripts/lib/marked-setup.js— allmarked.use()registrations:setupBasePlugins()(heading anchors, task-list items, alerts, syntax highlighting, code block wrappers) +setupLinkRewriter(sectionIdsByFile)(called after file metadata is available)scripts/lib/workshop.js— file discovery, metadata extraction, navigation rendering,buildWorkshopContent()→{ files, htmlContent, workshopMenu }scripts/lib/docs-css.js—generateAlertsCss(),generateHljsCss(),generateDocsCss()scripts/lib/page-template.js—generatePage(htmlContent, workshopMenu)scripts/build-docs.js— trimmed to ~200-line orchestrator: set up plugins, build content, copy assets, write outputNo logic changes; all 8 existing tests pass.