gen docs to right place
This commit is contained in:
parent
12bef1972d
commit
81efa4db49
1 changed files with 12 additions and 6 deletions
|
|
@ -3,14 +3,18 @@ var path = require("path")
|
|||
var marked = require("marked")
|
||||
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
|
||||
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
|
||||
try {fs.mkdirSync("archive")} catch (e) {}
|
||||
try {fs.mkdirSync("archive/v" + version)} catch (e) {}
|
||||
try {fs.mkdirSync("archive/v" + version + "/lib")} catch (e) {}
|
||||
try {fs.mkdirSync("archive/v" + version + "/lib/prism")} catch (e) {}
|
||||
try {fs.mkdirSync("../mithril")} catch (e) {}
|
||||
try {fs.mkdirSync("../mithril/archive")} catch (e) {}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version)} catch (e) {}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib")} catch (e) {}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib/prism")} catch (e) {}
|
||||
|
||||
var guides = fs.readFileSync("docs/guides.md", "utf-8")
|
||||
var methods = fs.readFileSync("docs/methods.md", "utf-8")
|
||||
|
||||
var index = fs.readFileSync("docs/index.md", "utf-8")
|
||||
fs.writeFileSync("README.md", index.replace(/(\]\()(.+?)\.md(\))/g, "$1http://mithril.js.org/$2.html$3"), "utf-8")
|
||||
|
||||
generate("docs")
|
||||
|
||||
function generate(pathname) {
|
||||
|
|
@ -47,10 +51,12 @@ function generate(pathname) {
|
|||
.replace(/<h5 id="([^"]+?)">([^<]+?)<\/h5>/gim, function(match, id, text) { // fix anchors
|
||||
return "<h5 id=\"" + text.toLowerCase().replace(/\.|\[|\]|"|\//g, "") + "\">" + text + "</h5>"
|
||||
})
|
||||
fs.writeFileSync("archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
}
|
||||
else if (!pathname.match(/lint|generate/)) {
|
||||
fs.writeFileSync("archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
fs.writeFileSync("../mithril/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue