Skip to content

Commit

Permalink
Remove p-Tags from type-Field. Update fixtures and deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Dec 14, 2015
1 parent ad5b4ac commit c0567cc
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 92 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# apiDoc Changelog


#### 0.13.2

* Parser
* Remove p-Tags from type-Field.
* Update dependencies.
* Update fixtures (type-Fields and line endings).


#### 0.13.1

* Template
* Update French and Russian translation files.


#### 0.13.0

* **Important changes**:
Expand Down
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ function createOutputFiles(api) {
// Write api_data
app.log.verbose('write json file: ' + app.options.dest + 'api_data.json');
if( ! app.options.simulate)
fs.writeFileSync(app.options.dest + './api_data.json', api.data);
fs.writeFileSync(app.options.dest + './api_data.json', api.data + '\n');

app.log.verbose('write js file: ' + app.options.dest + 'api_data.js');
if( ! app.options.simulate)
fs.writeFileSync(app.options.dest + './api_data.js', 'define({ "api": ' + api.data + ' });');
fs.writeFileSync(app.options.dest + './api_data.js', 'define({ "api": ' + api.data + ' });' + '\n');

// Write api_project
app.log.verbose('write json file: ' + app.options.dest + 'api_project.json');
if( ! app.options.simulate)
fs.writeFileSync(app.options.dest + './api_project.json', api.project);
fs.writeFileSync(app.options.dest + './api_project.json', api.project + '\n');

app.log.verbose('write js file: ' + app.options.dest + 'api_project.js');
if( ! app.options.simulate)
fs.writeFileSync(app.options.dest + './api_project.js', 'define(' + api.project + ');');
fs.writeFileSync(app.options.dest + './api_project.js', 'define(' + api.project + ');' + '\n');
}

module.exports = {
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apidoc",
"version": "0.13.1",
"version": "0.13.2",
"description": "RESTful web API Documentation Generator",
"author": "Peter Rottmann <[email protected]>",
"license": {
Expand Down Expand Up @@ -36,21 +36,21 @@
"node": ">= 0.10.0"
},
"dependencies": {
"apidoc-core": "~0.4.0",
"fs-extra": "~0.18.2",
"lodash": "~3.8.0",
"markdown-it": "^4.2.1",
"apidoc-core": "~0.4.2",
"fs-extra": "~0.26.2",
"lodash": "~3.10.1",
"markdown-it": "^5.0.2",
"nomnom": "~1.8.1",
"winston": "~1.0.0"
"winston": "~2.1.1"
},
"devDependencies": {
"apidoc-example": "*",
"jshint": "^2.7.0",
"mocha": "~2.2.4",
"npm-check-updates": "^1.5.1",
"path-to-regexp": "^1.0.3",
"semver": "^4.3.4",
"should": "~6.0.1"
"jshint": "^2.9.1-rc1",
"mocha": "~2.3.4",
"npm-check-updates": "^2.5.4",
"path-to-regexp": "^1.2.1",
"semver": "^5.1.0",
"should": "~8.0.1"
},
"jshintConfig": {
"camelcase": true,
Expand Down
95 changes: 47 additions & 48 deletions template/vendor/path-to-regexp/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var isarray = Array.isArray || function (arr) {
var isArray = Array.isArray || function (arr) {
return Object.prototype.toString.call(arr) == '[object Array]';
};

Expand All @@ -24,7 +24,7 @@ var PATH_REGEXP = new RegExp([
'([\\/.])?(?:\\:(\\w+)(?:\\(((?:\\\\.|[^)])*)\\))?|\\(((?:\\\\.|[^)])*)\\))([+*?])?',
// Match regexp special characters that are always escaped.
'([.+*?=^!:${}()[\\]|\\/])'
].join('|'), 'g')
].join('|'), 'g');

/**
* Escape the capturing group by escaping special characters and meaning.
Expand All @@ -33,7 +33,7 @@ var PATH_REGEXP = new RegExp([
* @return {String}
*/
function escapeGroup (group) {
return group.replace(/([=!:$\/()])/g, '\\$1')
return group.replace(/([=!:$\/()])/g, '\\$1');
}

/**
Expand All @@ -44,8 +44,8 @@ function escapeGroup (group) {
* @return {RegExp}
*/
function attachKeys (re, keys) {
re.keys = keys
return re
re.keys = keys;
return re;
}

/**
Expand All @@ -55,7 +55,7 @@ function attachKeys (re, keys) {
* @return {String}
*/
function flags (options) {
return options.sensitive ? '' : 'i'
return options.sensitive ? '' : 'i';
}

/**
Expand All @@ -67,20 +67,20 @@ function flags (options) {
*/
function regexpToRegexp (path, keys) {
// Use a negative lookahead to match only capturing groups.
var groups = path.source.match(/\((?!\?)/g)
var groups = path.source.match(/\((?!\?)/g);

if (groups) {
for (var i = 0; i < groups.length; i++) {
keys.push({
name: i,
name: i,
delimiter: null,
optional: false,
repeat: false
})
optional: false,
repeat: false
});
}
}

return attachKeys(path, keys)
return attachKeys(path, keys);
}

/**
Expand All @@ -92,14 +92,14 @@ function regexpToRegexp (path, keys) {
* @return {RegExp}
*/
function arrayToRegexp (path, keys, options) {
var parts = []
var parts = [];

for (var i = 0; i < path.length; i++) {
parts.push(pathToRegexp(path[i], keys, options).source)
parts.push(pathToRegexp(path[i], keys, options).source);
}

var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))
return attachKeys(regexp, keys)
var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
return attachKeys(regexp, keys);
}

