mirror of https://github.com/google/docsy.git
[CI] Add scripts to generate and check Chroma styles (#1976)
This commit is contained in:
parent
8f21861f9c
commit
2fcacd6781
|
@ -3,11 +3,11 @@
|
|||
|
||||
[build]
|
||||
publish = "userguide/public"
|
||||
command = "npm run docs-install && npm run build:preview"
|
||||
command = "npm run ci:prepare && npm run build:preview"
|
||||
|
||||
[build.environment]
|
||||
GO_VERSION = "1.21.6"
|
||||
HUGO_THEME = "repo"
|
||||
|
||||
[context.production]
|
||||
command = "npm run docs-install && npm run build:production"
|
||||
command = "npm run ci:prepare && npm run build:production"
|
||||
|
|
20
package.json
20
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "docsy",
|
||||
"version": "0.9.2-dev.0-unreleased",
|
||||
"version.next": "0.9.3-dev.0-unreleased",
|
||||
"version": "0.10.0-dev.0-unreleased",
|
||||
"version.next": "0.10.1-dev.0-unreleased",
|
||||
"repository": "github:google/docsy",
|
||||
"homepage": "https://www.docsy.dev",
|
||||
"license": "Apache-2.0",
|
||||
|
@ -10,29 +10,27 @@
|
|||
"_check:format": "npx prettier --check .??* *.md",
|
||||
"_cp:bs-rfs": "npx cpy 'node_modules/bootstrap/scss/vendor/*' assets/_vendor/bootstrap/scss/",
|
||||
"_diff:check": "git diff --name-only --exit-code",
|
||||
"_gen-chroma-styles": "bash -c tools/gen-chroma-styles.sh && bash -c 'tools/gen-chroma-styles.sh -s onedark -o _dark.scss'",
|
||||
"_mkdir:hugo-mod": "npx mkdirp ../github.com/FortAwesome/Font-Awesome ../github.com/twbs/bootstrap",
|
||||
"_prebuild": "npm run _cp:bs-rfs",
|
||||
"_test:docs": "npm run cd:docs test",
|
||||
"_prepare": "npm run _cp:bs-rfs && npm run _gen-chroma-styles",
|
||||
"build:preview": "npm run cd:docs build:preview",
|
||||
"build:production": "npm run cd:docs build:production",
|
||||
"build": "npm run cd:docs build",
|
||||
"cd:docs": "npm run _cd:docs -- npm run",
|
||||
"check": "npm run check:format && npm run check:links--md",
|
||||
"check:format": "npm run _check:format || (echo '[help] Run: npm run fix:format'; exit 1)",
|
||||
"check:links--md": "ls *.md | xargs npx markdown-link-check --config .markdown-link-check.json",
|
||||
"check:links:all": "npm run cd:docs check:links:all",
|
||||
"check:links": "npm run cd:docs check:links",
|
||||
"check": "npm run check:format && npm run check:links--md",
|
||||
"ci:post": "npm run fix:format && npm run _diff:check",
|
||||
"ci:prepare": "npm run docs-install && npm run _prepare && npm run _diff:check",
|
||||
"docs-install": "npm run _cd:docs -- npm install",
|
||||
"fix:format": "npm run _check:format -- --write",
|
||||
"get:hugo-modules": "node tools/getHugoModules/index.mjs",
|
||||
"postinstall": "npm run _mkdir:hugo-mod",
|
||||
"prebuild:preview": "npm run _prebuild",
|
||||
"prebuild:production": "npm run _prebuild",
|
||||
"preserve": "npm run _prebuild",
|
||||
"pretest": "npm run _prebuild",
|
||||
"serve": "npm run cd:docs serve",
|
||||
"test:all": "npm run _test:docs && npm run check && npm run fix:format && npm run _diff:check",
|
||||
"test": "npm run _test:docs",
|
||||
"test:all": "npm run ci:prepare && npm run check && npm run cd:docs test && npm run ci:post",
|
||||
"test": "npm run cd:docs test",
|
||||
"update:pkg:dep": "npm install --save-exact @fortawesome/fontawesome-free@latest bootstrap@latest",
|
||||
"update:pkg:hugo": "npm install --save-exact -D hugo-extended@latest"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
HUGO="npx hugo"
|
||||
CHROMA_STYLE=tango
|
||||
DEST_DIR=assets/scss/td/chroma
|
||||
DEST_FILE=_light.scss
|
||||
DEST_PATH=/dev/null # Set in process_CLI_args
|
||||
|
||||
function _usage() {
|
||||
cat <<EOS
|
||||
Usage: `basename $0` [options]
|
||||
|
||||
Generate CSS for the named Chroma style using Hugo.
|
||||
|
||||
-h Output this usage info.
|
||||
-o FILE Output file name relative to $DEST_DIR.
|
||||
Default: $DEST_FILE.
|
||||
-s STYLE Chroma style name from list at
|
||||
https://xyproto.github.io/splash/docs
|
||||
Default: $CHROMA_STYLE.
|
||||
EOS
|
||||
}
|
||||
|
||||
function usage() {
|
||||
local status=${1:-0}
|
||||
_usage 1>&2
|
||||
exit $status
|
||||
}
|
||||
|
||||
function process_CLI_args() {
|
||||
while getopts ":ho:s:" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
o)
|
||||
DEST_FILE="$OPTARG"
|
||||
;;
|
||||
s)
|
||||
CHROMA_STYLE="$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
echo "ERROR: unrecognized flag: -$OPTARG"
|
||||
usage 1;
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
if [ "$#" -gt 0 ]; then
|
||||
echo "ERROR: extra argument(s): $*" >&2
|
||||
usage 1;
|
||||
fi
|
||||
|
||||
DEST_PATH="$DEST_DIR/$DEST_FILE"
|
||||
}
|
||||
|
||||
function main() {
|
||||
process_CLI_args "$@"
|
||||
|
||||
# For more options, see https://gohugo.io/commands/hugo_gen_chromastyles/
|
||||
local cmd="$HUGO gen chromastyles --style=$CHROMA_STYLE >> $DEST_PATH"
|
||||
echo "Generating $DEST_FILE using: $cmd"
|
||||
|
||||
echo "/* Chroma style: $CHROMA_STYLE */" > $DEST_PATH
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue