Comparing version 0.12.1 to 0.12.2
# apiDoc Changelog | ||
#### 0.12.2 | ||
* CLI | ||
* Bugfix: Multiple bin parameters. [244](https://github.com/apidoc/apidoc/issues/244) | ||
* Template | ||
* Update template vendor lib path-to-regexp. | ||
* Bugfix: Example overlaps navigation. [240](https://github.com/apidoc/apidoc/issues/240) | ||
* Parser | ||
* Update dependencies. | ||
#### 0.12.1 | ||
@@ -8,5 +21,6 @@ | ||
* Bugfix: Parse blocks with unknown parameters (before the block was skipped). | ||
* Bugfix: show correct block index. | ||
* Update dependencies. | ||
* Parser | ||
* Bugfix: Parse blocks with unknown parameters (before the block was skipped). | ||
* Bugfix: show correct block index. | ||
* Update dependencies. | ||
@@ -13,0 +27,0 @@ |
{ | ||
"name": "apidoc", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "RESTful web API Documentation Generator", | ||
@@ -24,3 +24,4 @@ "author": "Peter Rottmann <rottmann@inveris.de>", | ||
"jshint": "jshint lib/ test/", | ||
"build-example": "bin/apidoc -i example/ -o tmp/" | ||
"build-example": "bin/apidoc -i example/ -o tmp/", | ||
"check-updates": "npm-check-updates" | ||
}, | ||
@@ -39,15 +40,17 @@ "keywords": [ | ||
"dependencies": { | ||
"apidoc-core": "~0.3.1", | ||
"fs-extra": "~0.14.0", | ||
"lodash": "~2.4.1", | ||
"marked": "~0.3.2", | ||
"apidoc-core": "~0.3.2", | ||
"fs-extra": "~0.18.1", | ||
"lodash": "~3.6.0", | ||
"marked": "~0.3.3", | ||
"nomnom": "~1.8.1", | ||
"winston": "~0.8.3" | ||
"winston": "~1.0.0" | ||
}, | ||
"devDependencies": { | ||
"apidoc-example": "*", | ||
"jshint": "^2.5.10", | ||
"mocha": "~2.1.0", | ||
"semver": "^4.1.0", | ||
"should": "~4.6.0" | ||
"jshint": "^2.7.0", | ||
"mocha": "~2.2.4", | ||
"npm-check-updates": "^1.5.1", | ||
"path-to-regexp": "^1.0.3", | ||
"semver": "^4.3.3", | ||
"should": "~6.0.1" | ||
}, | ||
@@ -54,0 +57,0 @@ "jshintConfig": { |
@@ -0,5 +1,9 @@ | ||
var isarray = Array.isArray || function (arr) { | ||
return Object.prototype.toString.call(arr) == '[object Array]'; | ||
}; | ||
/** | ||
* Expose `pathtoRegexp`. | ||
* Expose `pathToRegexp`. | ||
*/ | ||
//module.exports = pathtoRegexp; | ||
// module.exports = pathToRegexp | ||
@@ -12,5 +16,4 @@ /** | ||
var PATH_REGEXP = new RegExp([ | ||
// Match already escaped characters that would otherwise incorrectly appear | ||
// in future matches. This allows the user to escape special characters that | ||
// shouldn't be transformed. | ||
// Match escaped characters that would otherwise appear in future matches. | ||
// This allows the user to escape special characters that won't transform. | ||
'(\\\\.)', | ||
@@ -23,5 +26,5 @@ // Match Express-style parameters and un-named parameters with a prefix | ||
'([\\/.])?(?:\\:(\\w+)(?:\\(((?:\\\\.|[^)])*)\\))?|\\(((?:\\\\.|[^)])*)\\))([+*?])?', | ||
// Match regexp special characters that should always be escaped. | ||
// Match regexp special characters that are always escaped. | ||
'([.+*?=^!:${}()[\\]|\\/])' | ||
].join('|'), 'g'); | ||
].join('|'), 'g') | ||
@@ -35,3 +38,3 @@ /** | ||
function escapeGroup (group) { | ||
return group.replace(/([=!:$\/()])/g, '\\$1'); | ||
return group.replace(/([=!:$\/()])/g, '\\$1') | ||
} | ||
@@ -46,126 +49,161 @@ | ||
*/ | ||
var attachKeys = function (re, keys) { | ||
re.keys = keys; | ||
function attachKeys (re, keys) { | ||
re.keys = keys | ||
return re | ||
} | ||
return re; | ||
}; | ||
/** | ||
* Get the flags for a regexp from the options. | ||
* | ||
* @param {Object} options | ||
* @return {String} | ||
*/ | ||
function flags (options) { | ||
return options.sensitive ? '' : 'i' | ||
} | ||
/** | ||
* Normalize the given path string, returning a regular expression. | ||
* Pull out keys from a regexp. | ||
* | ||
* An empty array should be passed in, which will contain the placeholder key | ||
* names. For example `/user/:id` will then contain `["id"]`. | ||
* | ||
* @param {(String|RegExp|Array)} path | ||
* @param {Array} keys | ||
* @param {Object} options | ||
* @param {RegExp} path | ||
* @param {Array} keys | ||
* @return {RegExp} | ||
*/ | ||
function pathtoRegexp (path, keys, options) { | ||
if (keys && !Array.isArray(keys)) { | ||
options = keys; | ||
keys = null; | ||
function regexpToRegexp (path, keys) { | ||
// Use a negative lookahead to match only capturing groups. | ||
var groups = path.source.match(/\((?!\?)/g) | ||
if (groups) { | ||
for (var i = 0; i < groups.length; i++) { | ||
keys.push({ | ||
name: i, | ||
delimiter: null, | ||
optional: false, | ||
repeat: false | ||
}) | ||
} | ||
} | ||
keys = keys || []; | ||
options = options || {}; | ||
return attachKeys(path, keys) | ||
} | ||
var strict = options.strict; | ||
var end = options.end !== false; | ||
var flags = options.sensitive ? '' : 'i'; | ||
var index = 0; | ||
/** | ||
* Transform an array into a regexp. | ||
* | ||
* @param {Array} path | ||
* @param {Array} keys | ||
* @param {Object} options | ||
* @return {RegExp} | ||
*/ | ||
function arrayToRegexp (path, keys, options) { | ||
var parts = [] | ||
if (path instanceof RegExp) { | ||
// Match all capturing groups of a regexp. | ||
var groups = path.source.match(/\((?!\?)/g) || []; | ||
// Map all the matches to their numeric keys and push into the keys. | ||
keys.push.apply(keys, groups.map(function (match, index) { | ||
return { | ||
name: index, | ||
delimiter: null, | ||
optional: false, | ||
repeat: false | ||
}; | ||
})); | ||
// Return the source back to the user. | ||
return attachKeys(path, keys); | ||
for (var i = 0; i < path.length; i++) { | ||
parts.push(pathToRegexp(path[i], keys, options).source) | ||
} | ||
if (Array.isArray(path)) { | ||
// Map array parts into regexps and return their source. We also pass | ||
// the same keys and options instance into every generation to get | ||
// consistent matching groups before we join the sources together. | ||
path = path.map(function (value) { | ||
return pathtoRegexp(value, keys, options).source; | ||
}); | ||
var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)) | ||
return attachKeys(regexp, keys) | ||
} | ||
// Generate a new regexp instance by joining all the parts together. | ||
return attachKeys(new RegExp('(?:' + path.join('|') + ')', flags), keys); | ||
} | ||
/** | ||
* Replace the specific tags with regexp strings. | ||
* | ||
* @param {String} path | ||
* @param {Array} keys | ||
* @return {String} | ||
*/ | ||
function replacePath (path, keys) { | ||
var index = 0 | ||
// Alter the path string into a usable regexp. | ||
path = path.replace(PATH_REGEXP, function (match, escaped, prefix, key, capture, group, suffix, escape) { | ||
// Avoiding re-escaping escaped characters. | ||
function replace (_, escaped, prefix, key, capture, group, suffix, escape) { | ||
if (escaped) { | ||
return escaped; | ||
return escaped | ||
} | ||
// Escape regexp special characters. | ||
if (escape) { | ||
return '\\' + escape; | ||
return '\\' + escape | ||
} | ||
var repeat = suffix === '+' || suffix === '*'; | ||
var optional = suffix === '?' || suffix === '*'; | ||
var repeat = suffix === '+' || suffix === '*' | ||
var optional = suffix === '?' || suffix === '*' | ||
keys.push({ | ||
name: key || index++, | ||
name: key || index++, | ||
delimiter: prefix || '/', | ||
optional: optional, | ||
repeat: repeat | ||
}); | ||
optional: optional, | ||
repeat: repeat | ||
}) | ||
// Escape the prefix character. | ||
prefix = prefix ? '\\' + prefix : ''; | ||
prefix = prefix ? ('\\' + prefix) : '' | ||
capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?') | ||
// Match using the custom capturing group, or fallback to capturing | ||
// everything up to the next slash (or next period if the param was | ||
// prefixed with a period). | ||
capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?'); | ||
// Allow parameters to be repeated more than once. | ||
if (repeat) { | ||
capture = capture + '(?:' + prefix + capture + ')*'; | ||
capture = capture + '(?:' + prefix + capture + ')*' | ||
} | ||
// Allow a parameter to be optional. | ||
if (optional) { | ||
return '(?:' + prefix + '(' + capture + '))?'; | ||
return '(?:' + prefix + '(' + capture + '))?' | ||
} | ||
// Basic parameter support. | ||
return prefix + '(' + capture + ')'; | ||
}); | ||
return prefix + '(' + capture + ')' | ||
} | ||
// Check whether the path ends in a slash as it alters some match behaviour. | ||
var endsWithSlash = path[path.length - 1] === '/'; | ||
return path.replace(PATH_REGEXP, replace) | ||
} | ||
// In non-strict mode we allow an optional trailing slash in the match. If | ||
// the path to match already ended with a slash, we need to remove it for | ||
// consistency. The slash is only valid at the very end of a path match, not | ||
// anywhere in the middle. This is important for non-ending mode, otherwise | ||
// "/test/" will match "/test//route". | ||
/** | ||
* Normalize the given path string, returning a regular expression. | ||
* | ||
* An empty array can be passed in for the keys, which will hold the | ||
* placeholder key descriptions. For example, using `/user/:id`, `keys` will | ||
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. | ||
* | ||
* @param {(String|RegExp|Array)} path | ||
* @param {Array} [keys] | ||
* @param {Object} [options] | ||
* @return {RegExp} | ||
*/ | ||
function pathToRegexp (path, keys, options) { | ||
keys = keys || [] | ||
if (!isarray(keys)) { | ||
options = keys | ||
keys = [] | ||
} else if (!options) { | ||
options = {} | ||
} | ||
if (path instanceof RegExp) { | ||
return regexpToRegexp(path, keys, options) | ||
} | ||
if (isarray(path)) { | ||
return arrayToRegexp(path, keys, options) | ||
} | ||
var strict = options.strict | ||
var end = options.end !== false | ||
var route = replacePath(path, keys) | ||
var endsWithSlash = path.charAt(path.length - 1) === '/' | ||
// In non-strict mode we allow a slash at the end of match. If the path to | ||
// match already ends with a slash, we remove it for consistency. The slash | ||
// is valid at the end of a path match, not in the middle. This is important | ||
// in non-ending mode, where "/test/" shouldn't match "/test//route". | ||
if (!strict) { | ||
path = (endsWithSlash ? path.slice(0, -2) : path) + '(?:\\/(?=$))?'; | ||
route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?' | ||
} | ||
// In non-ending mode, we need prompt the capturing groups to match as much | ||
// as possible by using a positive lookahead for the end or next path segment. | ||
if (!end) { | ||
path += strict && endsWithSlash ? '' : '(?=\\/|$)'; | ||
if (end) { | ||
route += '$' | ||
} else { | ||
// In non-ending mode, we need the capturing groups to match as much as | ||
// possible by using a positive lookahead to the end or next path segment. | ||
route += strict && endsWithSlash ? '' : '(?=\\/|$)' | ||
} | ||
return attachKeys(new RegExp('^' + path + (end ? '$' : ''), flags), keys); | ||
}; | ||
return attachKeys(new RegExp('^' + route, flags(options)), keys) | ||
} | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
612676
4073
7
+ Addedasync@1.0.0(transitive)
+ Addedcolors@1.0.3(transitive)
+ Addedfs-extra@0.18.4(transitive)
+ Addedgraceful-fs@3.0.12(transitive)
+ Addednatives@1.1.6(transitive)
+ Addedwinston@1.0.2(transitive)
- Removedasync@0.2.10(transitive)
- Removedcolors@0.6.2(transitive)
- Removedfs-extra@0.14.0(transitive)
- Removedlodash@2.4.2(transitive)
- Removedncp@1.0.1(transitive)
- Removedwinston@0.8.3(transitive)
Updatedapidoc-core@~0.3.2
Updatedfs-extra@~0.18.1
Updatedlodash@~3.6.0
Updatedmarked@~0.3.3
Updatedwinston@~1.0.0