This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Better doc indexes, fix some links

  • Loading branch information...
1 parent ade8cf9 commit 939fba40fd55d67f873e2edc89503029c616c17e @miksago miksago committed with ry Nov 14, 2010
Showing with 96 additions and 10 deletions.
  1. +61 −1 doc/api_assets/core.js
  2. +32 −6 doc/api_assets/style.css
  3. +2 −2 doc/index.html
  4. +1 −1 doc/template.html
View
@@ -1,3 +1,63 @@
$(function(){
highlight(undefined, undefined, 'pre');
-});
+ 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();
+ });
+ }
+});
View
@@ -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;
View
@@ -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 @@ <h2 id="contributing">Contributing</h2>
<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>
View
@@ -11,7 +11,7 @@
<header>
<h1>Node.js Manual &amp; 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>

0 comments on commit 939fba4

Please sign in to comment.