Skip to content

refactor: Move index.js to lib #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion declarations/comment.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
type DocumentationConfig = {
polyglot?: boolean,
inferPrivate?: boolean,
inferPrivate?: string,
noPackage?: boolean,
toc?: Array<Object>,
paths?: { [key: string]: number },
access?: Array<string>,
defaultGlobals?: boolean,
defaultGlobalsEnvs?: Array<string>,
external?: Array<string>,
Expand Down
67 changes: 36 additions & 31 deletions index.js → lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

var fs = require('fs'),
_ = require('lodash'),
sort = require('./lib/sort'),
nest = require('./lib/nest'),
filterAccess = require('./lib/filter_access'),
dependency = require('./lib/input/dependency'),
shallow = require('./lib/input/shallow'),
parseJavaScript = require('./lib/parsers/javascript'),
polyglot = require('./lib/parsers/polyglot'),
github = require('./lib/github'),
hierarchy = require('./lib/hierarchy'),
inferName = require('./lib/infer/name'),
inferKind = require('./lib/infer/kind'),
inferAugments = require('./lib/infer/augments'),
inferParams = require('./lib/infer/params'),
inferProperties = require('./lib/infer/properties'),
inferMembership = require('./lib/infer/membership'),
inferReturn = require('./lib/infer/return'),
inferAccess = require('./lib/infer/access'),
inferType = require('./lib/infer/type'),
formatLint = require('./lib/lint').formatLint,
garbageCollect = require('./lib/garbage_collect'),
lintComments = require('./lib/lint').lintComments,
markdownAST = require('./lib/output/markdown_ast'),
mergeConfig = require('./lib/merge_config');
sort = require('./sort'),
nest = require('./nest'),
filterAccess = require('./filter_access'),
dependency = require('./input/dependency'),
shallow = require('./input/shallow'),
parseJavaScript = require('./parsers/javascript'),
polyglot = require('./parsers/polyglot'),
github = require('./github'),
hierarchy = require('./hierarchy'),
inferName = require('./infer/name'),
inferKind = require('./infer/kind'),
inferAugments = require('./infer/augments'),
inferParams = require('./infer/params'),
inferProperties = require('./infer/properties'),
inferMembership = require('./infer/membership'),
inferReturn = require('./infer/return'),
inferAccess = require('./infer/access'),
inferType = require('./infer/type'),
formatLint = require('./lint').formatLint,
garbageCollect = require('./garbage_collect'),
lintComments = require('./lint').lintComments,
markdownAST = require('./output/markdown_ast'),
mergeConfig = require('./merge_config');

/**
* Build a pipeline of comment handlers.
Expand All @@ -45,7 +45,10 @@ function pipeline() {
};
}

function configure(indexes, args) /*: Promise<InputsConfig> */ {
function configure(
indexes /*: Array<string> */,
args /*: Object */
) /*: Promise<InputsConfig> */ {
let mergedConfig = mergeConfig(args);

return mergedConfig.then(config => {
Expand Down Expand Up @@ -185,7 +188,8 @@ function lintInternal(inputsAndConfig) {
* }
* });
*/
let lint = (indexes, args) => configure(indexes, args).then(lintInternal);
let lint = (indexes /*: Array<string|Object> */, args) =>
configure(indexes, args).then(lintInternal);

/**
* Generate JavaScript documentation as a list of parsed JSDoc
Expand Down Expand Up @@ -228,7 +232,8 @@ let lint = (indexes, args) => configure(indexes, args).then(lintInternal);
* // any other kind of code data.
* });
*/
let build = (indexes, args) => configure(indexes, args).then(buildInternal);
let build = (indexes /*: Array<string|Object> */, args /*: Object */) =>
configure(indexes, args).then(buildInternal);

/**
* Documentation's formats are modular methods that take comments
Expand All @@ -238,11 +243,11 @@ let build = (indexes, args) => configure(indexes, args).then(buildInternal);
* @public
*/
var formats = {
html: require('./lib/output/html'),
md: require('./lib/output/markdown'),
html: require('./output/html'),
md: require('./output/markdown'),
remark: (comments /*: Array<Comment> */, config /*: DocumentationConfig */) =>
markdownAST(comments, config).then(res => JSON.stringify(res, null, 2)),
json: require('./lib/output/json')
json: require('./output/json')
};

module.exports.lint = lint;
Expand All @@ -251,6 +256,6 @@ module.exports.build = build;
module.exports.formats = formats;

module.exports.util = {
createFormatters: require('./lib/output/util/formatters'),
LinkerStack: require('./lib/output/util/linker_stack')
createFormatters: require('./output/util/formatters'),
LinkerStack: require('./output/util/linker_stack')
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"website"
],
"license": "ISC",
"main": "index.js",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "[email protected]:documentationjs/documentation.git"
Expand All @@ -90,7 +90,7 @@
"release": "standard-version",
"precommit": "lint-staged --verbose",
"format": "prettier --write '{lib,test}/**/*.js' --single-quote",
"doc": "./bin/documentation.js build index.js -f md --access=public > docs/NODE_API.md",
"doc": "./bin/documentation.js build lib/index.js -f md --access=public > docs/NODE_API.md",
"changelog": "standard-changelog -i CHANGELOG.md -w",
"self-lint": "node ./bin/documentation.js lint",
"test": "are-we-flow-yet lib && flow check && npm run self-lint && npm run test-tap",
Expand Down