-
Notifications
You must be signed in to change notification settings - Fork 10
refactor: split build-docs.js into focused lib modules #2235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* Alert callout styles for GitHub GFM > [!NOTE] / [!TIP] / etc. */ | ||
| .markdown-alert { | ||
| padding: 0.5rem 1rem; | ||
| margin-bottom: 16px; | ||
| border-left: 0.25em solid; | ||
| border-radius: 6px; | ||
| } | ||
| .markdown-alert > :first-child { margin-top: 0; } | ||
| .markdown-alert > :last-child { margin-bottom: 0; } | ||
| .markdown-alert-title { | ||
| display: flex; | ||
| align-items: center; | ||
| font-weight: 600; | ||
| margin-bottom: 4px; | ||
| } | ||
| .markdown-alert-title svg { margin-right: 8px; } | ||
| .markdown-alert-note { | ||
| border-color: var(--borderColor-accent-emphasis, #0969da); | ||
| background-color: var(--bgColor-accent-muted, #ddf4ff); | ||
| } | ||
| .markdown-alert-note .markdown-alert-title { color: var(--fgColor-accent, #0969da); } | ||
| .markdown-alert-tip { | ||
| border-color: var(--borderColor-success-emphasis, #1a7f37); | ||
| background-color: var(--bgColor-success-muted, #dafbe1); | ||
| } | ||
| .markdown-alert-tip .markdown-alert-title { color: var(--fgColor-success, #1a7f37); } | ||
| .markdown-alert-important { | ||
| border-color: var(--borderColor-done-emphasis, #8250df); | ||
| background-color: var(--bgColor-done-muted, #fbefff); | ||
| } | ||
| .markdown-alert-important .markdown-alert-title { color: var(--fgColor-done, #8250df); } | ||
| .markdown-alert-warning { | ||
| border-color: var(--borderColor-attention-emphasis, #9a6700); | ||
| background-color: var(--bgColor-attention-muted, #fff8c5); | ||
| } | ||
| .markdown-alert-warning .markdown-alert-title { color: var(--fgColor-attention, #9a6700); } | ||
| .markdown-alert-caution { | ||
| border-color: var(--borderColor-danger-emphasis, #d1242f); | ||
| background-color: var(--bgColor-danger-muted, #ffebe9); | ||
| } | ||
| .markdown-alert-caution .markdown-alert-title { color: var(--fgColor-danger, #d1242f); } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { prefixCssSelectors } = require('./utils'); | ||
|
|
||
| // Generate alert callout CSS for marked-alert GFM rendering | ||
| function generateAlertsCss() { | ||
| return fs.readFileSync(path.join(__dirname, 'alerts.css'), 'utf8'); | ||
| } | ||
|
|
||
| // Generate highlight.js syntax highlighting CSS (GitHub light + dark themes). | ||
| // The dark theme rules are scoped to the data-color-mode="dark" attribute and | ||
| // to the prefers-color-scheme: dark media query for data-color-mode="auto". | ||
| function generateHljsCss() { | ||
| const hljsStylesDir = path.join(__dirname, '..', '..', 'node_modules', 'highlight.js', 'styles'); | ||
| const hljsLightCss = fs.readFileSync(path.join(hljsStylesDir, 'github.min.css'), 'utf8'); | ||
| const hljsDarkCss = fs.readFileSync(path.join(hljsStylesDir, 'github-dark.min.css'), 'utf8'); | ||
| return [ | ||
| '/* highlight.js \u2013 GitHub light theme (default) */', | ||
| hljsLightCss, | ||
| '', | ||
| '/* highlight.js \u2013 GitHub Dark theme (terminal blocks) */', | ||
| prefixCssSelectors(hljsDarkCss, '.terminal-block'), | ||
| '', | ||
| '/* highlight.js \u2013 GitHub Dark theme (explicit dark mode) */', | ||
| prefixCssSelectors(hljsDarkCss, 'html[data-color-mode="dark"]'), | ||
| '', | ||
| '/* highlight.js \u2013 GitHub Dark theme (system dark preference) */', | ||
| '@media (prefers-color-scheme: dark) {', | ||
| prefixCssSelectors(hljsDarkCss, 'html[data-color-mode="auto"]'), | ||
| '}', | ||
| ].join('\n'); | ||
| } | ||
|
|
||
| // Generate docs CSS \u2013 link discoverability and workshop SPA styles | ||
| function generateDocsCss() { | ||
| return fs.readFileSync(path.join(__dirname, 'docs.css'), 'utf8'); | ||
| } | ||
|
|
||
| module.exports = { generateAlertsCss, generateHljsCss, generateDocsCss }; | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 stylesscripts/lib/docs.css— full workshop SPA stylesdocs-css.jsnow reads them withfs.readFileSyncat build time.generateHljsCss()stays in JS since it must compose content from npm packages at runtime. All 8 tests pass (commitrefactor: extract CSS template strings into .css source files).