Skip to content

refactor: split build-docs.js into focused lib modules#2235

Merged
pelikhan merged 2 commits into
mainfrom
copilot/split-builddocs-js
Jul 27, 2026
Merged

refactor: split build-docs.js into focused lib modules#2235
pelikhan merged 2 commits into
mainfrom
copilot/split-builddocs-js

Conversation

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

scripts/build-docs.js was 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, addExternalLinkTargetAttrs
  • scripts/lib/marked-setup.js — all marked.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.jsgenerateAlertsCss(), generateHljsCss(), generateDocsCss()
  • scripts/lib/page-template.jsgeneratePage(htmlContent, workshopMenu)
  • scripts/build-docs.js — trimmed to ~200-line orchestrator: set up plugins, build content, copy assets, write output

No logic changes; all 8 existing tests pass.

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 AI requested a review from pelikhan July 27, 2026 07:26
Comment thread scripts/lib/docs-css.js
@@ -0,0 +1,1231 @@
'use strict';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot split this file in .css files as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. The CSS template literals have been extracted into two standalone source files:

  • scripts/lib/alerts.css — alert callout styles
  • scripts/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>
Copilot AI requested a review from pelikhan July 27, 2026 07:35
@pelikhan
pelikhan marked this pull request as ready for review July 27, 2026 07:36
@pelikhan
pelikhan merged commit 6b5c4d8 into main Jul 27, 2026
@pelikhan
pelikhan deleted the copilot/split-builddocs-js branch July 27, 2026 07:36
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.

2 participants