Browse Source

More simplification of the templating & rendering.

v0.7.4-release
Micheil Smith 14 years ago
committed by Ryan Dahl
parent
commit
c9f656baa9
  1. 4
      doc/template.html
  2. 21
      doc/template_index.html
  3. 50
      tools/doctool/doctool.js

4
doc/template_page.html → doc/template.html

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>{{section}} - Node.js Manual &amp; Documentation</title>
<title>{{section}}Node.js Manual &amp; Documentation</title>
<link rel="stylesheet" href="assets/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="assets/sh.css" type="text/css" media="all"/>
<script type="text/javascript" src="assets/jquery.js"></script>
@ -11,7 +11,7 @@
<header>
<h1>Node.js Manual &amp; Documentation</h1>
<div id="gtoc">
<p><a href="index.html">Table of Contents</a></p>
<p><a href="index.html">Table of Contents</a> | <a href="all.html">View on single page</a></p>
</div>
<hr />
</header>

21
doc/template_index.html

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Node.js Manual &amp; Documentation</title>
<link rel="stylesheet" href="assets/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="assets/sh.css" type="text/css" media="all"/>
<script type="text/javascript" src="assets/jquery.js"></script>
</head>
<body>
<div id="container">
<header>
<h1>Node.js Manual &amp; Documentation</h1>
<hr />
</header>
{{content}}
</div>
<script type="text/javascript" src="assets/sh_main.js"></script>
<script type="text/javascript" src="assets/sh_javascript.min.js"></script>
<script type="text/javascript" src="assets/core.js"></script>
</body>
</html>

50
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
)();
Loading…
Cancel
Save