diff --git a/extras/fileSearch/fileSearch.js b/extras/fileSearch/fileSearch.js index 48440f8..c521259 100644 --- a/extras/fileSearch/fileSearch.js +++ b/extras/fileSearch/fileSearch.js @@ -557,7 +557,7 @@ * Constructs and shows the search box, optionally pre-populated * with a value for the search field * - * @param {string,optional} val Pre-populated value for the search field + * @param {string=} val Pre-populated value for the search field */ function showSearchBox(val){ @@ -567,7 +567,7 @@ // Create the containing element var f = document.createElement('div'); - f.id = "search"; + f.id = 'search'; // Construct some basic HTML f.innerHTML = [ diff --git a/package.json b/package.json index 4c80f84..56fc157 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,19 @@ "name": "docker", "version": "0.2.14", "dependencies": { - "mkdirp": "0.3.2", + "async": "^1.4.0", "commander": "0.5.2", - "watchr": "~2.3.3", - "markdown-it": "^4.4.0", - "less": "^2.5.1", + "css": "^2.2.1", + "dox": "^0.8.0", "ejs": "^2.3.3", "extend": "^3.0.0", - "async": "^1.4.0", "highlight.js": "^8.7.0", + "less": "^2.5.1", + "markdown-it": "^4.4.0", + "mkdirp": "0.3.2", "repeating": "^1.1.3", "strip-indent": "^1.0.1", - "css": "^2.2.1" + "watchr": "~2.3.3" }, "bin": { "docker": "./docker" diff --git a/src/docker.js b/src/docker.js index 8b5d168..cb567b7 100644 --- a/src/docker.js +++ b/src/docker.js @@ -8,11 +8,11 @@ var watchr = require('watchr'); var async = require('async'); var path = require('path'); var less = require('less'); +var dox = require('dox'); var ejs = require('ejs'); var fs = require('fs'); var languages = require('./languages'); -var parseMultiline = require('./parseMultiLine'); var md = new MarkdownIt({ html: true, @@ -417,7 +417,7 @@ Docker.prototype.parseSections = function(data, lang){ // Strip off leading * characters. multiLine = multiLine.replace(/^[ \t]*\*? ?/gm, ""); - jsDocData = parseMultiline(multiLine); + jsDocData = dox.parseComment(multiLine, { raw: true }); // Put markdown parser on the data so it can be accessed in the template jsDocData.md = mark; @@ -435,7 +435,7 @@ Docker.prototype.parseSections = function(data, lang){ // end of the same comment, or if a single-line comment is started before the multiline // So for example the following would not be treated as a multiline starter: // ```js - // alert('foo'); // Alert some foo /* Random open comment thing + // alert('foo'); // Alert some foo /* Random open comment thing // ``` matchable.match(lang.multiLine[0]) && !matchable.replace(lang.multiLine[0],'').match(lang.multiLine[1]) && @@ -525,8 +525,8 @@ Docker.prototype.renderCodeFile = function(sections, language, filename, cb){ headings: headings, sidebar: this.options.sidebarState, filename: filename.replace(this.options.inDir, '').replace(/^[\/\\]/, ''), - js: this.options.js.map(path.basename), - css: this.options.css.map(path.basename) + js: this.options.js.map(function(f){ return path.basename(f); }), + css: this.options.css.map(function(f){ return path.basename(f); }) }); diff --git a/src/parseMultiLine.js b/src/parseMultiLine.js deleted file mode 100644 index 3210b45..0000000 --- a/src/parseMultiLine.js +++ /dev/null @@ -1,128 +0,0 @@ -module.exports = function(comment){ - var commentData = { tags: [], description: {} }; - - if(!/^\s*@/.test(comment)){ - - // Split out a summary and body from the comment - var full = comment.split('\n@')[0]; - - commentData.description.summary = full.split(/\n\s*\n\s*/)[0]; - commentData.description.body = full.split(/\n\s*\n\s*/).slice(1).join('\n\n'); - - }else{ - - // If the comment starts with a tag, do nothing - commentData.description.summary = ''; - commentData.description.body = ''; - } - - - // grabType function grabs the type out of an array of space-separated - // bits, so for example we can pick up {string, optional} from the beginning - // of a tag. `bits` is passed in as an array so we can shift and unshift - // 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(); - - // If for whatever reason the tag was of the format {type}blah without - // the trailing space after the }, extract whatever was left over and - // put it back onto the bits array. - if(!/\}$/.test(type)){ - bits.unshift(type.replace(/^.*\}(.*)$/, '$1')); - type = type.replace(/\}.*$/,'}'); - } - - function escapeChar(chr) { - return escape[chr] || "&"; - } - - type = type.replace(badChars, escapeChar); - - return type.replace(/[{}]/g,''); - } - - // Prepend a newline here in case the comment starts with a tag - comment = '\n' + comment; - - // If we have jsDoc-style parameters, parse them - if(comment.indexOf('\n@') !== -1){ - var tags = comment.split('\n@').slice(1); - - // Loop through all of the tags and process the ones we support - commentData.tags = tags.map(function(line){ - var bits = line.split(' '), tag = {}; - 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': - // `@see Title http://url` or `@see local place` - if(/http/.test(line)){ - tag.title = bits.length > 1 ? bits.shift() : ''; - tag.url = bits.join(' '); - }else{ - tag.local = bits.join(' '); - } - break; - default: - if(bits.length > 0 && bits[0].charAt(0) == '{') tag.types = grabType(bits).split(/ *[|,\/] */); - tag.description = bits.join(' '); - tag.name = tagType; - tag.type = 'unknown'; - } - - return tag; - }); - } - - return commentData; -};