diff --git a/History.md b/History.md index 220ceee..f822c71 100644 --- a/History.md +++ b/History.md @@ -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 diff --git a/package.json b/package.json index 2fb681c..71b70a5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "JT ", "name": "docker", - "version": "0.2.10", + "version": "0.2.11", "dependencies": { "mkdirp": "0.3.2", "commander": "0.5.2", diff --git a/res/jsDoc.jst b/res/jsDoc.jst index 0f5e449..4a9d6ad 100644 --- a/res/jsDoc.jst +++ b/res/jsDoc.jst @@ -71,6 +71,21 @@ if(tags.length){ <% } + if(tag.type == 'unknown'){ %> +
<%= tag.name %>
+
+<% if(tag.types){ + for(var j = 0; j < tag.types.length; j += 1){ %> + <%= tag.types[j] %> +<% } + } + + if(tag.description){ %> + <%= md(tag.description, true) %> +<% } %> +
+<% } + if(tag.type == 'see'){ %>
See
diff --git a/res/script.js b/res/script.js index 7649f78..4b72c33 100644 --- a/res/script.js +++ b/res/script.js @@ -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(); @@ -220,4 +226,5 @@ window.onload = function(){ }else{ switchTab('tree'); } -}; \ No newline at end of file +})); + diff --git a/src/docker.js b/src/docker.js index 10ed69b..41ace52 100644 --- a/src/docker.js +++ b/src/docker.js @@ -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 = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; // Carry on adding bits until we reach a closing brace while(bits.length && type.indexOf('}') === -1) type += bits.shift(); @@ -644,6 +653,12 @@ Docker.prototype.parseMultiline = function(comment){ type = type.replace(/\}.*$/,'}'); } + function escapeChar(chr) { + return escape[chr] || "&"; + } + + type = type.replace(badChars, escapeChar); + return type.replace(/[{}]/g,''); } @@ -660,17 +675,22 @@ 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': @@ -678,9 +698,19 @@ Docker.prototype.parseMultiline = function(comment){ 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': @@ -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; @@ -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' ],