Skip to content
This repository
Browse code

Update index.html

  • Loading branch information...
commit 2bfae81f2739cde292ac4abc551407adfa8533b8 1 parent c7f08c0
Justin DuJardin authored September 21, 2012

Showing 1 changed file with 27 additions and 27 deletions. Show diff stats Hide diff stats

  1. 54  index.html
54  index.html
... ...
@@ -1,4 +1,4 @@
1  
-<!DOCTYPE html>  <html> <head>   <title>docco.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">   <link rel="stylesheet" media="all" href="resources/docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>          <ul class="sections">           <li id="title">             <span class="docs">                 <h1>docco.coffee</h1>             </span>         </li>                              <li id="section-1">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>                           <p><strong>Docco</strong> is a quick-and-dirty, hundred-line-long, literate-programming-style
  1
+<!DOCTYPE html>  <html> <head>   <title>docco.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">   <link rel="stylesheet" media="all" href="resources/docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>          <ul class="sections">           <li id="title">             <span class="annotation">                 <h1>docco.coffee</h1>             </span>         </li>                              <li id="section-1">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>                           <p><strong>Docco</strong> is a quick-and-dirty, hundred-line-long, literate-programming-style
2 2
 documentation generator. It produces HTML
3 3
 that displays your comments alongside your code. Comments are passed through
4 4
 <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a>, and code is
@@ -47,16 +47,16 @@
47 47
 <li><p>And if you happen to be a <strong>.NET</strong>
48 48
 aficionado, check out <a href="https://github.com/dontangg">Don Wilson</a>'s 
49 49
 <a href="http://dontangg.github.com/nocco/">Nocco</a>.</p></li>
50  
-</ul>             </span>                      </li>                              <li id="section-2">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-2">&#182;</a>               </div>                           <h3>Main Documentation Generation Functions</h3>             </span>                      </li>                              <li id="section-3">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-3">&#182;</a>               </div>                           <p>Generate the documentation for a source file by reading it in, splitting it
  50
+</ul>             </span>                      </li>                              <li id="section-2">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-2">&#182;</a>               </div>                           <h3>Main Documentation Generation Functions</h3>             </span>                      </li>                              <li id="section-3">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-3">&#182;</a>               </div>                           <p>Generate the documentation for a source file by reading it in, splitting it
51 51
 up into comment/code sections, highlighting them for the appropriate language,
52  
-and merging them into an HTML template.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">generateDocumentation = </span><span class="nf">(source, config, callback) -&gt;</span>
  52
+and merging them into an HTML template.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">generateDocumentation = </span><span class="nf">(source, config, callback) -&gt;</span>
53 53
   <span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(error, buffer) -&gt;</span>
54 54
     <span class="k">throw</span> <span class="nx">error</span> <span class="k">if</span> <span class="nx">error</span>
55 55
     <span class="nv">code = </span><span class="nx">buffer</span><span class="p">.</span><span class="nx">toString</span><span class="p">()</span>
56 56
     <span class="nv">sections = </span><span class="nx">parse</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">code</span>
57 57
     <span class="nx">highlight</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">sections</span><span class="p">,</span> <span class="nf">-&gt;</span>
58 58
       <span class="nx">generateHtml</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">sections</span><span class="p">,</span> <span class="nx">config</span>
59  
-      <span class="nx">callback</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-4">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-4">&#182;</a>               </div>                           <p>Given a string of source code, parse out each comment and the code that
  59
+      <span class="nx">callback</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-4">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-4">&#182;</a>               </div>                           <p>Given a string of source code, parse out each comment and the code that
60 60
 follows it, and create an individual <strong>section</strong> for it.
61 61
 Sections take the form:</p>
62 62
 
@@ -66,7 +66,7 @@
66 66
   codeText: ...
67 67
   codeHtml: ...
68 68
 }
69  
-</code></pre>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">parse = </span><span class="nf">(source, code) -&gt;</span>
  69
+</code></pre>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">parse = </span><span class="nf">(source, code) -&gt;</span>
70 70
   <span class="nv">lines    = </span><span class="nx">code</span><span class="p">.</span><span class="nx">split</span> <span class="s">&#39;\n&#39;</span>
71 71
   <span class="nv">sections = </span><span class="p">[]</span>
