Created
March 17, 2012 20:15
-
-
Save justindujardin/2064894 to your computer and use it in GitHub Desktop.
Docco template for filtering out private doc sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docco -t private_filter.jst private_filter.coffee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file contains private API docs and code that we wish to be | |
# removed from the `docco` output. To accomplish this, we add a | |
# custom marker `@private` to any comment/code blocks that we want | |
# to hide from the output. The token `@private` must be on its own | |
# line, or be preceeded by a space, so that quoting it in strings | |
# will not hide sections. | |
# | |
# We then remove them from the output using a modified docco template | |
# that will skip over sections that contain this marker, by using a | |
# simple regex match. | |
# | |
# For the simplest case of updating the default `docco.jst` template, | |
# simply find the lines: | |
# | |
# <% for (var i=0, l=sections.length; i<l; i++) { %> | |
# <% var section = sections[i]; %> | |
# | |
# ...then add the following chunk, directly below the second line | |
# | |
# <% if(section.docs_html.match(/[\n\s]@private/m)) continue; %> | |
# | |
# ### Main | |
# This file contains two function definitions, but you should only see | |
# one on this page. | |
# The only public api this file exposes. | |
exports.main = () -> | |
console.log "Doing things..." | |
# An internal helper function that is not documented. | |
# @private | |
_internal_helper = () -> | |
console.log "Doing some private things..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title><%= title %></title> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<link rel="stylesheet" media="all" href="<%= css %>" /> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="background"></div> | |
<% if (sources.length > 1) { %> | |
<div id="jump_to"> | |
Jump To … | |
<div id="jump_wrapper"> | |
<div id="jump_page"> | |
<% for (var i=0, l=sources.length; i<l; i++) { %> | |
<% var source = sources[i]; %> | |
<a class="source" href="<%= path.basename(destination(source)) %>"> | |
<%= path.basename(source) %> | |
</a> | |
<% } %> | |
</div> | |
</div> | |
</div> | |
<% } %> | |
<table cellpadding="0" cellspacing="0"> | |
<thead> | |
<tr> | |
<th class="docs"> | |
<h1> | |
<%= title %> | |
</h1> | |
</th> | |
<th class="code"> | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% for (var i=0, l=sections.length; i<l; i++) { %> | |
<% var section = sections[i]; %> | |
<% | |
/* Skip over sections that have @private in the docstring. */ | |
if(section.docs_html.match(/[\n\s]@private/m)) continue; | |
%> | |
<tr id="section-<%= i + 1 %>"> | |
<td class="docs"> | |
<div class="pilwrap"> | |
<a class="pilcrow" href="#section-<%= i + 1 %>">¶</a> | |
</div> | |
<%= section.docs_html %> | |
</td> | |
<td class="code"> | |
<%= section.code_html %> | |
</td> | |
</tr> | |
<% } %> | |
</tbody> | |
</table> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment