🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

api_doc

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api_doc - npm Package Compare versions

Comparing version

to
2017.3.9

@@ -72,2 +72,27 @@ #!/usr/bin/env node

local.moduleDirname = function (module) {
/*
* this function will return the __dirname of the module
*/
var result;
if (!module || module.indexOf('/') >= 0 || module === '.') {
return require('path').resolve(process.cwd(), module || '');
}
try {
require(module);
} catch (ignore) {
}
[
new RegExp('(.*?/' + module + ')\\b'),
new RegExp('(.*?/' + module + ')/[^/].*?$')
].some(function (rgx) {
return Object.keys(require.cache).some(function (key) {
result = rgx.exec(key);
result = result && result[1];
return result;
});
});
return result || '';
};
local.nop = function () {

@@ -89,3 +114,7 @@ /*

arg2 = arg[key];
defaults2 = defaults[key];
// handle misbehaving getter
try {
defaults2 = defaults[key];
} catch (ignore) {
}
if (defaults2 === undefined) {

@@ -119,12 +148,8 @@ return;

/*
* this function will replace '&' to '&amp;', '<' to '&lt;',
* and '>' to '&gt;' in the text to make it htmlSafe
* this function will make the text html-safe
*/
return text
.replace((/&/g), '&amp;')
.replace((/</g), '&lt;')
.replace((/>/g), '&gt;')
.replace((/"/g), '&quot;')
.replace((/'/g), '&#x27;')
.replace((/`/g), '&#x60;');
// new RegExp('[' + '"&\'<>'.split('').sort().join('') + ']', 'g')
return text.replace((/["&'<>]/g), function (match0) {
return '&#x' + match0.charCodeAt(0).toString(16) + ';';
});
};

@@ -221,3 +246,3 @@

/* jslint-ignore-begin */
local.templateApidoc = '\
local.templateApidocHtml = '\
<div class="apidocDiv">\n\

@@ -271,3 +296,3 @@ <style>\n\

</style>\n\
<h1>api documentation\n\
<h1>api-documentation for\n\
<a\n\

@@ -277,5 +302,8 @@ {{#if env.npm_package_homepage}}\n\

{{/if env.npm_package_homepage}}\n\
>({{env.npm_package_nameAlias}} v{{env.npm_package_version}})</a>\n\
>{{env.npm_package_nameAlias}} (v{{env.npm_package_version}})</a>\n\
</h1>\n\
<div class="apidocSectionDiv"><a href="#"><h1>table of contents</h1></a><ul>\n\
<div class="apidocSectionDiv"><a\n\
href="#apidoc.tableOfContents"\n\
id="apidoc.tableOfContents"\n\
><h1>table of contents</h1></a><ol>\n\
{{#each moduleList}}\n\

@@ -292,3 +320,3 @@ <li class="apidocModuleLi"><a href="#{{id}}">module {{name}}</a><ol>\n\

<span class="apidocSignatureSpan">{{name}}</span>\n\
{{/if source}}\n\
{{/if source}}\n\
</li>\n\

@@ -298,3 +326,3 @@ {{/each elementList}}\n\

{{/each moduleList}}\n\
</ul></div>\n\
</ol></div>\n\
{{#each moduleList}}\n\

@@ -320,3 +348,3 @@ <div class="apidocSectionDiv">\n\

<div class="apidocFooterDiv">\n\
[ this api documentation was created with\n\
[ this document was created with\n\
<a href="https://github.com/kaizhu256/node-utility2" target="_blank">utility2</a>\n\

@@ -327,2 +355,67 @@ ]\n\

';
local.templateApidocMd = '\
# api-documentation for \
{{#if env.npm_package_homepage}} \
[{{env.npm_package_nameAlias}} (v{{env.npm_package_version}})]({{env.npm_package_homepage}}) \
{{#unless env.npm_package_homepage}} \
{{env.npm_package_nameAlias}} (v{{env.npm_package_version}}) \
{{/if env.npm_package_homepage}} \
\n\
\n\
\n\
\n\
# <a name="apidoc.tableOfContents"></a>[table of contents](#apidoc.tableOfContents) \
{{#each moduleList}} \
\n\
\n\
#### [module {{name}}](#{{id}}) \
{{#each elementList}} \
\n\
1. \
{{#if source}} \
[{{name}} {{signature}}](#{{id}}) \
{{#unless source}} \
{{name}} \
{{/if source}} \
{{/each elementList}} \
{{/each moduleList}} \
{{#each moduleList}} \
\n\
\n\
\n\
\n\
# <a name="{{id}}"></a>[module {{name}}](#{{id}}) \
{{#each elementList}} \
{{#if source}} \
\n\
\n\
#### <a name="{{id}}"></a>[{{name}} {{signature}}](#{{id}}) \
\n\
- description and source-code \
\n\
```javascript \
\n\
{{source}} \
\n\
``` \
\n\
- example usage \
\n\
```shell \
\n\
{{example}} \
\n\
``` \
{{/if source}} \
{{/each elementList}} \
{{/each moduleList}} \
\n\
\n\
\n\
\n\
# misc \
\n\
- this document was created with [utility2](https://github.com/kaizhu256/node-utility2) \
\n';
/* jslint-ignore-end */

@@ -338,26 +431,20 @@

*/
var element,
elementCreate,
elementName,
module,
moduleAddConditional,
moduleExports,
tmp,
trimLeft;
elementCreate = function () {
var elementCreate, module, moduleMain, readExample, tmp, trimLeft;
elementCreate = function (module, prefix, key) {
/*
* this function will create the html-element
* this function will create the apidoc-element in the given module
*/
var element;
element = {};
element.moduleName = module.name.split('.');
// handle case where module.exports is a function
if (element.moduleName.slice(-1)[0] === elementName) {
element.moduleName = prefix.split('.');
// handle case where module is a function
if (element.moduleName.slice(-1)[0] === key) {
element.moduleName.pop();
}
element.moduleName = element.moduleName.join('.');
element.id = encodeURIComponent('element.' + module.name + '.' + elementName);
element.typeof = typeof module.exports[elementName];
element.id = encodeURIComponent('apidoc.element.' + prefix + '.' + key);
element.typeof = typeof module[key];
element.name = (element.typeof + ' <span class="apidocSignatureSpan">' +
element.moduleName + '.</span>' + elementName)
// handle case where module.exports is a function
element.moduleName + '.</span>' + key)
// handle case where module is a function
.replace('>.<', '');

@@ -368,7 +455,9 @@ if (element.typeof !== 'function') {

// init source
element.source = trimLeft(module.exports[elementName].toString());
element.source = trimLeft(module[key].toString());
if (element.source.length > 4096) {
element.source = element.source.slice(0, 4096).trimRight() + ' ...';
}
element.source = local.stringHtmlSafe(element.source)
element.source = (options.template === local.templateApidocHtml
? local.stringHtmlSafe(element.source)
: element.source.replace((/`/g), '_'))
.replace((/\([\S\s]*?\)/), function (match0) {

@@ -378,3 +467,4 @@ // init signature

.replace((/ *?\/\*[\S\s]*?\*\/ */g), '')
.replace((/,/g), ',\n');
.replace((/,/g), ', ')
.replace((/\s+/g), ' ');
return element.signature;

@@ -386,43 +476,35 @@ })

)
.replace((/^function \(/), elementName + ' = function (');
.replace((/^function \(/), key + ' = function (');
// init example
element.example = 'n/a';
module.example.replace(
new RegExp('((?:\n.*?){8}\\.)(' + elementName + ')(\\((?:.*?\n){8})'),
function (match0, match1, match2, match3) {
// jslint-hack
local.nop(match0);
element.example = '...' + trimLeft(local.stringHtmlSafe(match1) +
'<span class="apidocCodeKeywordSpan">' + match2 + '</span>' +
local.stringHtmlSafe(match3)).trimRight() + '\n...';
}
);
options.exampleList.some(function (example) {
example.replace(
new RegExp('((?:\n.*?){8}\\.)(' + key + ')(\\((?:.*?\n){8})'),
function (match0, match1, match2, match3) {
element.example = '...' + trimLeft(
options.template === local.templateApidocHtml
? local.stringHtmlSafe(match1) +
'<span class="apidocCodeKeywordSpan">' +
local.stringHtmlSafe(match2) +
'</span>' +
local.stringHtmlSafe(match3)
: match0.replace((/`/g), "'")
).trimRight() + '\n...';
}
);
return element.example;
});
element.example = element.example || 'n/a';
return element;
};
moduleAddConditional = function (prefix, name, parent) {
readExample = function (file) {
/*
* this function will conditionally add parent[name] to options.moduleDict[name]
* this function will read the example from the given file
*/
var child;
child = parent[name];
if ((/\W/).test(name) ||
options.moduleDict[prefix + '.' + name] ||
options.circularList.indexOf(child) >= 0) {
return;
try {
return ('\n\n\n\n\n\n\n\n' +
local.fs.readFileSync(local.path.resolve(options.dir, file), 'utf8') +
'\n\n\n\n\n\n\n\n').replace((/\r\n*/g), '\n');
} catch (errorCaught) {
return '';
}
tmp = [child, child && child.prototype].some(function (dict) {
return dict && Object.keys(dict).some(function (key) {
return typeof dict[key] === 'function';
});
});
if (!tmp) {
return;
}
options.circularList.push(child);
options.moduleDict[prefix + '.' + name] = {
exampleFileList: ['lib.' + name.split('.').slice(-1)[0] + '.js'],
exports: child
};
// recurse prototype
moduleAddConditional(prefix + '.' + name, 'prototype', child);
};

@@ -433,9 +515,10 @@ trimLeft = function (text) {

*/
tmp = '';
var whitespace;
whitespace = '';
text.trim().replace((/^ */gm), function (match0) {
if (!tmp || match0.length < tmp.length) {
tmp = match0;
if (!whitespace || match0.length < whitespace.length) {
whitespace = match0;
}
});
text = text.replace(new RegExp('^' + tmp, 'gm'), '');
text = text.replace(new RegExp('^' + whitespace, 'gm'), '');
// enforce 128 character column limit

@@ -449,51 +532,39 @@ while ((/^.{128}[^\\\n]/m).test(text)) {

options = local.objectSetDefault(options, {});
local.objectSetDefault(options, { dir: process.cwd() });
options.dir = local.path.resolve(process.cwd(), options.dir);
local.objectSetDefault(options, {
packageJson: JSON.parse(local.fs.readFileSync(options.dir + '/package.json'))
options.dir = local.moduleDirname(options.dir);
options = local.objectSetDefault(options, {
packageJson: JSON.parse(readExample('package.json'))
});
local.objectSetDefault(options, { env: {
npm_package_homepage: options.packageJson.homepage,
npm_package_nameAlias: options.packageJson.nameAlias,
npm_package_nameAlias: options.packageJson.nameAlias ||
options.packageJson.name,
npm_package_version: options.packageJson.version
} }, 2);
local.objectSetDefault(options, { env: {
npm_package_nameAlias: options.packageJson.name
} }, 2);
local.objectSetDefault(options, {
blacklistDict: { global: global },
circularList: [global],
exampleFileList: [
'README.md',
'test.js',
'test.' + options.env.npm_package_nameAlias + '.js',
options.env.npm_package_main,
options.env.npm_package_main + '.js',
'index.js',
'lib.' + options.env.npm_package_nameAlias + '.js'
],
exampleFileList: [],
exampleList: [],
html: '',
moduleDict: {}
moduleDict: {},
moduleExtraDict: {},
template: local.templateApidocHtml
});
local.objectSetDefault(options, {
example: options.exampleFileList.map(function (file) {
try {
return '\n\n\n\n\n\n\n\n' +
local.fs.readFileSync(
local.path.resolve(options.dir, file),
'utf8'
) +
'\n\n\n\n\n\n\n\n';
} catch (ignore) {
}
}).join('')
});
// init moduleDict
options.moduleDict[options.env.npm_package_nameAlias] =
options.moduleDict[options.env.npm_package_nameAlias] ||
{ exports: require(options.dir) };
// init exampleList
options.exampleList = options.exampleList.concat(options.exampleFileList.concat(
local.fs.readdirSync(options.dir)
.sort()
.filter(function (file) {
return file.indexOf(options.env.npm_package_main) === 0 ||
(/^(?:readme)\b/i).test(file) ||
(/^(?:index|lib|test)\b.*\.js$/i).test(file);
})
).map(readExample));
// init moduleMain
moduleMain = options.moduleDict[options.env.npm_package_nameAlias] =
options.moduleDict[options.env.npm_package_nameAlias] || require(options.dir);
// init circularList - builtin
Object.keys(process.binding('natives')).forEach(function (key) {
if (!(/\/|_linklist|sys/).test(key)) {
options.circularList.push(require(key));
options.blacklistDict[key] = options.blacklistDict[key] || require(key);
}

@@ -507,65 +578,61 @@ });

Object.keys(options.moduleDict).forEach(function (key) {
options.circularList.push(options.moduleDict[key].exports);
options.circularList.push(options.moduleDict[key]);
});
// init circularList - prototype
Object.keys(options.circularList).forEach(function (key) {
tmp = options.circularList[key];
options.circularList.push(tmp && tmp.prototype);
});
// cleanup circularList
tmp = options.circularList;
options.circularList = [];
tmp.forEach(function (element) {
if (options.circularList.indexOf(element) < 0) {
options.circularList.push(element);
}
});
// init moduleDict child
['child', 'grandchild', 'lib'].forEach(function (key) {
if (key === 'lib') {
try {
options.libFileList = options.libFileList ||
local.fs.readdirSync(options.dir + '/lib')
.map(function (file) {
return 'lib/' + file;
});
} catch (ignore) {
local.apidocModuleDictAdd(options, options.moduleDict);
// init moduleDict lib
(function () {
// optimization - isolate try-catch block
try {
options.libFileList = options.libFileList ||
local.fs.readdirSync(options.dir + '/lib')
.sort()
.map(function (file) {
return 'lib/' + file;
});
} catch (ignore) {
}
}());
module = options.moduleExtraDict[options.env.npm_package_nameAlias] =
options.moduleExtraDict[options.env.npm_package_nameAlias] || {};
(options.libFileList || []).forEach(function (file) {
try {
tmp = {
module: require(local.path.resolve(options.dir, file)),
name: local.path.basename(file)
.replace((/\.[^.]*?$/), '')
.replace((/\W/g), '_')
};
if (module[tmp.name] || options.circularList.indexOf(tmp.module) >= 0) {
return;
}
(options.libFileList || []).forEach(function (file) {
try {
tmp = options.moduleDict[options.env.npm_package_nameAlias].exports;
tmp[file.replace((/\W/g), '_')] = tmp[file.replace((/\W/g), '_')] ||
require(local.path.resolve(options.dir, file));
} catch (ignore) {
}
});
module[tmp.name] = tmp.module;
// update exampleList
options.exampleList.push(readExample(file));
} catch (ignore) {
}
Object.keys(options.moduleDict).forEach(function (prefix) {
moduleExports = options.moduleDict[prefix].exports;
// bug-workaround - buggy electron accessors
try {
Object.keys(moduleExports).forEach(function (name) {
moduleAddConditional(prefix, name, moduleExports);
});
} catch (ignore) {
}
});
// init moduleDict child.prototype
Object.keys(options.moduleDict).forEach(function (prefix) {
moduleExports = options.moduleDict[prefix].exports;
// bug-workaround - buggy electron accessors
try {
Object.keys(moduleExports).forEach(function (name) {
moduleAddConditional(
prefix + '.' + name,
'prototype',
moduleExports[name]
);
});
} catch (ignore) {
}
});
});
// init moduleDict.example
local.apidocModuleDictAdd(options, options.moduleExtraDict);
// normalize moduleMain
moduleMain = options.moduleDict[options.env.npm_package_nameAlias] =
local.objectSetDefault({}, moduleMain);
Object.keys(options.moduleDict).forEach(function (key) {
options.moduleDict[key].example =
(options.moduleDict[key].exampleFileList || [])
.map(function (file) {
try {
return '\n\n\n\n\n\n\n\n' +
local.fs.readFileSync(
local.path.resolve(options.dir, file),
'utf8'
) +
'\n\n\n\n\n\n\n\n';
} catch (ignore) {
}
}).join('') + options.example;
if (key.indexOf(options.env.npm_package_nameAlias + '.') !== 0) {
return;
}
tmp = key.split('.').slice(1).join('.');
moduleMain[tmp] = moduleMain[tmp] || options.moduleDict[key];
});

@@ -575,21 +642,17 @@ // init moduleList

.sort()
.map(function (key) {
module = local.objectSetDefault(options.moduleDict[key], {
example: '',
name: key
});
// handle case where module.exports is a function
tmp = module.exports;
if (typeof tmp === 'function') {
module.exports[module.name.split('.').slice(-1)[0]] =
module.exports[module.name.split('.').slice(-1)[0]] || tmp;
.map(function (prefix) {
module = options.moduleDict[prefix];
// handle case where module is a function
if (typeof module === 'function') {
module[prefix.split('.').slice(-1)[0]] =
module[prefix.split('.').slice(-1)[0]] || module;
}
return {
elementList: Object.keys(module.exports)
elementList: Object.keys(module)
.filter(function (key) {
try {
return key && key[0] !== '_' &&
!(/\W/).test(key) &&
return key &&
(/^\w[\w\-.]*?$/).test(key) &&
key.indexOf('testCase_') !== 0 &&
module.exports[key] !== options.blacklistDict[key];
module[key] !== options.blacklistDict[key];
} catch (ignore) {

@@ -599,4 +662,3 @@ }

.map(function (key) {
elementName = key;
return elementCreate();
return elementCreate(module, prefix, key);
})

@@ -608,8 +670,64 @@ .sort(function (aa, bb) {

}),
id: 'module.' + module.name,
name: module.name
id: encodeURIComponent('apidoc.module.' + prefix),
name: prefix
};
});
return local.templateRender(local.templateApidoc, options);
// render apidoc
return local.templateRender(options.template, options);
};
local.apidocModuleDictAdd = function (options, moduleDict) {
/*
* this function will add the modules in moduleDict to options.moduleDict
*/
var isModule, tmp;
['child', 'prototype', 'grandchild', 'prototype'].forEach(function (element) {
Object.keys(moduleDict).sort().forEach(function (prefix) {
if (!(/^\w[\w\-.]*?$/).test(prefix)) {
return;
}
Object.keys(moduleDict[prefix]).forEach(function (key) {
if (!(/^\w[\w\-.]*?$/).test(key)) {
return;
}
// bug-workaround - buggy electron accessors
try {
tmp = element === 'prototype'
? {
module: moduleDict[prefix][key].prototype,
name: prefix + '.' + key + '.prototype'
}
: {
module: moduleDict[prefix][key],
name: prefix + '.' + key
};
if (!tmp.module ||
!(typeof tmp.module === 'function' ||
typeof tmp.module === 'object') ||
options.moduleDict[tmp.name] ||
options.circularList.indexOf(tmp.module) >= 0) {
return;
}
isModule = [
tmp.module,
tmp.module.prototype
].some(function (dict) {
return Object.keys(dict || {}).some(function (key) {
try {
return typeof dict[key] === 'function';
} catch (ignore) {
}
});
});
if (!isModule) {
return;
}
options.circularList.push(tmp.module);
options.moduleDict[tmp.name] = tmp.module;
} catch (ignore) {
}
});
});
});
};
}());

@@ -634,5 +752,10 @@ switch (local.modeJs) {

// jslint files
process.stdout.write(local.apidocCreate({ dir: process.argv[2] }));
process.stdout.write(local.apidocCreate({
dir: process.argv[2],
template: process.argv[3] === '--markdown'
? local.templateApidocMd
: local.templateApidocHtml
}));
break;
}
}());

@@ -1,1 +0,1 @@

{"author":"kai zhu <kaizhu256@gmail.com>","bin":{"apidoc-lite":"lib.apidoc.js"},"description":"this zero-dependency package will auto-generate documentation for your npm-package with zero-config","devDependencies":{"electron-lite":"kaizhu256/node-electron-lite#alpha","utility2":"kaizhu256/node-utility2#alpha"},"engines":{"node":">=4.0"},"homepage":"https://github.com/kaizhu256/node-apidoc-lite","keywords":["api-doc","apidoc","doc","documentation","doxygen","javadoc"],"license":"MIT","main":"lib.apidoc.js","name":"api_doc","nameAlias":"apidoc","nameOriginal":"apidoc-lite","os":["darwin","linux"],"repository":{"type":"git","url":"https://github.com/kaizhu256/node-apidoc-lite.git"},"scripts":{"build-ci":"utility2 shReadmeBuild","deploy-github":"true","deploy-heroku":"true","env":"env","heroku-postbuild":"npm install 'kaizhu256/node-utility2#alpha' && utility2 shDeployHeroku","postinstall":"if [ -f lib.apidoc.npm-scripts.sh ]; then ./lib.apidoc.npm-scripts.sh postinstall; fi","publish-alias":"VERSION=$(npm info $npm_package_name version); for ALIAS in api_doc apidocs api-doctor doctor-api npm-doc npmdoc; do utility2 shNpmPublishAs . $ALIAS $VERSION; utility2 shNpmTestPublished $ALIAS || exit $?; done","start":"export PORT=${PORT:-8080} && export npm_config_mode_auto_restart=1 && utility2 start","test":"export PORT=$(utility2 shServerPortRandom) && utility2 test test.js","test-example-js":"true","test-example-sh":"utility2 shReadmeTestExampleSh","test-pre":"true","test-published":"utility2 shNpmTestPublished"},"version":"2017.2.27"}
{"author":"kai zhu <kaizhu256@gmail.com>","bin":{"apidoc-lite":"lib.apidoc.js"},"description":"this zero-dependency package will auto-generate documentation for your npm-package with zero-config","devDependencies":{"electron-lite":"kaizhu256/node-electron-lite#alpha","utility2":"kaizhu256/node-utility2#alpha"},"engines":{"node":">=4.0"},"homepage":"https://github.com/kaizhu256/node-apidoc-lite","keywords":["api-doc","apidoc","doc","documentation","doxygen","javadoc"],"license":"MIT","main":"lib.apidoc.js","name":"api_doc","nameAlias":"apidoc","nameOriginal":"apidoc-lite","os":["darwin","linux"],"readmeParse":"1","repository":{"type":"git","url":"https://github.com/kaizhu256/node-apidoc-lite.git"},"scripts":{"build-ci":"utility2 shReadmeTest build_ci.sh","env":"env","heroku-postbuild":"npm install 'kaizhu256/node-utility2#alpha' && utility2 shDeployHeroku","postinstall":"if [ -f lib.apidoc.npm_scripts.sh ]; then ./lib.apidoc.npm_scripts.sh postinstall; fi","publish-alias":"VERSION=$(npm info $npm_package_name version); for ALIAS in api_doc apidocs api-doctor doctor-api npm-doc npmdoc; do utility2 shNpmPublishAs . $ALIAS $VERSION; utility2 shNpmTestPublished $ALIAS || exit $?; done","start":"export PORT=${PORT:-8080} && export npm_config_mode_auto_restart=1 && utility2 start","test":"export PORT=$(utility2 shServerPortRandom) && utility2 test test.js"},"version":"2017.3.9"}

@@ -13,7 +13,2 @@ apidoc-lite

# cdn download
- [https://kaizhu256.github.io/node-apidoc-lite/build..beta..travis-ci.org/app/assets.apidoc.rollup.js](https://kaizhu256.github.io/node-apidoc-lite/build..beta..travis-ci.org/app/assets.apidoc.rollup.js)
# documentation

@@ -23,3 +18,3 @@ #### apidoc

[![apidoc](https://kaizhu256.github.io/node-apidoc-lite/build/screen-capture.apidoc.browser._2Fhome_2Ftravis_2Fbuild_2Fkaizhu256_2Fnode-apidoc-lite_2Ftmp_2Fbuild_2Fapidoc.html.png)](https://kaizhu256.github.io/node-apidoc-lite/build..beta..travis-ci.org/apidoc.html)
[![apidoc](https://kaizhu256.github.io/node-apidoc-lite/build/screen-capture.buildApidoc.browser._2Fhome_2Ftravis_2Fbuild_2Fkaizhu256_2Fnode-apidoc-lite_2Ftmp_2Fbuild_2Fapidoc.html.png)](https://kaizhu256.github.io/node-apidoc-lite/build..beta..travis-ci.org/apidoc.html)

@@ -29,5 +24,7 @@ #### todo

#### change since 9fe8c225
- npm publish 2017.2.27
- successful travis-ci build
#### change since dfed6414
- npm publish 2017.3.9
- add ability to create markdown documentation
- auto-document dir ./lib/
- increase auto-coverage of examples
- none

@@ -82,3 +79,3 @@

# auto-generate documentation for the mysql npm-package with zero-config
node_modules/.bin/apidoc-lite node_modules/mysql > /tmp/apidoc.html
node_modules/.bin/apidoc-lite mysql > /tmp/apidoc.html
)}

@@ -89,3 +86,3 @@ shExampleSh

#### output from browser
![screen-capture](https://kaizhu256.github.io/node-apidoc-lite/build/screen-capture.testExampleSh.browser._2Ftmp_2Fapidoc.html.png)
[![screen-capture](https://kaizhu256.github.io/node-apidoc-lite/build/screen-capture.testExampleSh.browser._2Ftmp_2Fapidoc.html.png)](https://kaizhu256.github.io/node-apidoc-lite/build..beta..travis-ci.org/apidoc.example.html)

@@ -130,2 +127,3 @@ #### output from shell

],
"readmeParse": "1",
"repository": {

@@ -136,17 +134,11 @@ "type": "git",

"scripts": {
"build-ci": "utility2 shReadmeBuild",
"deploy-github": "true",
"deploy-heroku": "true",
"build-ci": "utility2 shReadmeTest build_ci.sh",
"env": "env",
"heroku-postbuild": "npm install 'kaizhu256/node-utility2#alpha' && utility2 shDeployHeroku",
"postinstall": "if [ -f lib.apidoc.npm-scripts.sh ]; then ./lib.apidoc.npm-scripts.sh postinstall; fi",
"postinstall": "if [ -f lib.apidoc.npm_scripts.sh ]; then ./lib.apidoc.npm_scripts.sh postinstall; fi",
"publish-alias": "VERSION=$(npm info $npm_package_name version); for ALIAS in api_doc apidocs api-doctor doctor-api npm-doc npmdoc; do utility2 shNpmPublishAs . $ALIAS $VERSION; utility2 shNpmTestPublished $ALIAS || exit $?; done",
"start": "export PORT=${PORT:-8080} && export npm_config_mode_auto_restart=1 && utility2 start",
"test": "export PORT=$(utility2 shServerPortRandom) && utility2 test test.js",
"test-example-js": "true",
"test-example-sh": "utility2 shReadmeTestExampleSh",
"test-pre": "true",
"test-published": "utility2 shNpmTestPublished"
"test": "export PORT=$(utility2 shServerPortRandom) && utility2 test test.js"
},
"version": "2017.2.27"
"version": "2017.3.9"
}

@@ -163,38 +155,33 @@ ```

# internal build-script
- build.sh
- build_ci.sh
```shell
# build.sh
# build_ci.sh
# this shell script will run the build for this package
shBuild() {(set -e
# this function will run the main build
# init env
. node_modules/.bin/utility2 && shInit
# init github-gh-pages commit-limit
export COMMIT_LIMIT=20
case "$CI_BRANCH" in
alpha)
shBuildCiDefault
;;
beta)
shBuildCiDefault
;;
master)
shBuildCiDefault
git tag "$npm_package_version" || true
git push "git@github.com:$GITHUB_REPO.git" "$npm_package_version" || true
;;
publish)
printf "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > "$HOME/.npmrc"
export CI_BRANCH=alpha
shNpmPublishAs
shBuildCiDefault
npm run publish-alias
git push "git@github.com:$GITHUB_REPO.git" publish:beta
;;
esac
shBuildCiInternalPost() {(set -e
shReadmeBuildLinkVerify
)}
shBuild
shBuildCiInternalPre() {(set -e
shReadmeTest example.js
shReadmeTest example.sh
# save screen-capture
(export MODE_BUILD=testExampleSh &&
export url=/tmp/apidoc.html &&
utility2 shBrowserTest &&
cp /tmp/apidoc.html "$npm_config_dir_build/apidoc.example.html") || return $?
shNpmTestPublished
)}
shBuildCiPost() {(set -e
return
)}
shBuildCiPre() {(set -e
return
)}
# init env
eval $(utility2 source) && shBuildCi
```

@@ -201,0 +188,0 @@

@@ -43,9 +43,22 @@ /* istanbul instrument in package apidoc */

/*
* this function will test apidocCreate's handling-behavior
* this function will test apidocCreate's default handling-behavior-behavior
*/
// test libFilelist default handling-behavior
options = { dir: local.utility2.__dirname };
options = {
// test dir-custom handling-behavior
dir: local.utility2.__dirname
};
local.apidocCreate(options);
options = {
// test libFilelist-custom handling-behavior
libFileList: ['lib.apidoc.js', 'package.json'],
// test invalid module-name handling-behavior
moduleDict: { 'invalid syntax': {} },
// test packageJson default handling-behavior
packageJson: {},
// test markdown-template handling-behavior
template: local.templateApidocMd
};
local.apidocCreate(options);
local.testMock([
// test libFileList error handling-behavior
// test libFileList-error handling-behavior
[local.fs, { readdirSync: function () {

@@ -63,3 +76,3 @@ return ['undefined'];

/*
* this function will test buildApidoc's handling-behavior
* this function will test buildApidoc's default handling-behavior-behavior
*/

@@ -72,3 +85,3 @@ options = {};

/*
* this function will test buildApp's handling-behavior
* this function will test buildApp's default handling-behavior-behavior
*/

@@ -81,3 +94,3 @@ local.testCase_buildReadme_default(options, local.onErrorDefault);

/*
* this function will test buildReadme's handling-behavior
* this function will test buildReadme's default handling-behavior-behavior
*/

@@ -84,0 +97,0 @@ options = {};