72 72
   <span class="nv">language = </span><span class="nx">getLanguage</span> <span class="nx">source</span>
@@ -85,13 +85,13 @@
85 85
       <span class="nv">hasCode = </span><span class="kc">yes</span>
86 86
       <span class="nx">codeText</span> <span class="o">+=</span> <span class="nx">line</span> <span class="o">+</span> <span class="s">&#39;\n&#39;</span>
87 87
   <span class="nx">save</span> <span class="nx">docsText</span><span class="p">,</span> <span class="nx">codeText</span>
88  
-  <span class="nx">sections</span></pre></div></span>                      </li>                              <li id="section-5">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-5">&#182;</a>               </div>                           <p>Highlights a single chunk of CoffeeScript code, using <strong>Pygments</strong> over stdio,
  88
+  <span class="nx">sections</span></pre></div></span>                      </li>                              <li id="section-5">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-5">&#182;</a>               </div>                           <p>Highlights a single chunk of CoffeeScript code, using <strong>Pygments</strong> over stdio,
89 89
 and runs the text of its corresponding comment through <strong>Markdown</strong>, using
90 90
 <a href="http://attacklab.net/showdown/">Showdown.js</a>.</p>
91 91
 
92 92
 <p>We process the entire file in a single call to Pygments by inserting little
93 93
 marker comments between each section and then splitting the result string
94  
-wherever our markers occur.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">highlight = </span><span class="nf">(source, sections, callback) -&gt;</span>
  94
+wherever our markers occur.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">highlight = </span><span class="nf">(source, sections, callback) -&gt;</span>
95 95
   <span class="nv">language = </span><span class="nx">getLanguage</span> <span class="nx">source</span>
96 96
   <span class="nv">pygments = </span><span class="nx">spawn</span> <span class="s">&#39;pygmentize&#39;</span><span class="p">,</span> <span class="p">[</span>
97 97
     <span class="s">&#39;-l&#39;</span><span class="p">,</span> <span class="nx">language</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span>
@@ -122,9 +122,9 @@
122 122
     <span class="nv">text = </span><span class="p">(</span><span class="nx">section</span><span class="p">.</span><span class="nx">codeText</span> <span class="k">for</span> <span class="nx">section</span> <span class="k">in</span> <span class="nx">sections</span><span class="p">)</span>
123 123
     <span class="nx">pygments</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">write</span> <span class="nx">text</span><span class="p">.</span><span class="nx">join</span> <span class="nx">language</span><span class="p">.</span><span class="nx">dividerText</span>
124 124
     <span class="nx">pygments</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">end</span><span class="p">()</span>
125  
-  </pre></div></span>                      </li>                              <li id="section-6">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-6">&#182;</a>               </div>                           <p>Once all of the code is finished highlighting, we can generate the HTML file by
  125
+  </pre></div></span>                      </li>                              <li id="section-6">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-6">&#182;</a>               </div>                           <p>Once all of the code is finished highlighting, we can generate the HTML file by
126 126
 passing the completed sections into the template, and then writing the file to 
127  
-the specified output path.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">generateHtml = </span><span class="nf">(source, sections, config) -&gt;</span>
  127
+the specified output path.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">generateHtml = </span><span class="nf">(source, sections, config) -&gt;</span>
128 128
   <span class="nv">destination = </span><span class="nf">(filepath) -&gt;</span>
129 129
     <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">output</span><span class="p">,</span> <span class="nx">path</span><span class="p">.</span><span class="nx">basename</span><span class="p">(</span><span class="nx">filepath</span><span class="p">,</span> <span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">filepath</span><span class="p">))</span> <span class="o">+</span> <span class="s">&#39;.html&#39;</span><span class="p">)</span>   
130 130
   <span class="nv">title = </span><span class="nx">path</span><span class="p">.</span><span class="nx">basename</span> <span class="nx">source</span>
@@ -138,22 +138,22 @@
138 138
     <span class="nv">css        : </span><span class="nx">path</span><span class="p">.</span><span class="nx">basename</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">css</span><span class="p">)</span>
139 139
   <span class="p">}</span>
140 140
   <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&quot;docco: </span><span class="si">#{</span><span class="nx">source</span><span class="si">}</span><span class="s"> -&gt; </span><span class="si">#{</span><span class="nx">dest</span><span class="si">}</span><span class="s">&quot;</span>
