diff options
author | isaacs <i@izs.me> | 2011-09-04 22:18:22 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-09-04 22:18:22 +0400 |
commit | bf4646091ab881b15a45d0f08358c6afd8317f59 (patch) | |
tree | f44261b2b78962c17eb48dd4e28bb4588f79f7d9 /scripts | |
parent | f2a2b3e6edf6a798313c73c71714fc0a89026c35 (diff) |
Abstract doc building to a separate script
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/doc-build.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/doc-build.sh b/scripts/doc-build.sh new file mode 100755 index 000000000..5d93277fd --- /dev/null +++ b/scripts/doc-build.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +if [[ $DEBUG != "" ]]; then + set -x +fi +set -o errexit +set -o pipefail + +[ -x ./node_modules/.bin/ronn ] || node cli.js install ronn + +src=$1 +dest=$2 +name=$(basename ${src%.*}) +date=$(date -u +'%Y-%M-%d %H:%m:%S') +version=$(npm -v) + +mkdir -p $(dirname $dest) + +case $dest in + *.html) + (cat html/dochead.html && \ + ./node_modules/.bin/ronn -f $src && \ + cat html/docfoot.html )\ + | sed "s|@NAME@|$name|g" \ + | sed "s|@DATE@|$date|g" \ + | sed "s|@VERSION@|$version|g" \ + | perl -pi -e 's/<h1>npm(-?[^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>npm\1<\/h1> <p>\2<\/p>/g' \ + | perl -pi -e 's/npm-([^\)]+)\(1\)/<a href="\1.html">npm \1<\/a>/g' \ + | perl -pi -e 's/npm\(1\)/<a href="npm.html">npm<\/a>/g' \ + | perl -pi -e 's/README/<a href="README.html">README<\/a>/g' \ + > $dest + exit $? + ;; + *.1) + ./node_modules/.bin/ronn --roff $src \ + | sed "s|@VERSION@|$version|g" \ + | perl -pi -e 's/npm\\-([^\(]*)\([0-9]\)/npm help \1/g' \ + | perl -pi -e 's/npm\([0-9]\)/npm help npm/g' \ + > $dest + exit $? + ;; + *) + echo "Invalid destination type: $dest" >&2 + exit 1 + ;; +esac |