Skip to content

Commit ab675fa

Browse files
committed
🙏
1 parent fc1cd13 commit ab675fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+216
-1205
lines changed

.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["flow"],
3+
"plugins": [
4+
"transform-es2015-modules-commonjs"
5+
]
6+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
coverage
22
.nyc_output
33
node_modules
4+
lib

lib/cli.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env node
2+
3+
4+
/* eslint no-console: 0 */
5+
6+
'use strict';
7+
8+
var yargs = require('yargs'),
9+
commands = require('./commands');
10+
11+
var argv = yargs.command(commands.serve).command(commands.build).command(commands.lint).command(commands.readme).fail(function (msg, error) {
12+
if (error) {
13+
throw error;
14+
} else {
15+
yargs.showHelp('error');
16+
console.error(msg);
17+
return yargs.exit(1);
18+
}
19+
}).version(function () {
20+
return require('../package').version;
21+
}).usage(`Usage:
22+
23+
# generate markdown docs for index.js and files it references
24+
$0 build index.js -f md
25+
26+
# generate html docs for all files in src
27+
$0 build src/** -f html -o docs
28+
29+
# document index.js, ignoring any files it requires or imports
30+
$0 build index.js -f md --shallow
31+
32+
# build, serve, and live-update html docs for app.js
33+
$0 serve app.js
34+
35+
# validate JSDoc syntax in util.js
36+
$0 lint util.js
37+
38+
# update the API section of README.md with docs from index.js
39+
$0 readme index.js --section=API
40+
41+
# build docs for all values exported by index.js
42+
$0 build --document-exported index.js
43+
`).recommendCommands().help().argv;
44+
45+
if (argv.private) {
46+
console.error('--private is deprecated, please use the --access (or -a) option instead');
47+
console.error('for example: -a public -a private -a protected -a undefined');
48+
}
49+
50+
if (!argv._handled) {
51+
yargs.showHelp('error');
52+
process.exit(1);
53+
}

index.js renamed to lib/index.js

Lines changed: 38 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
'use strict';
22

33
var fs = require('fs'),
4-
_ = require('lodash'),
5-
sort = require('./lib/sort'),
6-
nest = require('./lib/nest'),
7-
filterAccess = require('./lib/filter_access'),
8-
dependency = require('./lib/input/dependency'),
9-
shallow = require('./lib/input/shallow'),
10-
parseJavaScript = require('./lib/parsers/javascript'),
11-
polyglot = require('./lib/parsers/polyglot'),
12-
github = require('./lib/github'),
13-
hierarchy = require('./lib/hierarchy'),
14-
inferName = require('./lib/infer/name'),
15-
inferKind = require('./lib/infer/kind'),
16-
inferAugments = require('./lib/infer/augments'),
17-
inferParams = require('./lib/infer/params'),
18-
inferProperties = require('./lib/infer/properties'),
19-
inferMembership = require('./lib/infer/membership'),
20-
inferReturn = require('./lib/infer/return'),
21-
inferAccess = require('./lib/infer/access'),
22-
inferType = require('./lib/infer/type'),
23-
formatLint = require('./lib/lint').formatLint,
24-
garbageCollect = require('./lib/garbage_collect'),
25-
lintComments = require('./lib/lint').lintComments,
26-
markdownAST = require('./lib/output/markdown_ast'),
27-
mergeConfig = require('./lib/merge_config');
4+
_ = require('lodash'),
5+
sort = require('./sort'),
6+
nest = require('./nest'),
7+
getTyped = require('get-typed'),
8+
filterAccess = require('./filter_access'),
9+
dependency = require('./input/dependency'),
10+
shallow = require('./input/shallow'),
11+
parseJavaScript = require('./parsers/javascript'),
12+
polyglot = require('./parsers/polyglot'),
13+
github = require('./github'),
14+
hierarchy = require('./hierarchy'),
15+
inferName = require('./infer/name'),
16+
inferAugments = require('./infer/augments'),
17+
inferProperties = require('./infer/properties'),
18+
inferMembership = require('./infer/membership'),
19+
inferAccess = require('./infer/access'),
20+
formatLint = require('./lint').formatLint,
21+
garbageCollect = require('./garbage_collect'),
22+
lintComments = require('./lint').lintComments,
23+
markdownAST = require('./output/markdown_ast'),
24+
mergeConfig = require('./merge_config');
2825

