build-docs.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. # Part of Zombie Navigator
  3. # Copyright © 2015 Zombie Navigator Developers
  4. dir="`dirname "$0"`"
  5. dir="`cd "$dir";pwd`"
  6. cd "$dir/src"
  7. # Look for JSDoc
  8. if ! which jsdoc >/dev/null 2>&1 ; then
  9. echo "Please install JSDoc somewhere in PATH" >&2
  10. exit 1
  11. fi
  12. targetDir="./data/internal-pages/docs/api"
  13. jsdoc --configure ../jsdoc/conf.json --destination "$targetDir"/ --readme ../jsdoc/README.markdown --recurse ../jsdoc/
  14. echo "Removing embedded fonts..." >&2
  15. rm -rf "$targetDir"/fonts/ "$targetDir"/scripts/ "$targetDir"/*.jsdoc.html "$targetDir"/scripts/*.js "$targetDir"/styles/prettify-*.css
  16. echo "Shrinking generated documentation..." >&2
  17. # Remove dates to make generated docs deterministic
  18. # Remove MSIE-specific codes
  19. # Remove spaces to reduce the addon size
  20. 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"' -- {} \;
  21. # Minimize CSS
  22. # Remove @font-face rules and non-Firefox rules
  23. # XXX: Regex chaos
  24. 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"' -- {} \;
  25. echo "Done?" >&2
  26. # vim: ts=4 noet ai