Skip to content

Commit

Permalink
clean, polish
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Mar 11, 2013
1 parent b0539ec commit ea5e8a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
8 changes: 2 additions & 6 deletions docco.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 3 additions & 14 deletions docco.litcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ concatenating, and then splitting the result string wherever the marker occurs.
codeFragments = if output
output.split lang.codeSplitHtml
else
(htmlEscape section.codeText for section in sections)
(_.escape section.codeText for section in sections)
docsFragments = marked(docs).split lang.docsSplitHtml
for section, i in sections
Expand All @@ -171,17 +171,6 @@ concatenating, and then splitting the result string wherever the marker occurs.
pygments.stdin.write code
pygments.stdin.end()
**Escape** an HTML string, in order to produce valid non-highlighted output when
Pygments is not present on the system.

htmlEscape = (string) ->
string.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#x27;')
.replace(/\//g,'&#x2F;')
Once all of the code has finished highlighting, we can **write** the resulting
documentation file by passing the completed HTML sections into the template,
and rendering it to the specified output path.
Expand Down Expand Up @@ -320,8 +309,8 @@ Keep it DRY. Extract the docco **version** from `package.json`
version = JSON.parse(fs.readFileSync("#{__dirname}/package.json")).version

Run from Commandline
--------------------
Command Line Interface
----------------------

Finally, let's define the interface to run Docco from the command line.
Parse options using [Commander](https://github.com/visionmedia/commander.js).
Expand Down
22 changes: 2 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h2>Main Documentation Generation Functions</h2>
<span class="nv">codeFragments = </span><span class="k">if</span> <span class="nx">output</span>
<span class="nx">output</span><span class="p">.</span><span class="nx">split</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">codeSplitHtml</span>
<span class="k">else</span>
<span class="p">(</span><span class="nx">htmlEscape</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>
<span class="p">(</span><span class="nx">_</span><span class="p">.</span><span class="nx">escape</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>
<span class="nv">docsFragments = </span><span class="nx">marked</span><span class="p">(</span><span class="nx">docs</span><span class="p">).</span><span class="nx">split</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">docsSplitHtml</span>

<span class="k">for</span> <span class="nx">section</span><span class="p">,</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">sections</span>
Expand All @@ -240,24 +240,6 @@ <h2>Main Documentation Generation Functions</h2>



<p><strong>Escape</strong> an HTML string, in order to produce valid non-highlighted output when
Pygments is not present on the system.


</p>


<div class="highlight"><pre><span class="nv">htmlEscape = </span><span class="nf">(string) -&gt;</span>
<span class="nx">string</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&amp;/g</span><span class="p">,</span> <span class="s">&#39;&amp;amp;&#39;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;/g</span><span class="p">,</span> <span class="s">&#39;&amp;lt;&#39;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&gt;/g</span><span class="p">,</span> <span class="s">&#39;&amp;gt;&#39;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&quot;/g</span><span class="p">,</span> <span class="s">&#39;&amp;quot;&#39;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&#39;/g</span><span class="p">,</span> <span class="s">&#39;&amp;#x27;&#39;</span><span class="p">)</span>
<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">&#39;&amp;#x2F;&#39;</span><span class="p">)</span></pre></div>




<p>Once all of the code has finished highlighting, we can <strong>write</strong> the resulting
documentation file by passing the completed HTML sections into the template,
and rendering it to the specified output path.
Expand Down Expand Up @@ -518,7 +500,7 @@ <h2>Helpers &amp; Initial Setup</h2>



<h2>Run from Commandline</h2>
<h2>Command Line Interface</h2>



Expand Down

0 comments on commit ea5e8a4

Please sign in to comment.