141  
-  <span class="nx">fs</span><span class="p">.</span><span class="nx">writeFileSync</span> <span class="nx">dest</span><span class="p">,</span> <span class="nx">html</span></pre></div></span>                      </li>                              <li id="section-7">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-7">&#182;</a>               </div>                           <h3>Helpers &amp; Setup</h3>             </span>                      </li>                              <li id="section-8">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-8">&#182;</a>               </div>                           <p>Require our external dependencies, including <strong>Showdown.js</strong>
142  
-(the JavaScript implementation of Markdown).</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">fs       = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
  141
+  <span class="nx">fs</span><span class="p">.</span><span class="nx">writeFileSync</span> <span class="nx">dest</span><span class="p">,</span> <span class="nx">html</span></pre></div></span>                      </li>                              <li id="section-7">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-7">&#182;</a>               </div>                           <h3>Helpers &amp; Setup</h3>             </span>                      </li>                              <li id="section-8">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-8">&#182;</a>               </div>                           <p>Require our external dependencies, including <strong>Showdown.js</strong>
  142
+(the JavaScript implementation of Markdown).</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">fs       = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
143 143
 <span class="nv">path     = </span><span class="nx">require</span> <span class="s">&#39;path&#39;</span>
144 144
 <span class="nv">showdown = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;./../vendor/showdown&#39;</span><span class="p">).</span><span class="nx">Showdown</span>
145 145
 <span class="p">{</span><span class="nx">spawn</span><span class="p">,</span> <span class="nx">exec</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s">&#39;child_process&#39;</span>
146  
-<span class="nv">commander = </span><span class="nx">require</span> <span class="s">&#39;commander&#39;</span></pre></div></span>                      </li>                              <li id="section-9">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-9">&#182;</a>               </div>                           <p>Read resource file and return its content.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">getResource = </span><span class="nf">(name) -&gt;</span>
  146
+<span class="nv">commander = </span><span class="nx">require</span> <span class="s">&#39;commander&#39;</span></pre></div></span>                      </li>                              <li id="section-9">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-9">&#182;</a>               </div>                           <p>Read resource file and return its content.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">getResource = </span><span class="nf">(name) -&gt;</span>
147 147
   <span class="nv">fullPath = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">__dirname</span><span class="p">,</span> <span class="s">&#39;..&#39;</span><span class="p">,</span> <span class="s">&#39;resources&#39;</span><span class="p">,</span> <span class="nx">name</span>
148  
-  <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">fullPath</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-10">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-10">&#182;</a>               </div>                           <p>Languages are stored in JSON format in the file <code>resources/languages.json</code>
  148
+  <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">fullPath</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-10">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-10">&#182;</a>               </div>                           <p>Languages are stored in JSON format in the file <code>resources/languages.json</code>
149 149
 Each item maps the file extension to the name of the Pygments lexer and the
150  
-symbol that indicates a comment. To add a new language, modify the file.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">languages = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">getResource</span> <span class="s">&#39;languages.json&#39;</span></pre></div></span>                      </li>                              <li id="section-11">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-11">&#182;</a>               </div>                           <p>Build out the appropriate matchers and delimiters for each language.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="k">for</span> <span class="nx">ext</span><span class="p">,</span> <span class="nx">l</span> <span class="k">of</span> <span class="nx">languages</span></pre></div></span>                      </li>                              <li id="section-12">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-12">&#182;</a>               </div>                           <p>Does the line begin with a comment?</p>             </span>                          <span class="code"><div class="highlight"><pre>  <span class="nv">l.commentMatcher = </span><span class="sr">///^\s*</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="sr">\s?///</span></pre></div></span>                      </li>                              <li id="section-13">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-13">&#182;</a>               </div>                           <p>Ignore <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">hashbangs</a>
151  
-and interpolations...</p>             </span>                          <span class="code"><div class="highlight"><pre>  <span class="nv">l.commentFilter = </span><span class="sr">/(^#![/]|^\s*#\{)/</span></pre></div></span>                      </li>                              <li id="section-14">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>                           <p>The dividing token we feed into Pygments, to delimit the boundaries between
152  
-sections.</p>             </span>                          <span class="code"><div class="highlight"><pre>  <span class="nv">l.dividerText = </span><span class="s">&quot;\n</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="s">DIVIDER\n&quot;</span></pre></div></span>                      </li>                              <li id="section-15">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">&#182;</a>               </div>                           <p>The mirror of <code>dividerText</code> that we expect Pygments to return. We can split
  150
+symbol that indicates a comment. To add a new language, modify the file.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">languages = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">getResource</span> <span class="s">&#39;languages.json&#39;</span></pre></div></span>                      </li>                              <li id="section-11">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-11">&#182;</a>               </div>                           <p>Build out the appropriate matchers and delimiters for each language.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="k">for</span> <span class="nx">ext</span><span class="p">,</span> <span class="nx">l</span> <span class="k">of</span> <span class="nx">languages</span></pre></div></span>                      </li>                              <li id="section-12">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-12">&#182;</a>               </div>                           <p>Does the line begin with a comment?</p>             </span>                          <span class="content"><div class="highlight"><pre>  <span class="nv">l.commentMatcher = </span><span class="sr">///^\s*</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="sr">\s?///</span></pre></div></span>                      </li>                              <li id="section-13">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-13">&#182;</a>               </div>                           <p>Ignore <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">hashbangs</a>
  151
+and interpolations...</p>             </span>                          <span class="content"><div class="highlight"><pre>  <span class="nv">l.commentFilter = </span><span class="sr">/(^#![/]|^\s*#\{)/</span></pre></div></span>                      </li>                              <li id="section-14">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>                           <p>The dividing token we feed into Pygments, to delimit the boundaries between
  152
+sections.</p>             </span>                          <span class="content"><div class="highlight"><pre>  <span class="nv">l.dividerText = </span><span class="s">&quot;\n</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="s">DIVIDER\n&quot;</span></pre></div></span>                      </li>                              <li id="section-15">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">&#182;</a>               </div>                           <p>The mirror of <code>dividerText</code> that we expect Pygments to return. We can split
153 153
 on this to recover the original sections.
154  
-Note: the class is "c" for Python and "c1" for the other languages</p>             </span>                          <span class="code"><div class="highlight"><pre>  <span class="nv">l.dividerHtml = </span><span class="sr">///\n*&lt;span\sclass=&quot;c1?&quot;&gt;</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="sr">DIVIDER&lt;\/span&gt;\n*///</span></pre></div></span>                      </li>                              <li id="section-16">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-16">&#182;</a>               </div>                           <p>Get the current language we're documenting, based on the extension.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">getLanguage = </span><span class="nf">(source) -&gt;</span> <span class="nx">languages</span><span class="p">[</span><span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">source</span><span class="p">)]</span></pre></div></span>                      </li>                              <li id="section-17">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-17">&#182;</a>               </div>                           <p>Ensure that the destination directory exists.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">ensureDirectory = </span><span class="nf">(dir, callback) -&gt;</span>
155  
-  <span class="nx">exec</span> <span class="s">&quot;mkdir -p </span><span class="si">#{</span><span class="nx">dir</span><span class="si">}</span><span class="s">&quot;</span><span class="p">,</span> <span class="nf">-&gt;</span> <span class="nx">callback</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-18">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-18">&#182;</a>               </div>                           <p>Micro-templating, originally by John Resig, borrowed by way of
156  
-<a href="http://documentcloud.github.com/underscore/">Underscore.js</a>.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">template = </span><span class="nf">(str) -&gt;</span>
  154
+Note: the class is "c" for Python and "c1" for the other languages</p>             </span>                          <span class="content"><div class="highlight"><pre>  <span class="nv">l.dividerHtml = </span><span class="sr">///\n*&lt;span\sclass=&quot;c1?&quot;&gt;</span><span class="si">#{</span><span class="nx">l</span><span class="p">.</span><span class="nx">symbol</span><span class="si">}</span><span class="sr">DIVIDER&lt;\/span&gt;\n*///</span></pre></div></span>                      </li>                              <li id="section-16">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-16">&#182;</a>               </div>                           <p>Get the current language we're documenting, based on the extension.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">getLanguage = </span><span class="nf">(source) -&gt;</span> <span class="nx">languages</span><span class="p">[</span><span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">source</span><span class="p">)]</span></pre></div></span>                      </li>                              <li id="section-17">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-17">&#182;</a>               </div>                           <p>Ensure that the destination directory exists.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">ensureDirectory = </span><span class="nf">(dir, callback) -&gt;</span>
  155
+  <span class="nx">exec</span> <span class="s">&quot;mkdir -p </span><span class="si">#{</span><span class="nx">dir</span><span class="si">}</span><span class="s">&quot;</span><span class="p">,</span> <span class="nf">-&gt;</span> <span class="nx">callback</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-18">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-18">&#182;</a>               </div>                           <p>Micro-templating, originally by John Resig, borrowed by way of
  156
+<a href="http://documentcloud.github.com/underscore/">Underscore.js</a>.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">template = </span><span class="nf">(str) -&gt;</span>
157 157
   <span class="k">new</span> <span class="nb">Function</span> <span class="s">&#39;obj&#39;</span><span class="p">,</span>
158 158
     <span class="s">&#39;var p=[],print=function(){p.push.apply(p,arguments);};&#39;</span> <span class="o">+</span>
159 159
     <span class="s">&#39;with(obj){p.push(\&#39;&#39;</span> <span class="o">+</span>
@@ -164,15 +164,15 @@
164 164
        <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;%=(.+?)%&gt;/g</span><span class="p">,</span> <span class="s">&quot;&#39;,$1,&#39;&quot;</span><span class="p">)</span>
165 165
        <span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s">&#39;&lt;%&#39;</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s">&quot;&#39;);&quot;</span><span class="p">)</span>
166 166
        <span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s">&#39;%&gt;&#39;</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s">&quot;p.push(&#39;&quot;</span><span class="p">)</span> <span class="o">+</span>
167  
-       <span class="s">&quot;&#39;);}return p.join(&#39;&#39;);&quot;</span></pre></div></span>                      </li>                              <li id="section-19">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-19">&#182;</a>               </div>                           <p>The start of each Pygments highlight block.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">highlightStart = </span><span class="s">&#39;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&#39;</span></pre></div></span>                      </li>                              <li id="section-20">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-20">&#182;</a>               </div>                           <p>The end of each Pygments highlight block.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">highlightEnd   = </span><span class="s">&#39;&lt;/pre&gt;&lt;/div&gt;&#39;</span></pre></div></span>                      </li>                              <li id="section-21">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-21">&#182;</a>               </div>                           <p>Extract the docco version from <code>package.json</code></p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">version = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s">&quot;</span><span class="si">#{</span><span class="nx">__dirname</span><span class="si">}</span><span class="s">/../package.json&quot;</span><span class="p">)).</span><span class="nx">version</span></pre></div></span>                      </li>                              <li id="section-22">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-22">&#182;</a>               </div>                           <p>Default configuration options.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">defaults =</span>
  167
+       <span class="s">&quot;&#39;);}return p.join(&#39;&#39;);&quot;</span></pre></div></span>                      </li>                              <li id="section-19">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-19">&#182;</a>               </div>                           <p>The start of each Pygments highlight block.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">highlightStart = </span><span class="s">&#39;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&#39;</span></pre></div></span>                      </li>                              <li id="section-20">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-20">&#182;</a>               </div>                           <p>The end of each Pygments highlight block.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">highlightEnd   = </span><span class="s">&#39;&lt;/pre&gt;&lt;/div&gt;&#39;</span></pre></div></span>                      </li>                              <li id="section-21">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-21">&#182;</a>               </div>                           <p>Extract the docco version from <code>package.json</code></p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">version = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s">&quot;</span><span class="si">#{</span><span class="nx">__dirname</span><span class="si">}</span><span class="s">/../package.json&quot;</span><span class="p">)).</span><span class="nx">version</span></pre></div></span>                      </li>                              <li id="section-22">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-22">&#182;</a>               </div>                           <p>Default configuration options.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">defaults =</span>
168 168
   <span class="nv">template: </span><span class="s">&quot;</span><span class="si">#{</span><span class="nx">__dirname</span><span class="si">}</span><span class="s">/../resources/docco.jst&quot;</span>
169 169
   <span class="nv">css     : </span><span class="s">&quot;</span><span class="si">#{</span><span class="nx">__dirname</span><span class="si">}</span><span class="s">/../resources/resources/docco.css&quot;</span>
170  
-  <span class="nv">output  : </span><span class="s">&quot;docs/&quot;</span></pre></div></span>                      </li>                              <li id="section-23">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-23">&#182;</a>               </div>                           <h3>Run from Commandline</h3>             </span>                      </li>                              <li id="section-24">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-24">&#182;</a>               </div>                           <p>Run Docco from a set of command line arguments.  </p>
  170
+  <span class="nv">output  : </span><span class="s">&quot;docs/&quot;</span></pre></div></span>                      </li>                              <li id="section-23">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-23">&#182;</a>               </div>                           <h3>Run from Commandline</h3>             </span>                      </li>                              <li id="section-24">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-24">&#182;</a>               </div>                           <p>Run Docco from a set of command line arguments.  </p>
171 171
 
172 172
 <ol>
173 173
 <li>Parse command line using <a href="https://github.com/visionmedia/commander.js">Commander JS</a>.</li>
174 174
 <li>Document sources, or print the usage help if none are specified.</li>
175  
-</ol>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">run = </span><span class="nf">(args=process.argv) -&gt;</span>
  175
+</ol>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">run = </span><span class="nf">(args=process.argv) -&gt;</span>
176 176
   <span class="nx">commander</span><span class="p">.</span><span class="nx">version</span><span class="p">(</span><span class="nx">version</span><span class="p">)</span>
177 177
     <span class="p">.</span><span class="nx">usage</span><span class="p">(</span><span class="s">&quot;[options] &lt;filePattern ...&gt;&quot;</span><span class="p">)</span>
178 178
     <span class="p">.</span><span class="nx">option</span><span class="p">(</span><span class="s">&quot;-c, --css [file]&quot;</span><span class="p">,</span><span class="s">&quot;use a custom css file&quot;</span><span class="p">,</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">css</span><span class="p">)</span>
@@ -183,7 +183,7 @@
183 183
   <span class="k">if</span> <span class="nx">commander</span><span class="p">.</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span>
184 184
     <span class="nb">document</span><span class="p">(</span><span class="nx">commander</span><span class="p">.</span><span class="nx">args</span><span class="p">.</span><span class="nx">slice</span><span class="p">(),</span><span class="nx">commander</span><span class="p">)</span>
185 185
   <span class="k">else</span>
186  
-    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">commander</span><span class="p">.</span><span class="nx">helpInformation</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-25">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-25">&#182;</a>               </div>                           <h3>Document Sources</h3>             </span>                      </li>                              <li id="section-26">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-26">&#182;</a>               </div>                           <p>Run Docco over a list of <code>sources</code> with the given <code>options</code>.</p>
  186
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">commander</span><span class="p">.</span><span class="nx">helpInformation</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-25">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-25">&#182;</a>               </div>                           <h3>Document Sources</h3>             </span>                      </li>                              <li id="section-26">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-26">&#182;</a>               </div>                           <p>Run Docco over a list of <code>sources</code> with the given <code>options</code>.</p>
187 187
 
188 188
 <ol>
189 189
 <li>Construct config to use by taking <code>defaults</code> first, then  merging in <code>options</code></li>
@@ -191,7 +191,7 @@
191 191
 <li>Load the specified template and css files.</li>
192 192
 <li>Ensure the output path is created, write out the CSS file, 
193 193
 document each source, and invoke the completion callback if it is specified.</li>
194  
-</ol>             </span>                          <span class="code"><div class="highlight"><pre><span class="nb">document</span> <span class="o">=</span> <span class="nf">(sources, options = {}, callback = null) -&gt;</span>
  194
+</ol>             </span>                          <span class="content"><div class="highlight"><pre><span class="nb">document</span> <span class="o">=</span> <span class="nf">(sources, options = {}, callback = null) -&gt;</span>
195 195
   <span class="nv">config = </span><span class="p">{}</span>
196 196
   <span class="nx">config</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">defaults</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span><span class="nx">value</span> <span class="k">of</span> <span class="nx">defaults</span>
197 197
   <span class="nx">config</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">value</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span><span class="nx">value</span> <span class="k">of</span> <span class="nx">options</span> <span class="k">if</span> <span class="nx">key</span> <span class="k">of</span> <span class="nx">defaults</span>
@@ -210,13 +210,13 @@
210 210
     <span class="nv">nextFile = </span><span class="nf">-&gt;</span> 
211 211
       <span class="nx">callback</span><span class="p">()</span> <span class="k">if</span> <span class="nx">callback</span><span class="o">?</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">files</span><span class="p">.</span><span class="nx">length</span>
212 212
       <span class="nx">generateDocumentation</span> <span class="nx">files</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span> <span class="nx">config</span><span class="p">,</span> <span class="nx">nextFile</span> <span class="k">if</span> <span class="nx">files</span><span class="p">.</span><span class="nx">length</span>
213  
-    <span class="nx">nextFile</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-27">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-27">&#182;</a>               </div>                           <h3>Resolve Wildcard Source Inputs</h3>             </span>                      </li>                              <li id="section-28">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-28">&#182;</a>               </div>                           <p>Resolve a wildcard <code>source</code> input to the files it matches.</p>
  213
+    <span class="nx">nextFile</span><span class="p">()</span></pre></div></span>                      </li>                              <li id="section-27">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-27">&#182;</a>               </div>                           <h3>Resolve Wildcard Source Inputs</h3>             </span>                      </li>                              <li id="section-28">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-28">&#182;</a>               </div>                           <p>Resolve a wildcard <code>source</code> input to the files it matches.</p>
214 214
 
215 215
 <ol>
216 216
 <li>If the input contains no wildcard characters, just return it.</li>
217 217
 <li>Convert the wildcard match to a regular expression, and return
218 218
 an array of files in the path that match it.</li>
219  
-</ol>             </span>                          <span class="code"><div class="highlight"><pre><span class="nv">resolveSource = </span><span class="nf">(source) -&gt;</span>
  219
+</ol>             </span>                          <span class="content"><div class="highlight"><pre><span class="nv">resolveSource = </span><span class="nf">(source) -&gt;</span>
220 220
   <span class="k">return</span> <span class="nx">source</span> <span class="k">if</span> <span class="o">not</span> <span class="nx">source</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/([\*\?])/</span><span class="p">)</span>
221 221
   <span class="nv">regex_str = </span><span class="nx">path</span><span class="p">.</span><span class="nx">basename</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span>
222 222
     <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\./g</span><span class="p">,</span> <span class="s">&quot;\\$&amp;&quot;</span><span class="p">)</span>
@@ -225,7 +225,7 @@
225 225
   <span class="nv">regex = </span><span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s">&#39;^(&#39;</span> <span class="o">+</span> <span class="nx">regex_str</span> <span class="o">+</span> <span class="s">&#39;)$&#39;</span><span class="p">)</span>
226 226
   <span class="nv">file_path = </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span>
227 227
   <span class="nv">files = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readdirSync</span> <span class="nx">file_path</span>
228  
-  <span class="k">return</span> <span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">file_path</span><span class="p">,</span><span class="nx">file</span><span class="p">)</span> <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</span> <span class="k">when</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="nx">regex</span><span class="p">)</span></pre></div></span>                      </li>                              <li id="section-29">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-29">&#182;</a>               </div>                           <h3>Exports</h3>             </span>                      </li>                              <li id="section-30">             <span class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-30">&#182;</a>               </div>                           <p>Information about docco, and functions for programatic usage.</p>             </span>                          <span class="code"><div class="highlight"><pre><span class="nx">exports</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">value</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span> <span class="k">of</span> <span class="p">{</span>
  228
+  <span class="k">return</span> <span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">file_path</span><span class="p">,</span><span class="nx">file</span><span class="p">)</span> <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</span> <span class="k">when</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="nx">regex</span><span class="p">)</span></pre></div></span>                      </li>                              <li id="section-29">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-29">&#182;</a>               </div>                           <h3>Exports</h3>             </span>                      </li>                              <li id="section-30">             <span class="annotation">               <div class="pilwrap">                 <a class="pilcrow" href="#section-30">&#182;</a>               </div>                           <p>Information about docco, and functions for programatic usage.</p>             </span>                          <span class="content"><div class="highlight"><pre><span class="nx">exports</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">value</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span> <span class="k">of</span> <span class="p">{</span>
229 229
   <span class="nv">run           : </span><span class="nx">run</span>
230 230
   <span class="nb">document</span>      <span class="o">:</span> <span class="nb">document</span>
231 231
   <span class="nv">parse         : </span><span class="nx">parse</span>

0 notes on commit 2bfae81

Please sign in to comment.
Something went wrong with that request. Please try again.