diff options
author | isaacs <i@izs.me> | 2011-09-09 00:18:48 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-09-09 00:18:48 +0400 |
commit | 8fdd60d9608cd56a07d46ebbe492d6c7e05e3047 (patch) | |
tree | dd0caf3699e936aa69d6d4685e4e19883f513289 /scripts | |
parent | a79d8804f1a205cdaf73bb84f7b06a0112c73085 (diff) |
Build an index of all html documentation files
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/index-build.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/index-build.js b/scripts/index-build.js new file mode 100644 index 000000000..7d60a1775 --- /dev/null +++ b/scripts/index-build.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node +var fs = require("fs") + , path = require("path") + , docdir = path.resolve(__dirname, "..", "doc") + +console.log( + "npm-index(1) -- Index of all npm documentation files\n" + + "====================================================\n\n") +fs.readdir(docdir, function (er, docs) { + if (er) throw er + docs.filter(function (d) { + return d !== "index.md" + && d.charAt(0) !== "." + && d.match(/\.md$/) + }).forEach(function (d) { + var doc = path.resolve(docdir, d) + , s = fs.lstatSync(doc) + , content = fs.readFileSync(doc, "utf8").split("\n\n") + , syn + , desc + + if (s.isSymbolicLink()) return + + content.forEach(function (c, i) { + c = c.trim() + //console.log([c, i]) + if (c === "## SYNOPSIS") syn = content[i + 1] + if (c === "## DESCRIPTION") syn = content[i + 1] + }) + console.log(d.replace(/^(.*)\.md$/, "## npm-$1(1)") + "\n") + if (desc) console.log(desc + "\n") + else if (syn) console.log(syn + "\n") + }) +}) |