Socket
Socket
Sign inDemoInstall

apidoc-core

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apidoc-core - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

lib/parsers/api_deprecated.js

11

lib/index.js

@@ -19,7 +19,7 @@ var _ = require('lodash');

// const
var SPECIFICATION_VERSION = '0.2.0';
var SPECIFICATION_VERSION = '0.3.0';
var defaults = {
excludeFilters: [],
includeFilters: [ '.*\\.(clj|coffee|cpp|cs|dart|erl|exs?|go|groovy|ino?|java|js|litcoffee|lua|php?|py|rb|scala|ts|pm)$' ],
includeFilters: [ '.*\\.(clj|cls|coffee|cpp|cs|dart|erl|exs?|go|groovy|ino?|java|js|jsx|litcoffee|lua|p|php?|pl|pm|py|rb|scala|ts|vue)$' ],

@@ -57,2 +57,3 @@ src: path.join(__dirname, '../example/'),

'.lua' : './languages/lua.js',
'.pl' : './languages/pm.js',
'.pm' : './languages/pm.js',

@@ -81,3 +82,4 @@ '.py' : './languages/py.js',

apiversion : './parsers/api_version.js',
apisamplerequest : './parsers/api_sample_request.js'
apisamplerequest : './parsers/api_sample_request.js',
apideprecated : './parsers/api_deprecated.js'
},

@@ -116,3 +118,4 @@ workers: {

sampleUrl : false,
version : '0.0.0'
version : '0.0.0',
defaultVersion: '0.0.0'
};

@@ -119,0 +122,0 @@

@@ -248,8 +248,10 @@ var _ = require('lodash');

var field = elementParser.markdownFields[markdownIndex];
if (values[field]) {
values[field] = app.markdownParser.render(values[field]);
var value = _.get(values, field);
if (value) {
value = app.markdownParser.render(value);
// remove line breaks
values[field] = values[field].replace(/(\r\n|\n|\r)/g, ' ');
value = value.replace(/(\r\n|\n|\r)/g, ' ');
values[field] = values[field].trim();
value = value.trim();
_.set(values, field, value);

@@ -262,3 +264,4 @@ // TODO: Little hacky, not sure to handle this here or in template

// Remove p-Tags
values[field] = values[field].replace(/(<p>|<\/p>)/g, '');
value = value.replace(/(<p>|<\/p>)/g, '');
_.set(values, field, value);
}

@@ -415,2 +418,3 @@ }

for (var j = 0; j < blocks[i].length; j += 1) {
// check apiIgnore
if (blocks[i][j].name.substr(0, 9) === 'apiignore') {

@@ -422,2 +426,9 @@ app.log.debug('apiIgnore found in block: ' + i);

// check app.options.apiprivate and apiPrivate
if (!app.options.apiprivate && blocks[i][j].name.substr(0, 10) === 'apiprivate') {
app.log.debug('private flag is set to false and apiPrivate found in block: ' + i);
found = false;
break;
}
if (blocks[i][j].name.substr(0, 3) === 'api')

@@ -424,0 +435,0 @@ found = true;

@@ -82,2 +82,9 @@ var trim = require('../utils/trim');

// reverse Unicode Linebreaks
matches.forEach(function (val, index, array) {
if (val) {
array[index] = val.replace(/\uffff/g, '\n');
}
});
var allowedValues = matches[4];

@@ -102,6 +109,2 @@ if (allowedValues) {

// Replace Unicode Linebreaks in description
if (matches[10])
matches[10] = matches[10].replace(/\uffff/g, '\n');
// Set global group variable

@@ -108,0 +111,0 @@ group = matches[1] || defaultGroup || 'Parameter';

@@ -9,20 +9,21 @@ var _ = require('lodash');

function PluginLoader(_app) {
var self = this;
var self = this;
// global variables
app = _app;
// global variables
app = _app;
// class variables
self.plugins = {};
// class variables
self.plugins = {};
// Try to load global apidoc-plugins (if apidoc is installed locally it tries only local)
this.detectPugins(__dirname);
// Try to load global apidoc-plugins (if apidoc is installed locally it tries only local)
this.detectPugins(__dirname);
// Try to load local apidoc-plugins
this.detectPugins( path.join(process.cwd(), '/node_modules') );
// Try to load local apidoc-plugins
this.detectPugins( path.join(process.cwd(), '/node_modules') );
if (Object.keys(this.plugins).length === 0)
app.log.debug('No plugins found.');
if (Object.keys(this.plugins).length === 0) {
app.log.debug('No plugins found.');
}
this.loadPlugins();
this.loadPlugins();
}

@@ -44,21 +45,29 @@ /**

PluginLoader.prototype.detectPugins = function(dir) {
var self = this;
var self = this;
// Search from the given dir up to root.
// Every dir start with "apidoc-plugin-", because for the tests of apidoc-plugin-test.
var plugins = glob.sync(dir + '/apidoc-plugin-*');
if (plugins.length === 0) {
dir = path.join(dir, '..');
if (dir === '/' || dir.substr(1) === ':\\')
return;
return this.detectPugins(dir);
// Every dir start with "apidoc-plugin-", because for the tests of apidoc-plugin-test.
var plugins;
try {
plugins = glob.sync(dir + '/apidoc-plugin-*')
.concat( glob.sync(dir + '/@*/apidoc-plugin-*') );
} catch (e) {
app.log.warn(e);
return;
}
if (plugins.length === 0) {
dir = path.join(dir, '..');
if (dir === '/' || dir.substr(1) === ':\\') {
return;
}
return this.detectPugins(dir);
}
var offset = dir.length + 1;
plugins.forEach( function(plugin) {
var name = plugin.substr(offset);
var filename = path.relative(__dirname, plugin);
app.log.debug('add plugin: ' + name + ', ' + filename);
self.addPlugin(name, plugin);
});
var offset = dir.length + 1;
plugins.forEach( function(plugin) {
var name = plugin.substr(offset);
var filename = path.relative(__dirname, plugin);
app.log.debug('add plugin: ' + name + ', ' + filename);
self.addPlugin(name, plugin);
});
};

@@ -70,6 +79,7 @@

PluginLoader.prototype.addPlugin = function(name, filename) {
if (this.plugins[name])
app.log.debug('overwrite plugin: ' + name + ', ' + this.plugins[name]);
if (this.plugins[name]) {
app.log.debug('overwrite plugin: ' + name + ', ' + this.plugins[name]);
}
this.plugins[name] = filename;
this.plugins[name] = filename;
};

@@ -81,15 +91,15 @@

PluginLoader.prototype.loadPlugins = function() {
_.forEach(this.plugins, function(filename, name) {
app.log.debug('load plugin: ' + name + ', ' + filename);
var plugin;
try {
plugin = require(filename);
} catch(e) {
}
if (plugin && plugin.init) {
plugin.init(app);
} else {
app.log.debug('Ignored, no init function found.');
}
});
_.forEach(this.plugins, function(filename, name) {
app.log.debug('load plugin: ' + name + ', ' + filename);
var plugin;
try {
plugin = require(filename);
} catch(e) {
}
if (plugin && plugin.init) {
plugin.init(app);
} else {
app.log.debug('Ignored, no init function found.');
}
});
};

@@ -1,5 +0,3 @@

var fs = require('fs');
var os = require('os');
var path = require('path');
var wrench = require('wrench');
var fs = require('fs-extra');
var os = require('os');

@@ -12,5 +10,5 @@ var FileError = require('../errors/file_error');

function FindFiles() {
this.path = './';
this.excludeFilters = [];
this.includeFilters = [];
this.path = './';
this.excludeFilters = [];
this.includeFilters = [];
}

@@ -29,4 +27,5 @@

FindFiles.prototype.setPath = function(path) {
if (path)
this.path = path;
if (path) {
this.path = path;
}
};

@@ -40,4 +39,5 @@

FindFiles.prototype.setExcludeFilters = function(excludeFilters) {
if (excludeFilters)
this.excludeFilters = excludeFilters;
if (excludeFilters) {
this.excludeFilters = excludeFilters;
}
};

@@ -51,4 +51,5 @@

FindFiles.prototype.setIncludeFilters = function(includeFilters) {
if (includeFilters)
this.includeFilters = includeFilters;
if (includeFilters) {
this.includeFilters = includeFilters;
}
};

@@ -62,69 +63,87 @@

FindFiles.prototype.search = function() {
var self = this;
var files = [];
try {
// find Files
files = wrench.readdirSyncRecursive(self.path);
var self = this;
var files = [];
try {
files = fs.walkSync(self.path);
// create RegExp Include Filter List
var regExpIncludeFilters = [];
var filters = self.includeFilters;
if (typeof(filters) === 'string')
filters = [ filters ];
// create RegExp Include Filter List
var regExpIncludeFilters = [];
var filters = self.includeFilters;
if (typeof(filters) === 'string') {
filters = [ filters ];
}
filters.forEach(function(filter) {
if (filter.length > 0)
regExpIncludeFilters.push( new RegExp(filter) );
});
filters.forEach(function(filter) {
if (filter.length > 0) {
regExpIncludeFilters.push( new RegExp(filter) );
}
});
// RegExp Include Filter
var length = regExpIncludeFilters.length;
files = files.filter(function(filename) {
// Not include Directories like 'dirname.js'
var fullFilename = path.join(self.path, filename);
if (fs.statSync(fullFilename).isDirectory())
return 0;
// RegExp Include Filter
var length = regExpIncludeFilters.length;
files = files.filter(function(filename) {
// not include Directories like 'dirname.js/'
if (fs.statSync(filename).isDirectory()) {
return 0;
}
if (os.platform() === 'win32')
filename = filename.replace(/\\/g, '/');
if (os.platform() === 'win32') {
filename = filename.replace(/\\/g, '/');
}
// apply every filter
for (var i = 0; i < length; i += 1) {
if(regExpIncludeFilters[i].test(filename))
return 1;
}
return 0;
});
// apply every filter
for (var i = 0; i < length; i += 1) {
if(regExpIncludeFilters[i].test(filename)) {
return 1;
}
}
// create RegExp Exclude Filter List
var regExpExcludeFilters = [];
filters = self.excludeFilters;
if (typeof(filters) === 'string')
filters = [ filters ];
return 0;
});
filters.forEach(function(filter) {
if (filter.length > 0)
regExpExcludeFilters.push( new RegExp(filter) );
}); // forEach
// create RegExp Exclude Filter List
var regExpExcludeFilters = [];
filters = self.excludeFilters;
if (typeof(filters) === 'string') {
filters = [ filters ];
}
// RegExp Exclude Filter
length = regExpExcludeFilters.length;
files = files.filter(function(filename) {
if (os.platform() === 'win32')
filename = filename.replace(/\\/g, '/');
filters.forEach(function(filter) {
if (filter.length > 0) {
regExpExcludeFilters.push( new RegExp(filter) );
}
});
// apply every filter
for(var i = 0; i < length; i += 1) {
if(regExpExcludeFilters[i].test(filename))
return 0;
}
return 1;
});
} catch (e) {
throw e;
} finally {
if ( ! files || files.length === 0)
throw new FileError('No files found.', self.path);
// RegExp Exclude Filter
length = regExpExcludeFilters.length;
files = files.filter(function(filename) {
if (os.platform() === 'win32') {
filename = filename.replace(/\\/g, '/');
}
// apply every filter
for(var i = 0; i < length; i += 1) {
if(regExpExcludeFilters[i].test(filename)) {
return 0;
}
}
return 1;
});
} catch (e) {
throw e;
} finally {
if ( ! files || files.length === 0) {
throw new FileError('No files found.', self.path);
}
return files;
// remove source path prefix
if (self.path !== './') {
files = files.map( function(filename) {
return filename.substr(self.path.length);
});
}
}
return files;
};

@@ -75,3 +75,3 @@ var util = require('util');

if ( ! block.local.version)
block.local.version = '0.0.0';
block.local.version = packageInfos.defaultVersion;

@@ -78,0 +78,0 @@ if ( ! block.local.filename)

@@ -34,3 +34,3 @@ var path = require('path');

var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

@@ -98,3 +98,3 @@ if ( ! result[target][name])

var name = block.local[target];
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

@@ -132,3 +132,3 @@

var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

@@ -135,0 +135,0 @@ var versionKeys = Object.keys(preProcess[source][name]);

@@ -33,3 +33,3 @@ var semver = require('semver');

var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

@@ -80,3 +80,3 @@ if ( ! result[target][name])

var name = definition.group;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

@@ -114,3 +114,3 @@

var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

@@ -117,0 +117,0 @@ var versionKeys = Object.keys(preProcess[source][name]);

@@ -33,3 +33,3 @@ var semver = require('semver');

var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

@@ -75,3 +75,3 @@ if ( ! result[target][name])

var name = definition.name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

@@ -110,3 +110,3 @@

var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

@@ -113,0 +113,0 @@ var versionKeys = Object.keys(preProcess[source][name]);

@@ -34,3 +34,3 @@ var _ = require('lodash');

var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

@@ -75,3 +75,3 @@ if ( ! result[target][name])

var name = definition.name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

@@ -98,3 +98,3 @@ if ( ! preProcess[source] || ! preProcess[source][name]) {

var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

@@ -101,0 +101,0 @@ var versionKeys = Object.keys(preProcess[source][name]);

{
"name": "apidoc-core",
"version": "0.7.1",
"version": "0.8.0",
"description": "Core parser library to generate apidoc result following the apidoc-spec",
"author": "Peter Rottmann <rottmann@inveris.de>",
"license": {
"type": "MIT",
"url": "https://github.com/apidoc/apidoc-core/blob/master/LICENSE"
},
"license": "MIT",
"main": "./lib/index.js",

@@ -36,15 +33,15 @@ "homepage": "https://github.com/apidoc/apidoc-core",

"dependencies": {
"glob": "^7.0.3",
"iconv-lite": "^0.4.13",
"lodash": "~4.11.1",
"semver": "~5.1.0",
"wrench": "~1.5.9"
"fs-extra": "^1.0.0",
"glob": "^7.1.1",
"iconv-lite": "^0.4.15",
"lodash": "~4.17.4",
"semver": "~5.3.0"
},
"devDependencies": {
"apidoc-example": "*",
"jshint": "~2.9.2",
"markdown-it": "^6.0.1",
"mocha": "~2.4.5",
"npm-check-updates": "^2.6.3",
"should": "~8.3.1"
"jshint": "~2.9.4",
"markdown-it": "^8.2.2",
"mocha": "~3.2.0",
"npm-check-updates": "^2.8.9",
"should": "~11.1.2"
},

@@ -51,0 +48,0 @@ "jshintConfig": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc