123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/bin/sh
- # Part of Zombie Navigator
- # Copyright © 2015 Zombie Navigator Developers
- dir="`dirname "$0"`"
- dir="`cd "$dir";pwd`"
- cd "$dir/src"
- # Look for JSDoc
- if ! which jsdoc >/dev/null 2>&1 ; then
- echo "Please install JSDoc somewhere in PATH" >&2
- exit 1
- fi
- targetDir="./data/internal-pages/docs/api"
- jsdoc --configure ../jsdoc/conf.json --destination "$targetDir"/ --readme ../jsdoc/README.markdown --recurse ../jsdoc/
- echo "Removing embedded fonts..." >&2
- rm -rf "$targetDir"/fonts/ "$targetDir"/scripts/ "$targetDir"/*.jsdoc.html "$targetDir"/scripts/*.js "$targetDir"/styles/prettify-*.css
- echo "Shrinking generated documentation..." >&2
- # Remove dates to make generated docs deterministic
- # Remove MSIE-specific codes
- # Remove spaces to reduce the addon size
- find "$targetDir" -type f -name '*.html' -execdir sh -c 'egrep -v "^\s*$|src=.(https?:)?//|<\!--\[if|<\!\[endif|lang-css.js|linenumber.js" "$1" | sed "`printf "s/^[ \t]*</</"`" | sed "s/ *on [A-Za-z]\{3\} [A-Za-z]\{3\} [0-9]\{1,2\} [0-9]\{1,\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\} GMT.*$//" | sed "s/[`printf " \t"`]*href="\""[^."\""]*.jsdoc.html[^"\""]*"\""//g" | sed "s/JSDoc:/Zombie Navigator:/" | tr "\n" "\177" | sed "s/>`printf "\177"`</></g" | tr "\177" "\n" > "$1".tmp && mv -f "$1".tmp "$1"' -- {} \;
- # Minimize CSS
- # Remove @font-face rules and non-Firefox rules
- # XXX: Regex chaos
- find "$targetDir" -type f -name '*.css' -execdir sh -c 'egrep -v "^\s*$" "$1" | sed "`printf "s/^[ \t]*//"`" | egrep -v "^-ms-|^-webkit-|^font-family:\s*[^,]*;|^src:|url\(.?\.\./fonts|local\(|^font-weight:\s*normal|^font-style:\s*normal|^/\*.*\*/$" | sed "s/ *: */:/" | sed "s/;\{0,1\} *} */}/" | sed "s/ *\([{,>]\) */\1/g" | sed "s/[`printf " \t"`]\{1,\}/ /g" | tr -d "\n" | perl -pe "s/;\}/}/g ; s/\@font\-face[{][}]//g ; s~/\*.*?\*/~~g ; s/[^}{]+\{\}//g" > "$1".tmp && mv -f "$1".tmp "$1"' -- {} \;
- echo "Done?" >&2
- # vim: ts=4 noet ai
|