From c9f656baa9df73088af934c9b33cf3e407e9cf02 Mon Sep 17 00:00:00 2001 From: Micheil Smith Date: Fri, 29 Oct 2010 07:00:28 +1100 Subject: [PATCH] More simplification of the templating & rendering. --- doc/{template_page.html => template.html} | 4 +- doc/template_index.html | 21 ---------- tools/doctool/doctool.js | 50 +++++++---------------- 3 files changed, 16 insertions(+), 59 deletions(-) rename doc/{template_page.html => template.html} (79%) delete mode 100644 doc/template_index.html diff --git a/doc/template_page.html b/doc/template.html similarity index 79% rename from doc/template_page.html rename to doc/template.html index 240ca9d9cc..dfbf7f0d9d 100644 --- a/doc/template_page.html +++ b/doc/template.html @@ -1,7 +1,7 @@ - {{section}} - Node.js Manual & Documentation + {{section}}Node.js Manual & Documentation @@ -11,7 +11,7 @@

Node.js Manual & Documentation


diff --git a/doc/template_index.html b/doc/template_index.html deleted file mode 100644 index 56b42ab4da..0000000000 --- a/doc/template_index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - Node.js Manual & Documentation - - - - - -
-
-

Node.js Manual & Documentation

-
-
- {{content}} -
- - - - - \ No newline at end of file diff --git a/tools/doctool/doctool.js b/tools/doctool/doctool.js index 223ddabee1..c28402f84c 100644 --- a/tools/doctool/doctool.js +++ b/tools/doctool/doctool.js @@ -71,22 +71,14 @@ function checkdir(next){ /* Loads the template for which the documentation should be outputed into. */ -var template_index, template_page; +var template; function loadTemplates(next){ - var templates_path = path.join(doc_root, "..", "template"); - - fs.readFile(templates_path+"_page.html", "utf8", function(err, data){ - if(err) throw err; + fs.readFile(path.join(doc_root, "../template.html"), "utf8", function(e, d){ + if(e) throw e; - template_page = data; - - fs.readFile(templates_path+"_index.html", "utf8", function(err, data){ - if(err) throw err; - - template_index = data; - next(); - }); + template = d; + next(); }); }; @@ -103,8 +95,7 @@ function convertFiles(next){ files.filter(function(file){ var basename = path.basename(file, ".markdown"); return path.extname(file) == ".markdown" && - basename != "index" && - basename != "_toc"; + basename.substr(0,1) != "_"; }).forEach(function(file){ var filename = path.basename(file, '.markdown') , build_path = path.join(build_root, filename+".html") @@ -115,9 +106,13 @@ function convertFiles(next){ // do conversion stuff. var html = convertData(data); - var output = template_page - .replace("{{section}}", filename) - .replace("{{content}}", html); + var output = template.replace("{{content}}", html); + + if(filename == "index"){ + output = output.replace("{{section}}", ""); + } else { + output = output.replace("{{section}}", filename+" - ") + } fs.writeFile(build_path, output, function(err){ if(err) throw err; @@ -129,22 +124,6 @@ function convertFiles(next){ next(); }; -function createIndex(next){ - fs.readFile(path.join(doc_root, "index.markdown"), "utf8", function(err, data){ - if(err) throw err; - - // do conversion stuff. - var html = convertData(data); - var output = template_index.replace("{{content}}", html); - - fs.writeFile(path.join(build_root, "index.html"), output, function(err){ - if(err) throw err; - }); - }); - // one again, no need to wait. - next(); -}; - function copyAssets(next){ cp.exec("cp -R "+assets_path+" "+bassets_path, function(err, stdout, stderr){ next(); @@ -155,6 +134,5 @@ step( checkdir, copyAssets, loadTemplates, - convertFiles, - createIndex + convertFiles )(); \ No newline at end of file