Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-07-12 01:33:58 +0400
committerisaacs <i@izs.me>2013-07-12 01:33:58 +0400
commitfb3571543839cae0fcd2ffd53e8a9136da87fd3e (patch)
treea7b0908bd473bd4448f9881b3690e0bd42a62452 /scripts
parente600886532351c18852a9fe5a1386fffb773ba8d (diff)
doc: Build index and readme html properly
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/doc-build.sh11
-rwxr-xr-xscripts/index-build.js10
2 files changed, 13 insertions, 8 deletions
diff --git a/scripts/doc-build.sh b/scripts/doc-build.sh
index de4c9d22b..4ca97322e 100755
--- a/scripts/doc-build.sh
+++ b/scripts/doc-build.sh
@@ -61,15 +61,20 @@ case $dest in
| sed "s|@VERSION@|$version|g" \
| perl -pi -e 's/<h1>([^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>\1<\/h1> <p>\2<\/p>/g' \
| perl -pi -e 's/npm-npm/npm/g' \
- | perl -pi -e 's/([^"-])(npm-)?README(\(1\))?/\1<a href="..\/doc\/README.html">README<\/a>/g' \
+ | perl -pi -e 's/([^"-])(npm-)?README(\(1\))?/\1<a href="..\/..\/doc\/README.html">README<\/a>/g' \
| perl -pi -e 's/<title><a href="[^"]+README.html">README<\/a><\/title>/<title>README<\/title>/g' \
| perl -pi -e 's/([^"-])([^\(> ]+)(\(1\))/\1<a href="..\/cli\/\2.html">\2\3<\/a>/g' \
| perl -pi -e 's/([^"-])([^\(> ]+)(\(3\))/\1<a href="..\/api\/\2.html">\2\3<\/a>/g' \
| perl -pi -e 's/([^"-])([^\(> ]+)(\(5\))/\1<a href="..\/files\/\2.html">\2\3<\/a>/g' \
| perl -pi -e 's/([^"-])([^\(> ]+)(\(7\))/\1<a href="..\/misc\/\2.html">\2\3<\/a>/g' \
| perl -pi -e 's/\([1357]\)<\/a><\/h1>/<\/a><\/h1>/g' \
- > $dest
- cat html/docfoot-script.html >> $dest
+ | (if [ $(basename $(dirname $dest)) == "doc" ]; then
+ perl -pi -e 's/ href="\.\.\// href="/g'
+ else
+ cat
+ fi) \
+ > $dest \
+ && cat html/docfoot-script.html >> $dest
exit $?
;;
*)
diff --git a/scripts/index-build.js b/scripts/index-build.js
index 56827fcc7..8031fe727 100755
--- a/scripts/index-build.js
+++ b/scripts/index-build.js
@@ -11,7 +11,7 @@ glob(root + "/{README.md,doc/*/*.md}", function (er, files) {
output(files.map(function (f) {
var b = path.basename(f)
if (b === "README.md")
- return [1, b]
+ return [0, b]
if (b === "index.md")
return null
var s = conversion[path.basename(path.dirname(f))]
@@ -22,8 +22,6 @@ glob(root + "/{README.md,doc/*/*.md}", function (er, files) {
return (a[0] === b[0])
? ( path.basename(a[1]) === "npm.md" ? -1
: path.basename(b[1]) === "npm.md" ? 1
- : path.basename(a[1]) === "README.md" ? -1
- : path.basename(b[1]) === "README.md" ? 1
: a[1] > b[1] ? 1 : -1 )
: a[0] - b[0]
}))
@@ -36,6 +34,7 @@ function output (files) {
"npm-index(7) -- Index of all npm documentation\n" +
"==============================================\n")
+ writeLines(files, 0)
writeLines(files, 1, "Command Line Documentation")
writeLines(files, 3, "API Documentation")
writeLines(files, 5, "Files")
@@ -43,7 +42,8 @@ function output (files) {
}
function writeLines (files, sxn, heading) {
- console.log("# %s\n", heading)
+ if (heading)
+ console.log("# %s\n", heading)
files.filter(function (f) {
return f[0] === sxn
}).forEach(writeLine)
@@ -51,7 +51,7 @@ function writeLines (files, sxn, heading) {
function writeLine (sd) {
- var sxn = sd[0]
+ var sxn = sd[0] || 1
, doc = sd[1]
, d = path.basename(doc, ".md")