diff options
author | Micheil Smith <micheil@brandedcode.com> | 2010-11-15 02:50:14 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-16 06:59:21 +0300 |
commit | 939fba40fd55d67f873e2edc89503029c616c17e (patch) | |
tree | 42b226499c6473b4f79e9750d8152a7b06a77bf9 /doc | |
parent | ade8cf96e0f19fab240b2a7fcf970e8b1d24d10b (diff) |
Better doc indexes, fix some links
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api_assets/core.js | 62 | ||||
-rw-r--r-- | doc/api_assets/style.css | 38 | ||||
-rw-r--r-- | doc/index.html | 4 | ||||
-rw-r--r-- | doc/template.html | 2 |
4 files changed, 96 insertions, 10 deletions
diff --git a/doc/api_assets/core.js b/doc/api_assets/core.js index e22106d6e11..3625b2dcece 100644 --- a/doc/api_assets/core.js +++ b/doc/api_assets/core.js @@ -1,3 +1,63 @@ $(function(){ highlight(undefined, undefined, 'pre'); -});
\ No newline at end of file + var $headings = $("h2, h3, h4, h5, h6"); + + if(! $("body").hasClass("index") && $headings.size() > 2){ + var current_level + , last_level = 0 + , toc = [ + '<div id="toc">', + '<h2>Table Of Contents <a id="toggler" href="#toc">Hide</a></h2>' + ]; + + for(var i=0, hl=$headings.size()+1; i < hl; i++) { + var heading = $headings[i] || false; + if(heading) { + current_level = heading.tagName.substr(1,1); + + console.log(current_level, last_level, $(heading).text()); + + if(last_level != 0 && current_level <= last_level) { + toc.push("</li>"); + } + + if(current_level > last_level) { + toc.push("<ul>"); + toc.push("<li>"); + } else if(current_level < last_level) { + console.log(last_level-current_level); + for(var c=last_level-current_level; 0 < c ; c-- ){ + toc.push("</ul>"); + toc.push("</li>"); + } + } + + if(current_level == last_level || current_level < last_level) { + toc.push("<li>"); + } + + toc.push('<a href="#'+$(heading).attr("id")+'">'+$(heading).text()+'</a>'); + last_level = current_level; + } else { + toc.push("</li>"); + toc.push("</ul>"); + } + } + + toc.push("</li>"); + toc.push("</ul>"); + toc.push("<hr />"); + toc.push("</div>"); + + $("#container header").after(toc.join("\n")); + $("#toggler").toggle(function(e){ + $("#toc ul").hide(); + $(this).text("show"); + e.preventDefault(); + }, function(e){ + $("#toc ul").show(); + $(this).text("hide"); + e.preventDefault(); + }); + } +}); diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index a57a820ce76..6dc8718857e 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -24,6 +24,10 @@ a { color: #b950b7; } +#changelog #gtoc { + display: none; +} + .notice { display: block; padding: 1em; @@ -97,16 +101,15 @@ h1 { } h2 { - font-size: 1.8em; + font-size: 1.9em; line-height: 1.227em; - margin: 0 0 0.75em; - font-style: italic; + margin: 0 0 0.5em; } h3 { - font-size: 1.6em; + font-size: 1.5em; line-height: 1.0909em; - margin: 1.6em 0 1em; + margin: 1.5em 0 0.5em; } h3 + h3 { @@ -175,12 +178,35 @@ code.pre { padding: 0 0.5em 0.225em; } -#container header hr { +hr { background: none; border: medium none; border-bottom: 1px solid #ccc; + margin: 5em 0 2em; } +#container header hr { + margin: 0; + padding: 0; +} + +#toc { + +} + + #toc h2 { + font-size: 1em; + line-height: 1.4em; + } + + #toc h2 a { + float: right; + } + + #toc hr { + margin: 1em 0 2em; + } + p tt, p code { background: #f8f8ff; border: 1px solid #dedede; diff --git a/doc/index.html b/doc/index.html index 27f8f3ea8d7..e7c0433698d 100644 --- a/doc/index.html +++ b/doc/index.html @@ -23,7 +23,7 @@ <li><a href="#about">About</a></li> <li><a href="#links">Links</a></li> <li><a href="#contributing">Contributing</a></li> - <li><a href="api.html">Documentation</a></li> + <li><a href="api/">Documentation</a></li> </ol> </div> <div id="content"> @@ -260,7 +260,7 @@ git config --global user.name "Ryan Dahl" <p> Before your code your code can be accepted you have to sign the - <a href="http://nodejs.org/cla.html">contributor license agreement</a>. + <a href="cla.html">contributor license agreement</a>. </p> <p> diff --git a/doc/template.html b/doc/template.html index dfbf7f0d9d2..54ae672eac0 100644 --- a/doc/template.html +++ b/doc/template.html @@ -11,7 +11,7 @@ <header> <h1>Node.js Manual & Documentation</h1> <div id="gtoc"> - <p><a href="index.html">Table of Contents</a> | <a href="all.html">View on single page</a></p> + <p><a href="index.html">Index</a> | <a href="all.html">View on single page</a></p> </div> <hr /> </header> |