2926
/**
3027
* Build a pipeline of comment handlers.
@@ -45,9 +42,7 @@ function pipeline() {
4542
};
4643
}
4744

48-
49-
50-
function configure(indexes, args)/*: Promise<InputsConfig> */ {
45+
function configure(indexes, args) /*: Promise<InputsConfig> */{
5146
let mergedConfig = mergeConfig(args);
5247

5348
return mergedConfig.then(config => {
@@ -71,8 +66,8 @@ function configure(indexes, args)/*: Promise<InputsConfig> */ {
7166
* @param {Object} config options
7267
* @returns {Promise<Array<string>>} promise with results
7368
*/
74-
function expandInputs(indexes/*: string|Array<string> */,
75-
config /*: DocumentationConfig */) {
69+
function expandInputs(indexes /*: string|Array<string> */
70+
, config /*: DocumentationConfig */) {
7671
// Ensure that indexes is an array of strings
7772
indexes = [].concat(indexes);
7873

@@ -91,21 +86,9 @@ function buildInternal(inputsAndConfig) {
9186
config.access = ['public', 'undefined', 'protected'];
9287
}
9388

94-
var parseFn = (config.polyglot) ? polyglot : parseJavaScript;
89+
var parseFn = config.polyglot ? polyglot : parseJavaScript;
9590

96-
var buildPipeline = pipeline(
97-
inferName,
98-
inferAccess(config.inferPrivate),
99-
inferAugments,
100-
inferKind,
101-
inferParams,
102-
inferProperties,
103-
inferReturn,
104-
inferMembership(),
105-
inferType,
106-
nest,
107-
config.github && github,
108-
garbageCollect);
91+
var buildPipeline = pipeline(inferName, inferAccess(config.inferPrivate), inferAugments, inferKind, inferParams, inferProperties, inferReturn, inferMembership(), inferType, nest, config.github && github, garbageCollect);
10992

11093
let extractedComments = _.flatMap(inputs, function (sourceFile) {
11194
if (!sourceFile.source) {
@@ -115,29 +98,16 @@ function buildInternal(inputsAndConfig) {
11598
return parseFn(sourceFile, config).map(buildPipeline);
11699
}).filter(Boolean);
117100

118-
return filterAccess(config.access,
119-
hierarchy(
120-
sort(extractedComments, config)));
101+
return filterAccess(config.access, hierarchy(sort(extractedComments, config)));
121102
}
122103

123104
function lintInternal(inputsAndConfig) {
124105
let inputs = inputsAndConfig.inputs;
125106
let config = inputsAndConfig.config;
126107

127-
let parseFn = (config.polyglot) ? polyglot : parseJavaScript;
108+
let parseFn = config.polyglot ? polyglot : parseJavaScript;
128109

129-
let lintPipeline = pipeline(
130-
lintComments,
131-
inferName,
132-
inferAccess(config.inferPrivate),
133-
inferAugments,
134-
inferKind,
135-
inferParams,
136-
inferProperties,
137-
inferReturn,
138-
inferMembership(),
139-
inferType,
140-
nest);
110+
let lintPipeline = pipeline(lintComments, inferName, inferAccess(config.inferPrivate), inferAugments, inferKind, inferParams, inferProperties, inferReturn, inferMembership(), inferType, nest);
141111

142112
let extractedComments = _.flatMap(inputs, sourceFile => {
143113
if (!sourceFile.source) {
@@ -183,8 +153,7 @@ function lintInternal(inputsAndConfig) {
183153
* }
184154
* });
185155
*/
186-
let lint = (indexes, args) => configure(indexes, args)
187-
.then(lintInternal);
156+
let lint = (indexes, args) => configure(indexes, args).then(lintInternal);
188157

189158
/**
190159
* Generate JavaScript documentation as a list of parsed JSDoc
@@ -227,8 +196,7 @@ let lint = (indexes, args) => configure(indexes, args)
227196
* // any other kind of code data.
228197
* });
229198
*/
230-
let build = (indexes, args) => configure(indexes, args)
231-
.then(buildInternal);
199+
let build = (indexes, args) => configure(indexes, args).then(buildInternal);
232200

233201
/**
234202
* Documentation's formats are modular methods that take comments
@@ -238,12 +206,10 @@ let build = (indexes, args) => configure(indexes, args)
238206
* @public
239207
*/
240208
var formats = {
241-
html: require('./lib/output/html'),
242-
md: require('./lib/output/markdown'),
243-
remark: (comments/*: Array<Comment> */, config/*: DocumentationConfig */) =>
244-
markdownAST(comments, config)
245-
.then(res => JSON.stringify(res, null, 2)),
246-
json: require('./lib/output/json')
209+
html: require('./output/html'),
210+
md: require('./output/markdown'),
211+
remark: (comments /*: Array<Comment> */, config /*: DocumentationConfig */) => markdownAST(comments, config).then(res => JSON.stringify(res, null, 2)),
212+
json: require('./output/json')
247213
};
248214

249215
module.exports.lint = lint;
@@ -252,6 +218,6 @@ module.exports.build = build;
252218
module.exports.formats = formats;
253219

254220
module.exports.util = {
255-
createFormatters: require('./lib/output/util/formatters'),
256-
LinkerStack: require('./lib/output/util/linker_stack')
257-
};
221+
createFormatters: require('./output/util/formatters'),
222+
LinkerStack: require('./output/util/linker_stack')
223+
};

lib/infer/kind.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy