Permalink
Browse files

Generating TOC

  • Loading branch information...
1 parent 1aad62b commit 0cdc836054b12e7a470d827645306efbafb51a86 @tj tj committed Jul 15, 2010
Showing with 87 additions and 48 deletions.
  1. +0 −5 .pomo
  2. +4 −2 Makefile
  3. +40 −40 docs/api.html
  4. +22 −1 docs/guide.html
  5. +21 −0 support/toc.js
View
5 .pomo
@@ -23,9 +23,4 @@
complete: false
description:
length: 25
- name: design mode with browser reloading
-- !ruby/object:Pomo::Task
- complete: false
- description:
- length: 25
name: generated TOC for guide
View
@@ -47,6 +47,8 @@ test-cov:
@TESTFLAGS=--cov $(MAKE) test
docs: docs/api.html $(MANPAGES) $(HTMLDOCS)
+ @ echo "... generating TOC"
+ @./support/toc.js docs/guide.html
docs/api.html: lib/express/*.js
dox --title Express \
@@ -55,14 +57,14 @@ docs/api.html: lib/express/*.js
%.1: %.md
@echo "... $< -> $@"
- @ronn -r --pipe $< > $@ &
+ @ronn -r --pipe $< > $@
%.html: %.md
@echo "... $< -> $@"
@ronn -5 --pipe --fragment $< \
| cat docs/layout/head.html - docs/layout/foot.html \
| sed 's/NAME/Express/g' \
- > $@ &
+ > $@
docclean:
rm -f docs/*.{1,html}
View
@@ -151,46 +151,6 @@
<span class="variable">require</span>(<span class="string">'./response'</span>);
</code></pre>
</td>
-</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">
-<td class="docs">
-<p>Parse mini markdown implementation.
-The following conversions are supported,
-primarily for the "flash" middleware:</p>
-
-<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;
- <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;
- <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>
-
-<h2></h2>
-
-<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
-</td>
-<td class="code">
-<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){
- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)
- .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)
- .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)
- .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);
-};</code></pre>
-</td>
-</tr>
-<tr class="code">
-<td class="docs">
-<p>Escape special characters in the given string of html.</p>
-
-<h2></h2>
-
-<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
-</td>
-<td class="code">
-<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {
- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)
- .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)
- .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)
- .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)
- .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);
-};</code></pre>
-</td>
</tr><tr class="filename"><td><h2 id="lib/express/request.js"><a href="#">request</a></h2></td><td>lib/express/request.js</td></tr><tr class="code">
<td class="docs">
<p>Module dependencies.
@@ -833,6 +793,46 @@
})(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);
</code></pre>
</td>
+</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">
+<td class="docs">
+<p>Parse mini markdown implementation.
+The following conversions are supported,
+primarily for the "flash" middleware:</p>
+
+<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;
+ <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;
+ <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>
+
+<h2></h2>
+
+<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
+</td>
+<td class="code">
+<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){
+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);
+};</code></pre>
+</td>
+</tr>
+<tr class="code">
+<td class="docs">
+<p>Escape special characters in the given string of html.</p>
+
+<h2></h2>
+
+<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
+</td>
+<td class="code">
+<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {
+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)
+ .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);
+};</code></pre>
+</td>
</tr><tr class="filename"><td><h2 id="lib/express/view.js"><a href="#">view</a></h2></td><td>lib/express/view.js</td></tr><tr class="code">
<td class="docs">
<p>Module dependencies.
View
@@ -147,7 +147,28 @@
</a>
<div id="header"><strong>Sencha</strong> labs</div>
<div id="wrapper">
- <div id="container">
+ <div id="container"><ul id="toc">
+<li><a href="#Installation">Installation</a></li>
+<li><a href="#Creating-An-Application">Creating An Application</a></li>
+<li><a href="#Configuration">Configuration</a></li>
+<li><a href="#Settings">Settings</a></li>
+<li><a href="#Routing">Routing</a></li>
+<li><a href="#Passing-Route-Control">Passing Route Control</a></li>
+<li><a href="#Middleware">Middleware</a></li>
+<li><a href="#ServerRequest-header-key-defaultValue-">ServerRequest#header(key[, defaultValue])</a></li>
+<li><a href="#ServerRequest-accepts-type-">ServerRequest#accepts(type)</a></li>
+<li><a href="#ServerRequest-param-name-">ServerRequest#param(name)</a></li>
+<li><a href="#ServerRequest-flash-type-msg-">ServerRequest#flash(type[, msg])</a></li>
+<li><a href="#ServerRequest-isXMLHttpRequest">ServerRequest#isXMLHttpRequest</a></li>
+<li><a href="#ServerResponse-header-key-val-">ServerResponse#header(key[, val])</a></li>
+<li><a href="#ServerResponse-contentType-type-">ServerResponse#contentType(type)</a></li>
+<li><a href="#ServerResponse-attachment-filename-">ServerResponse#attachment([filename])</a></li>
+<li><a href="#ServerResponse-sendfile-path-">ServerResponse#sendfile(path)</a></li>
+<li><a href="#ServerResponse-download-file-filename-">ServerResponse#download(file[, filename])</a></li>
+<li><a href="#ServerRequest-send-body-status-headers-status-status-">ServerRequest#send(body|status[, headers|status[, status]])</a></li>
+<li><a href="#ServerResponse-redirect-url-status-">ServerResponse#redirect(url[, status])</a></li>
+<li><a href="#Server-redirect-name-val-">Server#redirect(name, val)</a></li>
+</ul>
<a href='http://github.com/visionmedia/express' id='logo'>Express</a>
<p id="tagline">
High performance, high class web development for
View
@@ -0,0 +1,21 @@
+#!/usr/bin/env node
+
+var fs = require('fs'),
+ file = process.argv[2];
+
+if (file) {
+ var js = fs.readFileSync(file, 'utf8'),
+ headers = js.match(/<h3 id="(.*?)">(.*?)<\/h3>/g),
+ toc = ['<ul id="toc">'];
+ if (js.indexOf('id="toc"') < 0) {
+ headers.forEach(function(header){
+ var captures = header.match(/id="(.*?)">(.*?)</),
+ id = captures[1],
+ title = captures[2];
+ toc.push('<li><a href="#' + id + '">' + title + '</a></li>');
+ });
+ toc.push('</ul>');
+ js = js.replace('<div id="container">', '<div id="container">' + toc.join('\n'));
+ fs.writeFileSync(file, js);
+ }
+}

0 comments on commit 0cdc836

Please sign in to comment.