/**
Expand All @@ -110,43 +110,43 @@ function arrayToRegexp (path, keys, options) {
* @return {String}
*/
function replacePath (path, keys) {
var index = 0
var index = 0;

function replace (_, escaped, prefix, key, capture, group, suffix, escape) {
if (escaped) {
return escaped
return escaped;
}

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
});

prefix = prefix ? ('\\' + prefix) : ''
capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?')
prefix = prefix ? ('\\' + prefix) : '';
capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?');

if (repeat) {
capture = capture + '(?:' + prefix + capture + ')*'
capture = capture + '(?:' + prefix + capture + ')*';
}

if (optional) {
return '(?:' + prefix + '(' + capture + '))?'
return '(?:' + prefix + '(' + capture + '))?';
}

// Basic parameter support.
return prefix + '(' + capture + ')'
return prefix + '(' + capture + ')';
}

return path.replace(PATH_REGEXP, replace)
return path.replace(PATH_REGEXP, replace);
}

/**
Expand All @@ -162,44 +162,43 @@ function replacePath (path, keys) {
* @return {RegExp}
*/
function pathToRegexp (path, keys, options) {
keys = keys || []
keys = keys || [];

if (!isarray(keys)) {
options = keys
keys = []
if (!isArray(keys)) {
options = keys;
keys = [];
} else if (!options) {
options = {}
options = {};
}

if (path instanceof RegExp) {
return regexpToRegexp(path, keys, options)
return regexpToRegexp(path, keys, options);
}

if (isarray(path)) {
return arrayToRegexp(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) === '/'
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) {
route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?'
route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?';
}

if (end) {
route += '$'
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 ? '' : '(?=\\/|$)'
route += strict && endsWithSlash ? '' : '(?=\\/|$)';
}

return attachKeys(new RegExp('^' + route, flags(options)), keys)
return attachKeys(new RegExp('^' + route, flags(options)), keys);
}

26 changes: 13 additions & 13 deletions test/multi_input_folder/fixtures/api_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ define({ "api": [
"Credentials": [
{
"group": "Credentials",
"type": "<p>String</p> ",
"type": "String",
"optional": false,
"field": "username",
"description": "<p>Username</p> "
"description": "<p>Username</p>"
},
{
"group": "Credentials",
"type": "<p>String</p> ",
"type": "String",
"optional": false,
"field": "password",
"description": "<p>password</p> "
"description": "<p>password</p>"
}
]
}
Expand All @@ -35,7 +35,7 @@ define({ "api": [
"group": "500 Internal Server Error",
"optional": false,
"field": "InternalServerError",
"description": "<p>The server encountered an internal error</p> "
"description": "<p>The server encountered an internal error</p>"
}
]
},
Expand All @@ -53,7 +53,7 @@ define({ "api": [
"url": "/api/subscriptioninfo",
"title": "",
"version": "0.3.0",
"description": "<p>Get the subscription information from an authenticated user.</p> ",
"description": "<p>Get the subscription information from an authenticated user.</p>",
"group": "Authentication",
"name": "GetSubscriptionInfo",
"filename": "src/test_api.js",
Expand All @@ -66,7 +66,7 @@ define({ "api": [
"type": "String",
"optional": false,
"field": "Authorization",
"description": "<p>Auth header with JWT Token</p> "
"description": "<p>Auth header with JWT Token</p>"
}
]
},
Expand All @@ -85,7 +85,7 @@ define({ "api": [
"group": "500 Internal Server Error",
"optional": false,
"field": "InternalServerError",
"description": "<p>The server encountered an internal error</p> "
"description": "<p>The server encountered an internal error</p>"
}
]
},
Expand All @@ -103,16 +103,16 @@ define({ "api": [
"url": "/api/subscriptioninfo/:userid",
"title": "",
"version": "0.2.0",
"description": "<p>Get the subscription information for a user.</p> ",
"description": "<p>Get the subscription information for a user.</p>",
"parameter": {
"fields": {
"Parameter": [
{
"group": "Parameter",
"type": "<p>Number</p> ",
"type": "Number",
"optional": false,
"field": "userid",
"description": "<p>user id</p> "
"description": "<p>user id</p>"
}
]
}
Expand All @@ -128,7 +128,7 @@ define({ "api": [
"group": "500 Internal Server Error",
"optional": false,
"field": "InternalServerError",
"description": "<p>The server encountered an internal error</p> "
"description": "<p>The server encountered an internal error</p>"
}
]
},
Expand All @@ -141,4 +141,4 @@ define({ "api": [
]
}
}
] });
] });
Loading

0 comments on commit c0567cc

Please sign in to comment.