Skip to content

Commit

Permalink
Merge branch 'master' into scss-multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Seney committed May 13, 2014
2 parents 4606f60 + f1ff5dc commit 4819f56
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Docker Version History

## 0.2.11

* Change sidebar loading in produced output to fire on DOMContentLoaded - thanks [hhelwich](//github.com/hhelwich)
* LiveScript syntax support, thanks to [qgustavor](//github.com/qgustavor).
* Add option to ignore inline comments and only process multiline comments - thanks to [jasonseney](//github.com/jasonseney)
* Big pile of updates to jsDoc tag handling: alias some types, add default handler for unknown types, and escape HTML properly. Thanks [ErisDS](//github.com/ErisDS)!

## 0.2.10

* Purely a version bump because npm was having issues publishing 0.2.9
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "JT <[email protected]>",
"name": "docker",
"version": "0.2.10",
"version": "0.2.11",
"dependencies": {
"mkdirp": "0.3.2",
"commander": "0.5.2",
Expand Down
15 changes: 15 additions & 0 deletions res/jsDoc.jst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ if(tags.length){
</span>
<% }
if(tag.type == 'unknown'){ %>
<div class="dox_tag_title"><%= tag.name %></div>
<div class="dox_tag_detail">
<% if(tag.types){
for(var j = 0; j < tag.types.length; j += 1){ %>
<span class="dox_type"><%= tag.types[j] %></span>
<% }
}
if(tag.description){ %>
<span><%= md(tag.description, true) %></span>
<% } %>
</div>
<% }
if(tag.type == 'see'){ %>
<div class="dox_tag_title">See</div>
<div class="dox_tag_detail">
Expand Down
11 changes: 9 additions & 2 deletions res/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ function switchTab(tab){
*
* When the document is ready, make the sidebar and all that jazz
*/
window.onload = function(){
(function (init) {
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', init);
} else { // IE8 and below
window.onload = init;
}
}(function(){
makeTree(tree, relativeDir, thisFile);
wireUpTabs();

Expand All @@ -220,4 +226,5 @@ window.onload = function(){
}else{
switchTab('tree');
}
};
}));

40 changes: 40 additions & 0 deletions src/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,15 @@ Docker.prototype.parseMultiline = function(comment){
// to remove the type from it.
function grabType(bits){
var type = bits.shift();
var badChars = /[&<>"'`]/g;
var escape = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#x27;",
"`": "&#x60;"
};

// Carry on adding bits until we reach a closing brace
while(bits.length && type.indexOf('}') === -1) type += bits.shift();
Expand All @@ -644,6 +653,12 @@ Docker.prototype.parseMultiline = function(comment){
type = type.replace(/\}.*$/,'}');
}

function escapeChar(chr) {
return escape[chr] || "&amp;";
}

type = type.replace(badChars, escapeChar);

return type.replace(/[{}]/g,'');
}

Expand All @@ -660,27 +675,42 @@ Docker.prototype.parseMultiline = function(comment){
var tagType = tag.type = bits.shift();

switch(tagType){
case 'arg':
case 'argument':
case 'param':
// `@param {typename} paramname Parameter description`
if(bits[0].charAt(0) == '{') tag.types = grabType(bits).split(/ *[|,\/] */);
tag.name = bits.shift() || '';
tag.description = bits.join(' ');
tag.type = 'param';
break;

case 'returns':
case 'return':
// `@return {typename} Return description`
if(bits[0].charAt(0) == '{') tag.types = grabType(bits).split(/ *[|,\/] */);
tag.description = bits.join(' ');
tag.type = 'return';
break;

case 'type':
// `@type {typename}`
tag.types = grabType(bits).split(/ *[|,\/] */);
break;

case 'access':
case 'api':
// `@api public` or `@api private` etc.
tag.visibility = bits.shift();
tag.type = 'api';
break;

case 'private':
case 'protected':
case 'public':
// `@public` or `@private` etc.
tag.visibility = tagType;
tag.type = 'api';
break;

case 'see':
Expand All @@ -692,6 +722,11 @@ Docker.prototype.parseMultiline = function(comment){
tag.local = bits.join(' ');
}
break;
default:
if(bits[0].charAt(0) == '{') tag.types = grabType(bits).split(/ *[|,\/] */);
tag.description = bits.join(' ');
tag.name = tagType;
tag.type = 'unknown';
}

return tag;
Expand Down Expand Up @@ -822,6 +857,11 @@ Docker.prototype.languages = {
executables: [ 'coffee' ],
comment: '#', multiLine: [ /^\s*#{3}\s*$/m, /^\s*#{3}\s*$/m ], jsDoc: true
},
livescript: {
extensions: [ 'ls' ],
executables: [ 'lsc' ],
comment: '#', multiLine: [ /\/\*\*?/, /\*\// ], jsDoc: true
},
ruby: {
extensions: [ 'rb', 'rbw', 'rake', 'gemspec' ],
executables: [ 'ruby' ],
Expand Down

0 comments on commit 4819f56

Please sign in to comment.