diff --git a/.eslintrc b/.eslintrc index aa5b80ed0..375296eae 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,12 @@ { "root": true, - "parser": "espree", + "parser": "babel-eslint", + "parserOptions": { + "sourceType": "script" + }, + "plugins": [ + "flowtype" + ], "rules": { "space-in-parens": 2, "space-before-blocks": 2, @@ -21,8 +27,8 @@ "no-new": 2, "key-spacing": 2, "no-multi-spaces": 2, - "valid-jsdoc": 2, "brace-style": 2, + "object-shorthand": ["error", "always", { "avoidQuotes": true }], "no-throw-literal": 2, "no-self-compare": 2, "no-void": 2, @@ -32,13 +38,15 @@ "quotes": [2, "single"], "indent": [2, 2], "curly": 2, + "strict": [2, "global"], "no-shadow": 0, - "no-undef": 2 + "no-undef": 2, + "flowtype/define-flow-type": 1, + "flowtype/use-flow-type": 1 }, "extends": "eslint:recommended", "env": { "node": true, - "es6": true, - "browser": true + "es6": true } } diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 000000000..74fcf1e7d --- /dev/null +++ b/.flowconfig @@ -0,0 +1,12 @@ +[ignore] +.*node_modules/.cache/.* +.*node_modules/conventional-changelog-core/test/fixtures/.* +.*/test/fixture/.* + +[include] + +[libs] +declarations/ + +[options] +module.ignore_non_literal_requires=true diff --git a/README.md b/README.md index 59d8f9753..37e9f46b7 100644 --- a/README.md +++ b/README.md @@ -46,21 +46,21 @@ lets you run `documentation` as a [Gulp](http://gulpjs.com/) build task. ## Examples -* [HTML output with default template](http://documentation.js.org/html-example/) -* [Markdown](https://github.com/documentationjs/documentation/blob/master/docs/NODE_API.md) -* [JSON](http://documentation.js.org/html-example/index.json) +- [HTML output with default template](http://documentation.js.org/html-example/) +- [Markdown](https://github.com/documentationjs/documentation/blob/master/docs/NODE_API.md) +- [JSON](http://documentation.js.org/html-example/index.json) ## Documentation -* [Getting Started](docs/GETTING_STARTED.md): start here -* [Usage](docs/USAGE.md): how to use documentation.js -* [Recipes](docs/RECIPES.md): tricks for writing effective JSDoc docs -* [Node API](docs/NODE_API.md): documentation.js's self-generated documentation -* [Configuring documentation.js](docs/CONFIG.md) -* [FAQ](docs/FAQ.md) -* [Troubleshooting](docs/TROUBLESHOOTING.md) -* [Theming](docs/THEMING.md): tips for theming documentation output in HTML -* [See also](https://github.com/documentationjs/documentation/wiki/See-also): a list of projects similar to documentation.js +- [Getting Started](docs/GETTING_STARTED.md): start here +- [Usage](docs/USAGE.md): how to use documentation.js +- [Recipes](docs/RECIPES.md): tricks for writing effective JSDoc docs +- [Node API](docs/NODE_API.md): documentation.js's self-generated documentation +- [Configuring documentation.js](docs/CONFIG.md) +- [FAQ](docs/FAQ.md) +- [Troubleshooting](docs/TROUBLESHOOTING.md) +- [Theming](docs/THEMING.md): tips for theming documentation output in HTML +- [See also](https://github.com/documentationjs/documentation/wiki/See-also): a list of projects similar to documentation.js ## User Guide @@ -116,9 +116,9 @@ _We have plenty of [issues](https://github.com/documentationjs/documentation/issues) that we'd love help with._ -* Robust and complete `JSDoc` support, including typedefs. -* Strong support for HTML and Markdown output -* Documentation coverage, statistics, and validation +- Robust and complete `JSDoc` support, including typedefs. +- Strong support for HTML and Markdown output +- Documentation coverage, statistics, and validation documentation is an OPEN Open Source Project. This means that: diff --git a/bin/documentation.js b/bin/documentation.js index fc275553d..5bd322670 100755 --- a/bin/documentation.js +++ b/bin/documentation.js @@ -24,28 +24,29 @@ var argv = yargs .version(function () { return require('../package').version; }) - .usage('Usage:\n\n' + - '# generate markdown docs for index.js and files it references\n' + - '$0 build index.js -f md\n\n' + + .usage(`Usage: - '# generate html docs for all files in src\n' + - '$0 build src/** -f html -o docs\n\n' + + # generate markdown docs for index.js and files it references + $0 build index.js -f md - '# document index.js, ignoring any files it requires or imports\n' + - '$0 build index.js -f md --shallow\n\n' + + # generate html docs for all files in src + $0 build src/** -f html -o docs - '# build, serve, and live-update html docs for app.js\n' + - '$0 serve app.js\n\n' + + # document index.js, ignoring any files it requires or imports + $0 build index.js -f md --shallow - '# validate JSDoc syntax in util.js\n' + - '$0 lint util.js\n\n' + + # build, serve, and live-update html docs for app.js + $0 serve app.js - '# update the API section of README.md with docs from index.js\n' + - '$0 readme index.js --section=API\n\n' + + # validate JSDoc syntax in util.js + $0 lint util.js - '# build docs for all values exported by index.js\n' + - '$0 build --document-exported index.js' - ) + # update the API section of README.md with docs from index.js + $0 readme index.js --section=API + + # build docs for all values exported by index.js + $0 build --document-exported index.js +`) .recommendCommands() .help() .argv; diff --git a/declarations/comment.js b/declarations/comment.js new file mode 100644 index 000000000..a737ef123 --- /dev/null +++ b/declarations/comment.js @@ -0,0 +1,131 @@ +declare type DocumentationConfig = { + polyglot?: boolean, + inferPrivate?: boolean, + noPackage?: boolean, + toc?: Array, + paths?: { [key: string]: number }, + defaultGlobals?: boolean, + defaultGlobalsEnvs?: Array, + external?: Array, + theme: string, + requireExtension?: Array, + parseExtension: Array +}; + +declare type InputsConfig = { + inputs: Array, + config: DocumentationConfig +}; + +declare type CommentError = { + message: string, + commentLineNumber?: number +}; + +declare type DoctrineType = { + elements?: Array, + expression?: DoctrineType, + applications?: Array, + type: string, + name?: string +}; + +declare type CommentLoc = { + start: { + line: number + }, + end: { + line: number + } +}; + +declare type SourceFile = { + source?: string, + file: string +}; + +declare type CommentContext = { + sortKey: string, + file: string, + ast: Object, + loc: CommentLoc, + code: string, + github?: CommentContextGitHub +}; + +declare type CommentContextGitHub = { + path: string, + url: string +}; + +declare type CommentTag = { + name?: string, + title: string, + description?: Object, + default?: any, + lineNumber?: number, + type?: DoctrineType, + properties?: Array +}; + +declare type CommentMembers = { + static: Array, + instance: Array, + events: Array +}; + +declare type CommentExample = { + caption?: string, + description?: Object +}; + +declare type Remark = { + type: string, + children: Array +}; + +declare type Comment = { + errors: Array, + tags: Array, + + augments: Array, + errors: Array, + examples: Array, + params: Array, + properties: Array, + returns: Array, + sees: Array, + throws: Array, + todos: Array, + + description?: Remark, + summary?: Remark, + deprecated?: Remark, + classdesc?: Remark, + + members: CommentMembers, + + name?: string, + kind?: string, + memberof?: string, + scope?: string, + access?: string, + alias?: string, + + copyright?: string, + author?: string, + license?: string, + version?: string, + since?: string, + lends?: string, + override?: boolean, + + type?: DoctrineType, + + context: CommentContext, + + path?: Array<{ + name: string, + scope: string + }> +}; diff --git a/default_theme/index._ b/default_theme/index._ index 8cc488f59..1934773aa 100644 --- a/default_theme/index._ +++ b/default_theme/index._ @@ -2,7 +2,7 @@ - <%- options.name %> <%- options.version %> | Documentation + <%- config['project-name'] %> <%- config['project-version'] %> | Documentation @@ -13,8 +13,8 @@
-

<%- options.name %>

-
<%- options.version %>
+

<%- config['project-name'] %>

+
<%- config['project-version'] %>
*/, config/*: DocumentationConfig */) { - var linkerStack = createLinkerStack(options) + var linkerStack = new LinkerStack(config) .namespaceResolver(comments, function (namespace) { var slugger = new GithubSlugger(); return '#' + slugger.slug(namespace); @@ -21,15 +21,15 @@ module.exports = function (comments, options, callback) { var formatters = createFormatters(linkerStack.link); - hljs.configure(options.hljs || {}); + hljs.configure(config.hljs || {}); var sharedImports = { imports: { - slug: function (str) { + slug(str) { var slugger = new GithubSlugger(); return slugger.slug(str); }, - shortSignature: function (section) { + shortSignature(section) { var prefix = ''; if (section.kind === 'class') { prefix = 'new '; @@ -38,7 +38,7 @@ module.exports = function (comments, options, callback) { } return prefix + section.name + formatters.parameters(section, true); }, - signature: function (section) { + signature(section) { var returns = ''; var prefix = ''; if (section.kind === 'class') { @@ -46,13 +46,13 @@ module.exports = function (comments, options, callback) { } else if (section.kind !== 'function') { return section.name; } - if (section.returns) { + if (section.returns.length) { returns = ': ' + formatters.type(section.returns[0].type); } return prefix + section.name + formatters.parameters(section) + returns; }, - md: function (ast, inline) { + md(ast, inline) { if (inline && ast && ast.children.length && ast.children[0].type === 'paragraph') { ast = { type: 'root', @@ -63,8 +63,8 @@ module.exports = function (comments, options, callback) { }, formatType: formatters.type, autolink: formatters.autolink, - highlight: function (example) { - if (options.hljs && options.hljs.highlightAuto) { + highlight(example) { + if (config.hljs && config.hljs.highlightAuto) { return hljs.highlightAuto(example).value; } return hljs.highlight('js', example).value; @@ -79,14 +79,16 @@ module.exports = function (comments, options, callback) { var pageTemplate = _.template(fs.readFileSync(path.join(__dirname, 'index._'), 'utf8'), sharedImports); // push assets into the pipeline as well. - vfs.src([__dirname + '/assets/**'], { base: __dirname }) - .pipe(concat(function (files) { - callback(null, files.concat(new File({ - path: 'index.html', - contents: new Buffer(pageTemplate({ - docs: comments, - options: options - }), 'utf8') - }))); - })); + return new Promise(resolve => { + vfs.src([__dirname + '/assets/**'], { base: __dirname }) + .pipe(concat(function (files) { + resolve(files.concat(new File({ + path: 'index.html', + contents: new Buffer(pageTemplate({ + docs: comments, + config: config + }), 'utf8') + }))); + })); + }); }; diff --git a/index.js b/index.js index f79a7e30c..6ae6d0987 100644 --- a/index.js +++ b/index.js @@ -24,9 +24,7 @@ var fs = require('fs'), garbageCollect = require('./lib/garbage_collect'), lintComments = require('./lib/lint').lintComments, markdownAST = require('./lib/output/markdown_ast'), - loadConfig = require('./lib/load_config'); - -var parseExtensions = ['js', 'jsx', 'es5', 'es6']; + mergeConfig = require('./lib/merge_config'); /** * Build a pipeline of comment handlers. @@ -37,7 +35,7 @@ var parseExtensions = ['js', 'jsx', 'es5', 'es6']; */ function pipeline() { var elements = arguments; - return function (comment) { + return comment => { for (var i = 0; comment && i < elements.length; i++) { if (elements[i]) { comment = elements[i](comment); @@ -47,194 +45,109 @@ function pipeline() { }; } -/** - * Given an array of indexes and options for whether to resolve shallow - * or deep dependencies, resolve dependencies. - * - * @param {Array|string} indexes files to process - * @param {Object} options options - * @param {Function} callback called with results - * @returns {undefined} - */ -function expandInputs(indexes, options, callback) { - var inputFn; - if (options.polyglot || options.shallow || options.documentExported) { - inputFn = shallow; - } else { - inputFn = dependency; - } - options.parseExtensions = parseExtensions - .concat(options.parseExtension || []); - inputFn(indexes, options, callback); -} -/** - * Given an options object, it expands the `config` field - * if it exists. - * - * @param {Object} options - options to process - * @returns {undefined} - */ -function expandConfig(options) { - if (options && typeof options.config === 'string') { - Object.assign(options, loadConfig(options.config)); - } -} -/** - * Generate JavaScript documentation as a list of parsed JSDoc - * comments, given a root file as a path. - * - * @param {Array|string} indexes files to process - * @param {Object} options options - * @param {Array} options.external a string regex / glob match pattern - * that defines what external modules will be whitelisted and included in the - * generated documentation. - * @param {boolean} [options.polyglot=false] parse comments with a regex rather than - * a proper parser. This enables support of non-JavaScript languages but - * reduces documentation's ability to infer structure of code. - * @param {boolean} [options.shallow=false] whether to avoid dependency parsing - * even in JavaScript code. With the polyglot option set, this has no effect. - * @param {Array} [options.order=[]] optional array that - * defines sorting order of documentation - * @param {Array} [options.access=[]] an array of access levels - * to output in documentation - * @param {Object} [options.hljs] hljs optional options - * @param {boolean} [options.hljs.highlightAuto=false] hljs automatically detect language - * @param {Array} [options.hljs.languages] languages for hljs to choose from - * @param {string} [options.inferPrivate] a valid regular expression string - * to infer whether a code element should be private, given its naming structure. - * For instance, you can specify `inferPrivate: '^_'` to automatically treat - * methods named like `_myMethod` as private. - * @param {string|Array} [options.extension] treat additional file extensions - * as JavaScript, extending the default set of `js`, `es6`, and `jsx`. - * @param {Function} callback to be called when the documentation generation - * is complete, with (err, result) argumentsj - * @returns {undefined} calls callback - * @public - * @example - * var documentation = require('documentation'); - * - * documentation.build(['index.js'], { - * - * // only output comments with an explicit @public tag - * access: ['public'] - * - * }, function (err, res) { - * - * // res is an array of parsed comments with inferred properties - * // and more: everything you need to build documentation or - * // any other kind of code data. - * - * }); - */ -function build(indexes, options, callback) { - options = options || {}; +function configure(indexes, args)/*: Promise */ { + let mergedConfig = mergeConfig(args); - expandConfig(options); + return mergedConfig.then(config => { - if (typeof indexes === 'string') { - indexes = [indexes]; - } + let expandedInputs = expandInputs(indexes, config); - return expandInputs(indexes, options, function (error, inputs) { - if (error) { - return callback(error); - } - - var result; - try { - result = buildSync(inputs, options); - } catch (e) { - return callback(e); - } - callback(null, result); + return expandedInputs.then(inputs => { + return { + inputs, + config + }; + }); }); } /** - * Generate JavaScript documentation given a list of inputs. This internal - * method does not support require-following and it returns its results - * synchronously, rather than by calling a callback. - * - * @param {Array} indexes files to process - * @param {Object} options options - * @param {string} config path to configuration file to load - * @param {Array} options.external a string regex / glob match pattern - * that defines what external modules will be whitelisted and included in the - * generated documentation. - * @param {boolean} [options.polyglot=false] parse comments with a regex rather than - * a proper parser. This enables support of non-JavaScript languages but - * reduces documentation's ability to infer structure of code. - * @param {boolean} [options.shallow=false] whether to avoid dependency parsing - * even in JavaScript code. With the polyglot option set, this has no effect. - * @param {Array} [options.order=[]] optional array that - * defines sorting order of documentation - * @param {Array} [options.access=[]] an array of access levels - * to output in documentation - * @param {Object} [options.hljs] hljs optional options - * @param {boolean} [options.hljs.highlightAuto=false] hljs automatically detect language - * @param {Array} [options.hljs.languages] languages for hljs to choose from - * @param {string} [options.inferPrivate] a valid regular expression string - * to infer whether a code element should be private, given its naming structure. - * For instance, you can specify `inferPrivate: '^_'` to automatically treat - * methods named like `_myMethod` as private. - * @param {string|Array} [options.extension] treat additional file extensions - * as JavaScript, extending the default set of `js`, `es6`, and `jsx`. - * @returns {Object} list of results - * @public - * @example - * var documentation = require('documentation'); + * Given an array of indexes and options for whether to resolve shallow + * or deep dependencies, resolve dependencies. * - * var results = documentation.buildSync(['index.js']); - * // results is an array of parsed comments with inferred properties - * // and more: everything you need to build documentation or - * // any other kind of code data. + * @param {Array|string} indexes files to process + * @param {Object} config options + * @returns {Promise>} promise with results */ -function buildSync(indexes, options) { - options = options || {}; - options.hljs = options.hljs || {}; +function expandInputs(indexes/*: string|Array */, + config /*: DocumentationConfig */) { + // Ensure that indexes is an array of strings + indexes = [].concat(indexes); + + if (config.polyglot || config.shallow || config.documentExported) { + return shallow(indexes, config); + } - expandConfig(options); + return dependency(indexes, config); +} + +function buildInternal(inputsAndConfig) { + let config = inputsAndConfig.config; + let inputs = inputsAndConfig.inputs; - if (!options.access) { - options.access = ['public', 'undefined', 'protected']; + if (!config.access) { + config.access = ['public', 'undefined', 'protected']; } - var parseFn = (options.polyglot) ? polyglot : parseJavaScript; + var parseFn = (config.polyglot) ? polyglot : parseJavaScript; var buildPipeline = pipeline( - inferName(), - inferAccess(options.inferPrivate), - inferAugments(), - inferKind(), - inferParams(), - inferProperties(), - inferReturn(), + inferName, + inferAccess(config.inferPrivate), + inferAugments, + inferKind, + inferParams, + inferProperties, + inferReturn, inferMembership(), - inferType(), + inferType, nest, - options.github && github, + config.github && github, garbageCollect); - return filterAccess(options.access, + let extractedComments = _.flatMap(inputs, function (sourceFile) { + if (!sourceFile.source) { + sourceFile.source = fs.readFileSync(sourceFile.file, 'utf8'); + } + + return parseFn(sourceFile, config).map(buildPipeline); + }).filter(Boolean); + + return filterAccess(config.access, hierarchy( - sort( - _.flatMap(indexes, function (index) { - var indexObject = null; + sort(extractedComments, config))); +} + +function lintInternal(inputsAndConfig) { + let inputs = inputsAndConfig.inputs; + let config = inputsAndConfig.config; + + let parseFn = (config.polyglot) ? polyglot : parseJavaScript; - if (typeof index === 'string') { - indexObject = { - source: fs.readFileSync(index, 'utf8'), - file: index - }; - } else { - indexObject = index; - } + let lintPipeline = pipeline( + lintComments, + inferName, + inferAccess(config.inferPrivate), + inferAugments, + inferKind, + inferParams, + inferProperties, + inferReturn, + inferMembership(), + inferType, + nest); + + let extractedComments = _.flatMap(inputs, sourceFile => { + if (!sourceFile.source) { + sourceFile.source = fs.readFileSync(sourceFile.file, 'utf8'); + } + + return parseFn(sourceFile, config).map(lintPipeline); + }).filter(Boolean); - return parseFn(indexObject, options).map(buildPipeline); - }) - .filter(Boolean), options))); + return formatLint(hierarchy(extractedComments)); } /** @@ -243,30 +156,25 @@ function buildSync(indexes, options) { * of lint information intended for human-readable output. * * @param {Array|string} indexes files to process - * @param {Object} options options - * @param {Array} options.external a string regex / glob match pattern + * @param {Object} args args + * @param {Array} args.external a string regex / glob match pattern * that defines what external modules will be whitelisted and included in the * generated documentation. - * @param {boolean} [options.polyglot=false] parse comments with a regex rather than + * @param {boolean} [args.polyglot=false] parse comments with a regex rather than * a proper parser. This enables support of non-JavaScript languages but * reduces documentation's ability to infer structure of code. - * @param {boolean} [options.shallow=false] whether to avoid dependency parsing + * @param {boolean} [args.shallow=false] whether to avoid dependency parsing * even in JavaScript code. With the polyglot option set, this has no effect. - * @param {string} [options.inferPrivate] a valid regular expression string + * @param {string} [args.inferPrivate] a valid regular expression string * to infer whether a code element should be private, given its naming structure. * For instance, you can specify `inferPrivate: '^_'` to automatically treat * methods named like `_myMethod` as private. - * @param {string|Array} [options.extension] treat additional file extensions + * @param {string|Array} [args.extension] treat additional file extensions * as JavaScript, extending the default set of `js`, `es6`, and `jsx`. - * @param {Function} callback to be called when the documentation generation - * is complete, with (err, result) arguments - * @returns {undefined} calls callback + * @returns {Promise} promise with lint results * @public * @example - * documentation.lint('file.js', {}, function (err, lintOutput) { - * if (err) { - * throw err; - * } + * documentation.lint('file.js').then(lintOutput => { * if (lintOutput) { * console.log(lintOutput); * process.exit(1); @@ -275,47 +183,56 @@ function buildSync(indexes, options) { * } * }); */ -function lint(indexes, options, callback) { - options = options || {}; - - expandConfig(options); +let lint = (indexes, args) => configure(indexes, args) + .then(lintInternal); - if (typeof indexes === 'string') { - indexes = [indexes]; - } - - var parseFn = (options.polyglot) ? polyglot : parseJavaScript; - - var lintPipeline = pipeline( - lintComments, - inferName(), - inferAccess(options.inferPrivate), - inferAugments(), - inferKind(), - inferParams(), - inferProperties(), - inferReturn(), - inferMembership(), - inferType(), - nest); - - return expandInputs(indexes, options, function (error, inputs) { - if (error) { - return callback(error); - } - callback(null, - formatLint(hierarchy( - inputs - .reduce(function (memo, file) { - return memo.concat(parseFn(file, options).map(lintPipeline)); - }, []) - .filter(Boolean)))); - }); -} +/** + * Generate JavaScript documentation as a list of parsed JSDoc + * comments, given a root file as a path. + * + * @param {Array|string} indexes files to process + * @param {Object} args args + * @param {Array} args.external a string regex / glob match pattern + * that defines what external modules will be whitelisted and included in the + * generated documentation. + * @param {boolean} [args.polyglot=false] parse comments with a regex rather than + * a proper parser. This enables support of non-JavaScript languages but + * reduces documentation's ability to infer structure of code. + * @param {boolean} [args.shallow=false] whether to avoid dependency parsing + * even in JavaScript code. With the polyglot option set, this has no effect. + * @param {Array} [args.order=[]] optional array that + * defines sorting order of documentation + * @param {Array} [args.access=[]] an array of access levels + * to output in documentation + * @param {Object} [args.hljs] hljs optional args + * @param {boolean} [args.hljs.highlightAuto=false] hljs automatically detect language + * @param {Array} [args.hljs.languages] languages for hljs to choose from + * @param {string} [args.inferPrivate] a valid regular expression string + * to infer whether a code element should be private, given its naming structure. + * For instance, you can specify `inferPrivate: '^_'` to automatically treat + * methods named like `_myMethod` as private. + * @param {string|Array} [args.extension] treat additional file extensions + * as JavaScript, extending the default set of `js`, `es6`, and `jsx`. + * @returns {Promise} results + * @public + * @example + * var documentation = require('documentation'); + * + * documentation.build(['index.js'], { + * // only output comments with an explicit @public tag + * access: ['public'] + * }).then(res => { + * // res is an array of parsed comments with inferred properties + * // and more: everything you need to build documentation or + * // any other kind of code data. + * }); + */ +let build = (indexes, args) => configure(indexes, args) + .then(buildInternal); /** * Documentation's formats are modular methods that take comments - * and options as input and call a callback with writable objects, + * and config as input and return Promises with results, * like stringified JSON, markdown strings, or Vinyl objects for HTML * output. * @public @@ -323,21 +240,18 @@ function lint(indexes, options, callback) { var formats = { html: require('./lib/output/html'), md: require('./lib/output/markdown'), - remark: function (comments, options, callback) { - markdownAST(comments, options, function (err, res) { - callback(err, JSON.stringify(res, null, 2)); - }); - }, + remark: (comments/*: Array */, config/*: DocumentationConfig */) => + markdownAST(comments, config) + .then(res => JSON.stringify(res, null, 2)), json: require('./lib/output/json') }; module.exports.lint = lint; module.exports.expandInputs = expandInputs; -module.exports.buildSync = buildSync; module.exports.build = build; module.exports.formats = formats; module.exports.util = { createFormatters: require('./lib/output/util/formatters'), - createLinkerStack: require('./lib/output/util/linker_stack') + LinkerStack: require('./lib/output/util/linker_stack') }; diff --git a/lib/commands/build.js b/lib/commands/build.js index 633973dc1..c22a5d88a 100644 --- a/lib/commands/build.js +++ b/lib/commands/build.js @@ -1,7 +1,10 @@ +/* @flow */ 'use strict'; + var streamArray = require('stream-array'), sharedOptions = require('./shared_options'), + path = require('path'), fs = require('fs'), vfs = require('vinyl-fs'), extend = require('extend'), @@ -21,23 +24,13 @@ module.exports.describe = 'build documentation'; module.exports.builder = extend({}, sharedOptions.sharedOutputOptions, sharedOptions.sharedInputOptions, { - format: { - alias: 'f', - default: 'json', - choices: ['json', 'md', 'remark', 'html'] - }, - 'markdown-toc': { - describe: 'include a table of contents in markdown output', - default: true, - type: 'boolean' - }, + example: 'documentation build foo.js -f md > API.md', output: { describe: 'output location. omit for stdout, otherwise is a filename ' + 'for single-file outputs and a directory name for multi-file outputs like html', default: 'stdout', alias: 'o' - }, - example: 'documentation build foo.js -f md > API.md' + } }); /* @@ -48,44 +41,49 @@ module.exports.builder = extend({}, * The former case, with the callback, is used by the `serve` command, which is * just a thin wrapper around this one. */ -module.exports.handler = function build(argv, callback) { +module.exports.handler = function build(argv/*: Object*/) { + var watcher; argv._handled = true; - argv = sharedOptions.expandInputs(argv); - if (argv.f === 'html' && argv.o === 'stdout') { - throw new Error('The HTML output mode requires a destination directory set with -o'); - } - - var generator = documentation.build - .bind(null, argv.input, argv, onDocumented); - function onDocumented(err, comments) { - if (err) { - if (typeof callback === 'function') { - return callback(err); - } - throw err; + if (!argv.input.length) { + try { + argv.input = [JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')).main || 'index.js']; + } catch (e) { + throw new Error('documentation was given no files and was not run in a module directory'); } + } - var formatterOptions = { - name: argv.name || (argv.package || {}).name, - version: argv['project-version'] || (argv.package || {}).version, - theme: argv.theme, - paths: argv.paths, - markdownToc: argv.markdownToc, - hljs: argv.hljs || {} - }; + if (argv.f === 'html' && argv.o === 'stdout') { + throw new Error('The HTML output mode requires a destination directory set with -o'); + } - documentation.formats[argv.format](comments, formatterOptions, onFormatted); + function generator() { + return documentation.build(argv.input, argv) + .then(comments => + documentation.formats[argv.format](comments, argv) + .then(onFormatted)) + .catch(err => { + /* eslint no-console: 0 */ + if (err instanceof Error) { + console.error(err.stack); + } else { + console.error(err); + } + process.exit(1); + }); } - function onFormatted(err, output) { + function onFormatted(output) { if (argv.watch) { updateWatcher(); } - if (typeof callback === 'function') { - callback(null, output); - } else if (argv.output === 'stdout') { + if (argv.output === 'stdout') { + if (argv.watch) { + // In watch mode, clear the screen first to make updated outputs + // obvious. + process.stdout.write('\u001b[2J'); + } process.stdout.write(output); } else if (Array.isArray(output)) { streamArray(output).pipe(vfs.dest(argv.output)); @@ -94,19 +92,15 @@ module.exports.handler = function build(argv, callback) { } } - if (argv.watch) { - var watcher = chokidar.watch(argv.input); - watcher.on('all', debounce(generator, 300)); - } - generator(); - function updateWatcher() { - documentation.expandInputs(argv.input, argv, addNewFiles); + if (!watcher) { + watcher = chokidar.watch(argv.input); + watcher.on('all', debounce(generator, 300)); + } + documentation.expandInputs(argv.input, argv).then(files => + watcher.add(files.map(data => + typeof data === 'string' ? data : data.file))); } - function addNewFiles(err, files) { - watcher.add(files.map(function (data) { - return typeof data === 'string' ? data : data.file; - })); - } + return generator(); }; diff --git a/lib/commands/index.js b/lib/commands/index.js index 3bce6d3ae..8f09831ff 100644 --- a/lib/commands/index.js +++ b/lib/commands/index.js @@ -1,3 +1,6 @@ +/* @flow */ +'use strict'; + /* * Maps command name to a command plugin module. Each command plugin module * must export a function that takes (documentation, parsedArgs), where @@ -10,8 +13,8 @@ */ module.exports = { - 'build': require('./build'), - 'serve': require('./serve'), - 'lint': require('./lint'), - 'readme': require('./readme') + build: require('./build'), + serve: require('./serve'), + lint: require('./lint'), + readme: require('./readme') }; diff --git a/lib/commands/lint.js b/lib/commands/lint.js index 60020a6af..1e7acad44 100644 --- a/lib/commands/lint.js +++ b/lib/commands/lint.js @@ -1,7 +1,9 @@ +/* @flow */ 'use strict'; var documentation = require('../../'); -var sharedOptions = require('./shared_options'); +var fs = require('fs'); +var path = require('path'); /* eslint no-console: 0 */ @@ -17,18 +19,25 @@ module.exports.builder = {}; * @returns {undefined} has side-effects * @private */ -module.exports.handler = function (argv) { +module.exports.handler = function (argv/*: Object*/) { argv._handled = true; - argv = sharedOptions.expandInputs(argv); - documentation.lint(argv.input, argv, function (err, lintOutput) { - if (err) { - throw err; + if (!argv.input.length) { + try { + argv.input = [JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')).main || 'index.js']; + } catch (e) { + throw new Error('documentation was given no files and was not run in a module directory'); } + } + documentation.lint(argv.input, argv).then(lintOutput => { if (lintOutput) { console.log(lintOutput); process.exit(1); } else { process.exit(0); } + }).catch(err => { + /* eslint no-console: 0 */ + console.error(err); + process.exit(1); }); }; diff --git a/lib/commands/readme.js b/lib/commands/readme.js index 7c4986709..b72c6b46f 100644 --- a/lib/commands/readme.js +++ b/lib/commands/readme.js @@ -1,12 +1,14 @@ +/* @flow */ 'use strict'; + var fs = require('fs'); var remark = require('remark'); -var sharedOptions = require('./shared_options'); +var path = require('path'); +var documentation = require('../../'); var inject = require('mdast-util-inject'); var chalk = require('chalk'); var disparity = require('disparity'); -var build = require('./build'); module.exports.command = 'readme [input..]'; module.exports.description = 'inject documentation into your README.md'; @@ -19,6 +21,7 @@ module.exports.description = 'inject documentation into your README.md'; module.exports.builder = { usage: 'Usage: documentation readme [--readme-file=README.md] --section "API"' + ' [--compare-only] [other documentationjs options]', + example: 'documentation readme index.js -s "API Docs" --github', 'readme-file': { describe: 'The markdown file into which to inject documentation', default: 'README.md' @@ -38,8 +41,7 @@ module.exports.builder = { alias: 'q', describe: 'Quiet mode: do not print messages or README diff to stdout.', default: false - }, - example: 'documentation readme index.js -s "API Docs" --github' + } }; function noop() {} @@ -50,57 +52,59 @@ function noop() {} * @param {Object} argv args from the CLI option parser * @return {undefined} has the side-effect of writing a file or printing to stdout */ -module.exports.handler = function readme(argv) { +module.exports.handler = function readme(argv/*: Object*/) { argv._handled = true; - argv = sharedOptions.expandInputs(argv); - argv.format = 'remark'; - /* eslint no-console: 0 */ - var log = argv.q ? noop : console.log.bind(console, '[documentation-readme] '); - var readmeFile = argv['readme-file']; - - build.handler(argv, onAst); - function onAst(err, docsAst) { - if (err) { - throw err; + if (!argv.input.length) { + try { + argv.input = [JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')).main || 'index.js']; + } catch (e) { + throw new Error('documentation was given no files and was not run in a module directory'); } - var readmeContent = fs.readFileSync(readmeFile, 'utf8'); - remark().use(plugin, { - section: argv.section, - toInject: JSON.parse(docsAst) - }).process(readmeContent, onInjected.bind(null, readmeContent)); } - function onInjected(readmeContent, err, file) { + argv.format = 'remark'; + /* eslint no-console: 0 */ + var log = argv.q ? noop : console.log.bind(console, '[documentation-readme] '); - if (err) { - throw err; - } + var readmeContent = fs.readFileSync(argv.readmeFile, 'utf8'); - var diffOutput = disparity.unified(readmeContent, file.contents, { - paths: [readmeFile, readmeFile] - }); - if (!diffOutput.length) { - log(readmeFile + ' is up to date.'); - process.exit(0); - } + documentation.build(argv.input, argv) + .then(comments => + documentation.formats.remark(comments, argv)) + .then(docsAst => remark().use(plugin, { + section: argv.section, + toInject: JSON.parse(docsAst) + }).process(readmeContent)) + .then(file => { + var diffOutput = disparity.unified(readmeContent, file.contents, { + paths: [argv.readmeFile, argv.readmeFile] + }); + if (!diffOutput.length) { + log(`${argv.readmeFile} is up to date.`); + process.exit(0); + } - if (argv.d) { - log(chalk.bold(readmeFile + ' needs the following updates:'), '\n' + diffOutput); - process.exit(1); - } else { - log(chalk.bold('Updating ' + readmeFile), '\n' + diffOutput); - } + if (argv.d) { + log(chalk.bold(`${argv.readmeFile} needs the following updates:`), `\n${diffOutput}`); + process.exit(1); + } else { + log(chalk.bold(`Updating ${argv.readmeFile}`), `\n${diffOutput}`); + } - fs.writeFileSync(readmeFile, file.contents); - } + fs.writeFileSync(argv.readmeFile, file.contents); + }) + .catch(err => { + console.error(err); + process.exit(1); + }); }; // wrap the inject utility as an remark plugin function plugin(remark, options) { return function transform(targetAst, file, next) { if (!inject(options.section, targetAst, options.toInject)) { - return next(new Error('Heading ' + options.section + ' not found.')); + return next(new Error(`Heading ${options.section} not found.`)); } next(); }; diff --git a/lib/commands/serve.js b/lib/commands/serve.js index 410cbcc0e..c25349a07 100644 --- a/lib/commands/serve.js +++ b/lib/commands/serve.js @@ -1,11 +1,15 @@ +/* @flow */ 'use strict'; var errorPage = require('../../lib/serve/error_page'), + fs = require('fs'), extend = require('extend'), + path = require('path'), + chokidar = require('chokidar'), sharedOptions = require('./shared_options'), - Server = require('../../lib/serve/server'); - -var build = require('./build').handler; + Server = require('../../lib/serve/server'), + debounce = require('debounce'), + documentation = require('../../'); module.exports.command = 'serve [input..]'; module.exports.description = 'generate, update, and display HTML documentation'; @@ -34,16 +38,53 @@ module.exports.builder = extend( * @param {Object} argv cli input * @returns {undefined} has side effects */ -module.exports.handler = function serve(argv) { +module.exports.handler = function serve(argv/*: Object*/) { argv._handled = true; + + if (!argv.input.length) { + try { + argv.input = [JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')).main || 'index.js']; + } catch (e) { + throw new Error('documentation was given no files and was not run in a module directory'); + } + } + var server = new Server(argv.port); + var watcher; + server.on('listening', function () { - process.stdout.write('documentation.js serving on port ' + argv.port + '\n'); + process.stdout.write(`documentation.js serving on port ${argv.port}\n`); }); - build(extend({}, { format: 'html' }, argv), function (err, output) { - if (err) { - return server.setFiles([errorPage(err)]).start(); + + function updateWatcher() { + if (!watcher) { + watcher = chokidar.watch(argv.input); + watcher.on('all', debounce(updateServer, 300)); } - server.setFiles(output).start(); - }); + + documentation.expandInputs(argv.input, argv) + .then(files => { + watcher.add(files.map(data => + typeof data === 'string' ? data : data.file)); + }).catch(err => { + /* eslint no-console: 0 */ + return server.setFiles([errorPage(err)]).start(); + }); + } + + function updateServer() { + documentation.build(argv.input, argv) + .then(comments => + documentation.formats.html(comments, argv)) + .then(files => { + if (argv.watch) { + updateWatcher(); + } + server.setFiles(files).start(); + }).catch(err => { + return server.setFiles([errorPage(err)]).start(); + }); + } + + updateServer(); }; diff --git a/lib/commands/shared_options.js b/lib/commands/shared_options.js index 192757f27..d50c45930 100644 --- a/lib/commands/shared_options.js +++ b/lib/commands/shared_options.js @@ -1,13 +1,11 @@ -var path = require('path'); +/* @flow */ +'use strict'; /** * Adds shared options to any command that runs documentation - * - * @param {Object} parser yargs object - * @returns {Object} same yargs object with options - * @private */ module.exports.sharedInputOptions = { + strict: true, 'shallow': { describe: 'shallow mode turns off dependency resolution, ' + 'only processing the specified files (or the main script specified in package.json)', @@ -19,26 +17,28 @@ module.exports.sharedInputOptions = { alias: 'c', type: 'string' }, + 'no-package': { + describe: 'dont find and use package.json for project- configuration option defaults', + alias: 'np', + type: 'boolean', + default: false + }, 'external': { describe: 'a string / glob match pattern that defines which external ' + 'modules will be whitelisted and included in the generated documentation.', default: null }, - 'requireExtension': { + 'require-extension': { describe: 'additional extensions to include in require() and import\'s search algorithm.' + 'For instance, adding .es5 would allow require("adder") to find "adder.es5"', - coerce: function (value) { - // Ensure that the value is an array - return [].concat(value); - }, + // Ensure that the value is an array + coerce: (value/*: string | Array*/) => [].concat(value), alias: 're' }, - 'parseExtension': { + 'parse-extension': { describe: 'additional extensions to parse as source code.', - coerce: function (value) { - // Ensure that the value is an array - return [].concat(value); - }, + // Ensure that the value is an array + coerce: (value/*: string | Array*/) => [].concat(value), alias: 'pe' }, 'polyglot': { @@ -85,40 +85,34 @@ module.exports.sharedInputOptions = { /** * Adds shared options to any command that runs documentation - * - * @param {Object} parser yargs object - * @returns {Object} same yargs object with options - * @private */ module.exports.sharedOutputOptions = { theme: { describe: 'specify a theme: this must be a valid theme module', alias: 't' }, - name: { + 'project-name': { describe: 'project name. by default, inferred from package.json' }, + 'project-version': { + describe: 'project version. by default, inferred from package.json' + }, + 'project-homepage': { + describe: 'project homepage. by default, inferred from package.json' + }, + format: { + alias: 'f', + default: 'json', + choices: ['json', 'md', 'remark', 'html'] + }, watch: { describe: 'watch input files and rebuild documentation when they change', alias: 'w', type: 'boolean' }, - 'project-version': { - describe: 'project version. by default, inferred from package.json' - } -}; - -module.exports.expandInputs = function (argv) { - if (argv.input === undefined || argv.input.length == 0) { - try { - var p = require(path.resolve('package.json')); - argv.package = p; - argv.input = [p.main || 'index.js']; - return argv; - } catch (e) { - throw new Error('documentation was given no files and was not run in a module directory'); - } - } else { - return argv; + 'markdown-toc': { + describe: 'include a table of contents in markdown output', + default: true, + type: 'boolean' } }; diff --git a/lib/extractors/comments.js b/lib/extractors/comments.js index 720bfef5f..b0da981b3 100644 --- a/lib/extractors/comments.js +++ b/lib/extractors/comments.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var traverse = require('babel-traverse').default, isJSDocComment = require('../../lib/is_jsdoc_comment'); @@ -5,15 +7,19 @@ var traverse = require('babel-traverse').default, * Iterate through the abstract syntax tree, finding a different kind of comment * each time, and optionally including context. This is how we find * JSDoc annotations that will become part of documentation - * @param {string} type comment type to find - * @param {boolean} includeContext to include context in the nodes - * @param {Object} ast the babel-parsed syntax tree - * @param {Object} data the filename and the source of the file the comment is in - * @param {Function} addComment a method that creates a new comment if necessary - * @returns {Array} comments + * @param type comment type to find + * @param includeContext to include context in the nodes + * @param ast the babel-parsed syntax tree + * @param data the filename and the source of the file the comment is in + * @param addComment a method that creates a new comment if necessary + * @returns comments * @private */ -function walkComments(type, includeContext, ast, data, addComment) { +function walkComments(type/*: string*/, + includeContext/*: boolean*/, + ast/*: Object*/, + data/*: Object*/, + addComment/*: Function*/)/*: Array*/ { var newResults = []; traverse(ast, { @@ -23,7 +29,7 @@ function walkComments(type, includeContext, ast, data, addComment) { * @returns {undefined} causes side effects * @private */ - enter: function (path) { + enter(path) { /** * Parse a comment with doctrine and decorate the result with file position and code context. * diff --git a/lib/extractors/exported.js b/lib/extractors/exported.js index 89bb9d7a0..9b80aa00a 100644 --- a/lib/extractors/exported.js +++ b/lib/extractors/exported.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var traverse = require('babel-traverse').default, isJSDocComment = require('../../lib/is_jsdoc_comment'), t = require('babel-types'), @@ -17,7 +19,9 @@ var traverse = require('babel-traverse').default, * @returns {Array} comments * @private */ -function walkExported(ast, data, addComment) { +function walkExported(ast/*: Object */, data/*: { + file: string +} */, addComment/*: Function */) { var newResults = []; var filename = data.file; var dataCache = Object.create(null); @@ -55,10 +59,10 @@ function walkExported(ast, data, addComment) { } traverse(ast, { - Statement: function (path) { + Statement(path) { path.skip(); }, - ExportDeclaration: function (path) { + ExportDeclaration(path) { var declaration = path.get('declaration'); if (t.isDeclaration(declaration)) { traverseExportedSubtree(declaration, data, addComments); @@ -80,7 +84,7 @@ function walkExported(ast, data, addComment) { var specifiers = path.get('specifiers'); var source = path.node.source; var exportKind = path.node.exportKind; - specifiers.forEach(function (specifier) { + specifiers.forEach(specifier => { var specData = data; var local, exported; if (t.isExportDefaultSpecifier(specifier)) { @@ -131,11 +135,11 @@ function traverseExportedSubtree(path, data, addComments, overrideName) { if (path.isClass() || path.isObjectExpression()) { path.traverse({ - Property: function (path) { + Property(path) { addComments(data, path); path.skip(); }, - Method: function (path) { + Method(path) { addComments(data, path); path.skip(); } @@ -158,7 +162,7 @@ function getCachedData(dataCache, filePath) { file: path, source: input }, - ast: ast + ast }; dataCache[path] = value; } @@ -174,10 +178,10 @@ function findExportDeclaration(dataCache, name, exportKind, referrer, filename) var rv; traverse(ast, { - Statement: function (path) { + Statement(path) { path.skip(); }, - ExportDeclaration: function (path) { + ExportDeclaration(path) { if (name === 'default' && path.isExportDefaultDeclaration()) { rv = path.get('declaration'); path.stop(); @@ -247,7 +251,7 @@ function findExportDeclaration(dataCache, name, exportKind, referrer, filename) return { ast: rv, - data: data + data }; } @@ -256,10 +260,10 @@ function findExportDeclaration(dataCache, name, exportKind, referrer, filename) function findLocalType(scope, local) { var rv; scope.path.traverse({ - Statement: function (path) { + Statement(path) { path.skip(); }, - TypeAlias: function (path) { + TypeAlias(path) { if (path.node.id.name === local) { rv = path; path.stop(); diff --git a/lib/filter_access.js b/lib/filter_access.js index d32564b64..c5ce346a1 100644 --- a/lib/filter_access.js +++ b/lib/filter_access.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var walk = require('./walk'); @@ -11,7 +13,7 @@ var walk = require('./walk'); * @param {Array} comments parsed comments (can be nested) * @return {Array} filtered comments */ -function filterAccess(levels, comments) { +function filterAccess(levels/*: Array*/, comments/*: Array*/) { levels = levels || ['public', 'undefined', 'protected']; function filter(comment) { diff --git a/lib/flow_doctrine.js b/lib/flow_doctrine.js index 6300be392..a7e46c07b 100644 --- a/lib/flow_doctrine.js +++ b/lib/flow_doctrine.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var namedTypes = { 'NumberTypeAnnotation': 'number', @@ -47,12 +49,13 @@ function propertyToField(property) { * @param {Object} type babel-parsed flow type * @returns {Object} doctrine compatible type */ -function flowDoctrine(type) { +function flowDoctrine(type/*: Object */)/*: DoctrineType*/ { if (type.type in namedTypes) { - return { + let doctrineType = { type: 'NameExpression', name: namedTypes[type.type] }; + return doctrineType; } if (type.type in oneToOne) { @@ -94,7 +97,7 @@ function flowDoctrine(type) { case 'FunctionTypeAnnotation': return { type: 'FunctionType', - params: type.params.map(function (param) { + params: type.params.map(param => { return { type: 'ParameterType', name: param.name.name, @@ -141,6 +144,10 @@ function flowDoctrine(type) { value: type.value }; } + + return { + type: 'AllLiteral' + }; } module.exports = flowDoctrine; diff --git a/lib/garbage_collect.js b/lib/garbage_collect.js index 79b8ed36b..94816c729 100644 --- a/lib/garbage_collect.js +++ b/lib/garbage_collect.js @@ -1,4 +1,6 @@ -function garbageCollect(comment) { +/* @flow */ +'use strict'; +function garbageCollect(comment/*: Comment*/) { delete comment.context.code; delete comment.context.ast; return comment; diff --git a/lib/git/find_git.js b/lib/git/find_git.js index 097ac2c4d..beb029449 100644 --- a/lib/git/find_git.js +++ b/lib/git/find_git.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var path = require('path'); var fs = require('fs'); @@ -6,10 +8,10 @@ var fs = require('fs'); /** * Given a full path to a single file, iterate upwards through the filesystem * to find a directory with a .git file indicating that it is a git repository - * @param {string} filename any file within a repository - * @returns {string|undefined} repository path + * @param filename any file within a repository + * @returns repository path */ -function findGit(filename) { +function findGit(filename/*: string*/) { var paths = filename.split(path.sep); for (var i = paths.length; i > 0; i--) { var p = path.resolve(paths.slice(0, i).join(path.sep) + path.sep + '.git'); diff --git a/lib/git/url_prefix.js b/lib/git/url_prefix.js index 8c12da93d..c35b6cb49 100644 --- a/lib/git/url_prefix.js +++ b/lib/git/url_prefix.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var fs = require('fs'); var path = require('path'); var gitUrlParse = require('git-url-parse'); @@ -16,10 +18,8 @@ var getRemoteOrigin = require('remote-origin-url'); */ function parsePackedRefs(packedRefs, branchName) { return packedRefs.split(/\n/) - .filter(function (line) { - return line[0] !== '#' && line[0] !== '^'; - }) - .reduce(function (memo, line) { + .filter(line => line[0] !== '#' && line[0] !== '^') + .reduce((memo, line) => { memo[line.split(' ')[1]] = line.split(' ')[0]; return memo; }, {})[branchName]; @@ -33,7 +33,8 @@ function parsePackedRefs(packedRefs, branchName) { * @returns {string} base HTTPS url of the GitHub repository * @throws {Error} if the root is not a git repo */ -function getGithubURLPrefix(root) { +function getGithubURLPrefix(root/*: string*/) { + var sha; try { var head = fs.readFileSync(path.join(root, '.git', 'HEAD'), 'utf8'); var branch = head.match(/ref\: (.*)/); @@ -41,7 +42,6 @@ function getGithubURLPrefix(root) { var branchName = branch[1]; var branchFileName = path.join(root, '.git', branchName); var packedRefsName = path.join(root, '.git', 'packed-refs'); - var sha; if (fs.existsSync(branchFileName)) { sha = fs.readFileSync(branchFileName, 'utf8'); } else if (fs.existsSync(packedRefsName)) { @@ -54,7 +54,9 @@ function getGithubURLPrefix(root) { } else { sha = head; } - return gitUrlParse(getRemoteOrigin.sync(root)).toString('https') + '/blob/' + sha.trim() + '/'; + if (sha) { + return gitUrlParse(getRemoteOrigin.sync(root)).toString('https') + '/blob/' + sha.trim() + '/'; + } } catch (e) { return null; } diff --git a/lib/github.js b/lib/github.js index 0e7a7ed6f..9c80a77e2 100644 --- a/lib/github.js +++ b/lib/github.js @@ -1,4 +1,6 @@ 'use strict'; +/* @flow */ + var path = require('path'); var findGit = require('../lib/git/find_git'); @@ -11,7 +13,7 @@ var getGithubURLPrefix = require('../lib/git/url_prefix'); * @param {Object} comment parsed comment * @return {Object} comment with github inferred */ -module.exports = function (comment) { +module.exports = function (comment/*: Comment*/) { var repoPath = findGit(comment.context.file); var root = repoPath ? path.dirname(repoPath) : '.'; var urlPrefix = getGithubURLPrefix(root); @@ -20,11 +22,13 @@ module.exports = function (comment) { .join('/'); if (urlPrefix) { - comment.context.path = fileRelativePath; - comment.context.github = urlPrefix + - fileRelativePath + - '#L' + comment.context.loc.start.line + '-' + - 'L' + comment.context.loc.end.line; + comment.context.github = { + url: urlPrefix + + fileRelativePath + + '#L' + comment.context.loc.start.line + '-' + + 'L' + comment.context.loc.end.line, + path: fileRelativePath + }; } return comment; }; diff --git a/lib/hierarchy.js b/lib/hierarchy.js index a597fc770..422d31362 100644 --- a/lib/hierarchy.js +++ b/lib/hierarchy.js @@ -3,21 +3,41 @@ var _ = require('lodash'); var hasOwnProperty = Object.prototype.hasOwnProperty; +/** + * Check if a given member object is of kind `event`. + * @param {Object} member - The member to check. + * @returns {boolean} `true` if it is of kind `event`, otherwise false. + */ +let isEvent = member => member.kind === 'event'; + +/*:: +declare type ReducedComment = { + name: string, + kind: ?string, + scope?: ?string +} */ + /** * Pick only relevant properties from a comment to store them in * an inheritance chain - * @param {Object} comment a parsed comment - * @returns {Object} reduced comment + * @param comment a parsed comment + * @returns reduced comment * @private */ -function pick(comment) { - var item = { +function pick(comment/*: Comment */)/*: ?ReducedComment */ { + if (typeof comment.name !== 'string') { + return undefined; + } + + var item/*: ReducedComment */ = { name: comment.name, kind: comment.kind }; + if (comment.scope) { item.scope = comment.scope; } + return item; } @@ -26,7 +46,7 @@ function pick(comment) { * @returns {Array} nested comments, with only root comments * at the top level. */ -module.exports = function (comments) { +module.exports = function (comments/*: Array*/) { var id = 0, root = { members: { @@ -35,16 +55,14 @@ module.exports = function (comments) { } }; - comments.forEach(function (comment) { + comments.forEach(comment => { var path = []; if (comment.memberof) { // TODO: full namepath parsing path = comment.memberof .split('.') - .map(function (segment) { - return ['static', segment]; - }); + .map(segment => ['static', segment]); } if (!comment.name) { @@ -139,28 +157,32 @@ module.exports = function (comments) { comment.members.events = events; - comment.path = path.map(pick).concat(pick(comment)); + comment.path = path.map(pick) + .concat(pick(comment)) + .filter(Boolean); var scopeChars = { instance: '#', static: '.' }; - comment.namespace = comment.path.reduce(function (memo, part) { + comment.namespace = comment.path.reduce((memo, part) => { if (part.kind === 'event') { return memo + '.event:' + part.name; } - return memo + (scopeChars[part.scope] || '') + part.name; + let scopeChar = ''; + if (part.scope) { + scopeChar = scopeChars[part.scope]; + } + return memo + scopeChar + part.name; }, ''); if (hasUndefinedParent) { - var memberOfTag = comment.tags.filter(function (tag) { - return tag.title === 'memberof'; - })[0]; + var memberOfTag = comment.tags.filter(tag => tag.title === 'memberof')[0]; var memberOfTagLineNumber = (memberOfTag && memberOfTag.lineNumber) || 0; comment.errors.push({ - message: '@memberof reference to ' + comment.memberof + ' not found', + message: `@memberof reference to ${comment.memberof} not found`, commentLineNumber: memberOfTagLineNumber }); @@ -178,11 +200,3 @@ module.exports = function (comments) { return toComments(root.members.static); }; -/** - * Check if a given member object is of kind `event`. - * @param {Object} member - The member to check. - * @returns {boolean} `true` if it is of kind `event`, otherwise false. - */ -function isEvent(member) { - return member.kind === 'event'; -} diff --git a/lib/infer/access.js b/lib/infer/access.js index f2c171ba2..6a83f3377 100644 --- a/lib/infer/access.js +++ b/lib/infer/access.js @@ -1,6 +1,6 @@ -'use strict'; -var shouldSkipInference = require('./should_skip_inference'); +'use strict'; +/* @flow */ /** * Given a string with a pattern that might infer access level, like `^_`, @@ -10,7 +10,7 @@ var shouldSkipInference = require('./should_skip_inference'); * @returns {Function} inference method * @private */ -function inferAccessWithPattern(pattern) { +function inferAccessWithPattern(pattern/*: ?string*/) { var re = pattern && new RegExp(pattern); /** @@ -20,7 +20,7 @@ function inferAccessWithPattern(pattern) { * @param {Object} comment parsed comment * @returns {Object} comment with access inferred */ - return shouldSkipInference(function inferAccess(comment) { + return function inferAccess(comment/*: Comment */) { // This needs to run after inferName beacuse we infer the access based on // the name. if (re && comment.name && comment.access === undefined && re.test(comment.name)) { @@ -28,7 +28,7 @@ function inferAccessWithPattern(pattern) { } return comment; - }); + }; } module.exports = inferAccessWithPattern; diff --git a/lib/infer/augments.js b/lib/infer/augments.js index 8982b58b4..0d4920b29 100644 --- a/lib/infer/augments.js +++ b/lib/infer/augments.js @@ -1,7 +1,8 @@ + 'use strict'; +/* @flow */ -var shouldSkipInference = require('./should_skip_inference'), - generate = require('babel-generator').default, +var generate = require('babel-generator').default, findClass = require('./finders').findClass; /** @@ -10,29 +11,27 @@ var shouldSkipInference = require('./should_skip_inference'), * @param {Object} comment parsed comment * @returns {Object} comment with kind inferred */ -function inferAugments() { - return shouldSkipInference(function inferAugments(comment) { - if (comment.augments) { - return comment; - } +function inferAugments(comment/*: Comment */) { + if (comment.augments.length) { + return comment; + } - var path = findClass(comment.context.ast); + var path = findClass(comment.context.ast); - /* - * A superclass can be a single name, like React, - * or a MemberExpression like React.Component, - * so we generate code from the AST rather than assuming - * we can access a name like `path.node.superClass.name` - */ - if (path && path.node.superClass) { - comment.augments = [{ - title: 'augments', - name: generate(path.node.superClass).code - }]; - } + /* + * A superclass can be a single name, like React, + * or a MemberExpression like React.Component, + * so we generate code from the AST rather than assuming + * we can access a name like `path.node.superClass.name` + */ + if (path && path.node.superClass) { + comment.augments.push({ + title: 'augments', + name: generate(path.node.superClass).code + }); + } - return comment; - }); + return comment; } module.exports = inferAugments; diff --git a/lib/infer/finders.js b/lib/infer/finders.js index cef792d9f..fe6808c59 100644 --- a/lib/infer/finders.js +++ b/lib/infer/finders.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var t = require('babel-types'); @@ -10,7 +12,7 @@ var t = require('babel-types'); * @returns {?Object} ast path, if one is found. * @private */ -function findTarget(path) { +function findTarget(path/*: Object */) { if (!path) { return path; } @@ -40,7 +42,7 @@ function findTarget(path) { * @returns {?Object} ast path, if one is found. * @private */ -function findClass(path) { +function findClass(path/*: Object*/) { var target = findTarget(path); if (target && (target.isClassDeclaration() || target.isClassExpression())) { return target; diff --git a/lib/infer/kind.js b/lib/infer/kind.js index cd5b8f246..d058899fc 100644 --- a/lib/infer/kind.js +++ b/lib/infer/kind.js @@ -1,6 +1,7 @@ + 'use strict'; +/* @flow */ -var shouldSkipInference = require('./should_skip_inference'); var t = require('babel-types'); /** @@ -9,60 +10,58 @@ var t = require('babel-types'); * @param {Object} comment parsed comment * @returns {Object} comment with kind inferred */ -function inferKind() { - return shouldSkipInference(function inferKind(comment) { - if (comment.kind) { +function inferKind(comment/*: Comment*/) { + if (comment.kind) { + return comment; + } + + function findKind(node) { + if (!node) { return comment; } - function findKind(node) { - if (!node) { - return comment; - } - - if (t.isClassDeclaration(node)) { - comment.kind = 'class'; - } else if (t.isFunction(node)) { - if (node.kind === 'get' || node.kind === 'set') { - comment.kind = 'member'; - } else if (node.id && node.id.name && !!/^[A-Z]/.exec(node.id.name)) { - comment.kind = 'class'; - } else { - comment.kind = 'function'; - } - } else if (t.isTypeAlias(node)) { - comment.kind = 'typedef'; - } else if (t.isVariableDeclaration(node)) { - if (node.kind === 'const') { - comment.kind = 'constant'; - } else { - // This behavior is in need of fixing https://github.com/documentationjs/documentation/issues/351 - findKind(node.declarations[0].init); - } - } else if (t.isExportDeclaration(node)) { - // export var x = ... - // export function f() {} - // export class C {} - // export default function f() {} - // export default class C {} - findKind(node.declaration); - } else if (t.isExpressionStatement(node)) { - // module.exports = function() {} - findKind(node.expression.right); - } else if (t.isClassProperty(node)) { + if (t.isClassDeclaration(node)) { + comment.kind = 'class'; + } else if (t.isFunction(node)) { + if (node.kind === 'get' || node.kind === 'set') { comment.kind = 'member'; - } else if (t.isProperty(node)) { - // { foo: function() {} } - findKind(node.value); + } else if (node.id && node.id.name && !!/^[A-Z]/.exec(node.id.name)) { + comment.kind = 'class'; + } else { + comment.kind = 'function'; + } + } else if (t.isTypeAlias(node)) { + comment.kind = 'typedef'; + } else if (t.isVariableDeclaration(node)) { + if (node.kind === 'const') { + comment.kind = 'constant'; + } else { + // This behavior is in need of fixing https://github.com/documentationjs/documentation/issues/351 + findKind(node.declarations[0].init); } + } else if (t.isExportDeclaration(node)) { + // export var x = ... + // export function f() {} + // export class C {} + // export default function f() {} + // export default class C {} + findKind(node.declaration); + } else if (t.isExpressionStatement(node)) { + // module.exports = function() {} + findKind(node.expression.right); + } else if (t.isClassProperty(node)) { + comment.kind = 'member'; + } else if (t.isProperty(node)) { + // { foo: function() {} } + findKind(node.value); } + } - if (comment.context.ast) { - findKind(comment.context.ast.node); - } + if (comment.context.ast) { + findKind(comment.context.ast.node); + } - return comment; - }); + return comment; } module.exports = inferKind; diff --git a/lib/infer/membership.js b/lib/infer/membership.js index 3197dde49..3da6353c8 100644 --- a/lib/infer/membership.js +++ b/lib/infer/membership.js @@ -1,8 +1,9 @@ + 'use strict'; +/* @flow */ var n = require('babel-types'), pathParse = require('parse-filepath'), - shouldSkipInference = require('./should_skip_inference'), isJSDocComment = require('../../lib/is_jsdoc_comment'), parse = require('../../lib/parse'); @@ -48,7 +49,7 @@ function extractThis(path) { * @returns {undefined} has side-effects * @private */ - ThisExpression: function (path) { + ThisExpression(path) { var scope = path.scope; while (n.isBlockStatement(scope.block)) { @@ -97,7 +98,7 @@ function extractIdentifiers(path) { * @returns {undefined} has side-effects * @private */ - Identifier: function (path) { + Identifier(path) { identifiers.push(path.node.name); } }); @@ -126,10 +127,15 @@ function countModuleIdentifiers(comment, identifiers) { /** * Returns the comment object after normalizing Foo.prototype and Foo# expressions - * @param {Object} comment parsed comment - * @returns {Object} the normalized comment + * @param comment parsed comment + * @returns the normalized comment */ -function normalizeMemberof(comment) { +function normalizeMemberof(comment/*: Comment*/)/*: Comment */ { + + if (typeof comment.memberof != 'string') { + return comment; + } + var memberof = comment.memberof; var isPrototype = /.prototype$/; @@ -211,14 +217,18 @@ module.exports = function () { } } - return shouldSkipInference(function inferMembership(comment) { + return function inferMembership(comment/*: Comment */) { + + if (comment.tags.some(tag => tag.title === 'name')) { + return comment; + } if (comment.kind === 'module') { currentModule = comment; } if (comment.lends) { - return; + return comment; } if (comment.memberof) { @@ -286,6 +296,18 @@ module.exports = function () { } } + // Foo = { bar() {} }; + // Foo.prototype = { bar() {} }; + // Foo.bar = { baz() {} }; + if (n.isObjectMethod(path.node) && + n.isObjectExpression(path.parentPath) && + n.isAssignmentExpression(path.parentPath.parentPath)) { + identifiers = extractIdentifiers(path.parentPath.parentPath.get('left')); + if (identifiers.length >= 1) { + inferMembershipFromIdentifiers(comment, identifiers); + } + } + // var Foo = { bar: ... } if (n.isIdentifier(path) && n.isObjectProperty(path.parentPath) && @@ -335,5 +357,5 @@ module.exports = function () { */ return comment; - }); + }; }; diff --git a/lib/infer/name.js b/lib/infer/name.js index 3f0b89fa8..701e291dd 100644 --- a/lib/infer/name.js +++ b/lib/infer/name.js @@ -1,7 +1,8 @@ + 'use strict'; +/* @flow */ -var shouldSkipInference = require('./should_skip_inference'), - pathParse = require('parse-filepath'), +var pathParse = require('parse-filepath'), t = require('babel-types'); /** @@ -11,92 +12,92 @@ var shouldSkipInference = require('./should_skip_inference'), * @param {Object} comment parsed comment * @returns {Object} comment with name inferred */ -module.exports = function () { - return shouldSkipInference(function inferName(comment) { - if (comment.name) { - return comment; - } +function inferName(comment/*: Comment */) { + if (comment.name) { + return comment; + } - if (comment.alias) { - comment.name = comment.alias; - return comment; - } + if (comment.alias) { + comment.name = comment.alias; + return comment; + } - if (comment.kind === 'module') { - comment.name = pathParse(comment.context.file).name; - return comment; + if (comment.kind === 'module') { + comment.name = pathParse(comment.context.file).name; + return comment; + } + + function inferName(path, node) { + if (node && node.name) { + comment.name = node.name; + return true; + } + if (node && node.type === 'StringLiteral' && node.value) { + comment.name = node.value; + return true; } + } - function inferName(path, node) { - if (node && node.name) { - comment.name = node.name; - return true; - } - if (node && node.type === 'StringLiteral' && node.value) { - comment.name = node.value; - return true; + var path = comment.context.ast; + if (path) { + if (path.type === 'ExportDefaultDeclaration') { + if (t.isDeclaration(path.node.declaration) && path.node.declaration.id) { + comment.name = path.node.declaration.id.name; + } else { + comment.name = pathParse(comment.context.file).name; } + return comment; } - var path = comment.context.ast; - if (path) { - if (path.type === 'ExportDefaultDeclaration') { - if (t.isDeclaration(path.node.declaration) && path.node.declaration.id) { - comment.name = path.node.declaration.id.name; - } else { - comment.name = pathParse(comment.context.file).name; + // The strategy here is to do a depth-first traversal of the AST, + // looking for nodes with a "name" property, with exceptions as needed. + // For example, name inference for a MemberExpression `foo.bar = baz` will + // infer the named based on the `property` of the MemberExpression (`bar`) + // rather than the `object` (`foo`). + path.traverse({ + /** + * Attempt to extract the name from an Identifier node. + * If the name can be resolved, it will stop traversing. + * @param {Object} path ast path + * @returns {undefined} has side-effects + * @private + */ + Identifier(path) { + if (inferName(path, path.node)) { + path.stop(); } - return comment; - } - - // The strategy here is to do a depth-first traversal of the AST, - // looking for nodes with a "name" property, with exceptions as needed. - // For example, name inference for a MemberExpression `foo.bar = baz` will - // infer the named based on the `property` of the MemberExpression (`bar`) - // rather than the `object` (`foo`). - path.traverse({ - /** - * Attempt to extract the name from an Identifier node. - * If the name can be resolved, it will stop traversing. - * @param {Object} path ast path - * @returns {undefined} has side-effects - * @private - */ - Identifier: function (path) { + }, + /** + * Attempt to extract the name from a string literal that is the `key` + * part of an ObjectProperty node. If the name can be resolved, it + * will stop traversing. + * @param {Object} path ast path + * @returns {undefined} has side-effects + * @private + */ + StringLiteral(path) { + if (path.parent.type === 'ObjectProperty' && path.node === path.parent.key) { if (inferName(path, path.node)) { path.stop(); } - }, - /** - * Attempt to extract the name from a string literal that is the `key` - * part of an ObjectProperty node. If the name can be resolved, it - * will stop traversing. - * @param {Object} path ast path - * @returns {undefined} has side-effects - * @private - */ - StringLiteral: function (path) { - if (path.parent.type === 'ObjectProperty' && path.node === path.parent.key) { - if (inferName(path, path.node)) { - path.stop(); - } - } - }, - /** - * Attempt to extract the name from an Identifier node. - * If the name can be resolved, it will stop traversing. - * @param {Object} path ast path - * @returns {undefined} has side-effects - * @private - */ - MemberExpression: function (path) { - if (inferName(path, path.node.property)) { - path.stop(); - } } - }); - } + }, + /** + * Attempt to extract the name from an Identifier node. + * If the name can be resolved, it will stop traversing. + * @param {Object} path ast path + * @returns {undefined} has side-effects + * @private + */ + MemberExpression(path) { + if (inferName(path, path.node.property)) { + path.stop(); + } + } + }); + } - return comment; - }); -}; + return comment; +} + +module.exports = inferName; diff --git a/lib/infer/params.js b/lib/infer/params.js index 050a6a67e..d5bcb0c55 100644 --- a/lib/infer/params.js +++ b/lib/infer/params.js @@ -1,10 +1,56 @@ + 'use strict'; +/* @flow */ -var shouldSkipInference = require('./should_skip_inference'), - t = require('babel-types'), +var t = require('babel-types'), findTarget = require('./finders').findTarget, flowDoctrine = require('../flow_doctrine'); +function addPrefix(doc, prefix) { + if (!Array.isArray(doc) && doc.name) { + doc.name = prefix + doc.name; + } + return doc; +} + +/** + * Given a parameter like + * + * function a(b = 1) + * + * Format it as an optional parameter in JSDoc land + * + * @param {Object} param ESTree node + * @returns {Object} JSDoc param + */ +function paramWithDefaultToDoc(param, comment, i)/*: CommentTag | Array */ { + var newParam = paramToDoc(param.left, comment, i, ''); + + var defaultValue = comment.context.code.substring( + param.right.start, param.right.end); + + // this is a destructuring parameter with defaults + if (Array.isArray(newParam)) { + newParam[0].default = defaultValue; + return newParam; + } + + var optionalParam/*: CommentTag */ = { + title: 'param', + name: newParam.name, + 'default': defaultValue + }; + + if (newParam.type) { + optionalParam.type = { + type: 'OptionalType', + expression: newParam.type + }; + } + + return optionalParam; +} + /** * Babel parses JavaScript source code and produces an abstract syntax * tree that includes methods and their arguments. This function takes @@ -23,71 +69,28 @@ var shouldSkipInference = require('./should_skip_inference'), * @param {string} prefix of the comment, if it is nested, like in the case of destructuring * @returns {Object} parameter with inference. */ -function paramToDoc(param, comment, i, prefix) { - - prefix = prefix || ''; - - function addPrefix(doc) { - if (!Array.isArray(doc)) { - doc.name = prefix + doc.name; - } - return doc; - } +function paramToDoc(param, + comment/*: Comment */, + i/*: number */, + prefix/*: string */)/*: Array | CommentTag */ { - /** - * Given a parameter like - * - * function a(b = 1) - * - * Format it as an optional parameter in JSDoc land - * - * @param {Object} param ESTree node - * @returns {Object} JSDoc param - */ - function paramWithDefaultToDoc(param) { - var newParam = paramToDoc(param.left, comment, i); - - var defaultValue = comment.context.code.substring( - param.right.start, param.right.end); - - // this is a destructuring parameter with defaults - if (Array.isArray(newParam)) { - newParam[0].default = defaultValue; - return newParam; - } - - var optionalParam = { - title: 'param', - name: newParam.name, - 'default': defaultValue - }; - - if (newParam.type) { - optionalParam.type = { - type: 'OptionalType', - expression: newParam.type - }; - } - - return optionalParam; - } - - function destructuringPropertyToDoc(property) { + function destructuringPropertyToDoc(property)/*: Array | CommentTag */ { if (property.type === 'ObjectProperty') { - return paramToDoc(property.value, comment, i, prefix + '$' + i + '.'); + return paramToDoc(property.value, comment, i, prefix + '$' + String(i) + '.'); } else if (property.type === 'Identifier') { // if the destructuring type is an array, the elements // in it are identifiers - return paramToDoc(property, comment, i, prefix + '$' + i + '.'); + return paramToDoc(property, comment, i, prefix + '$' + String(i) + '.'); } else if (property.type === 'RestProperty') { - return paramToDoc(property, comment, i, prefix + '$' + i + '.'); + return paramToDoc(property, comment, i, prefix + '$' + String(i) + '.'); } + throw new Error(`Unknown property encountered: ${property.type}`); } - function destructuringObjectParamToDoc(param) { + function destructuringObjectParamToDoc(param)/*: Array */ { return [{ title: 'param', - name: '$' + i, + name: '$' + String(i), type: flowDoctrine(param) || { type: 'NameExpression', name: 'Object' @@ -95,10 +98,10 @@ function paramToDoc(param, comment, i, prefix) { }].concat(param.properties.map(destructuringPropertyToDoc)); } - function destructuringArrayParamToDoc(param) { + function destructuringArrayParamToDoc(param)/*: Array */ { return [{ title: 'param', - name: '$' + i, + name: '$' + String(i), type: flowDoctrine(param) || { type: 'NameExpression', name: 'Array' @@ -106,39 +109,40 @@ function paramToDoc(param, comment, i, prefix) { }].concat(param.elements.map(destructuringPropertyToDoc)); } - function restParamToDoc(param) { + function restParamToDoc(param)/*: CommentTag */ { + let type/*: DoctrineType */ = { + type: 'RestType' + }; + if (param.typeAnnotation) { + type.expression = flowDoctrine(param.typeAnnotation.typeAnnotation); + } var newParam = { title: 'param', name: param.argument.name, lineNumber: param.loc.start.line, - type: { - type: 'RestType' - } + type }; - if (param.typeAnnotation) { - newParam.type.expression = flowDoctrine(param.typeAnnotation.typeAnnotation); - } return newParam; } // ES6 default if (param.type === 'AssignmentPattern') { - return addPrefix(paramWithDefaultToDoc(param)); + return addPrefix(paramWithDefaultToDoc(param, comment, i), prefix); } if (param.type === 'ObjectPattern') { - return addPrefix(destructuringObjectParamToDoc(param)); + return destructuringObjectParamToDoc(param); } if (param.type === 'ArrayPattern') { - return addPrefix(destructuringArrayParamToDoc(param)); + return destructuringArrayParamToDoc(param); } if (param.type === 'RestProperty' || param.type === 'RestElement') { - return addPrefix(restParamToDoc(param)); + return addPrefix(restParamToDoc(param), prefix); } - var newParam = { + var newParam/*: CommentTag */ = { title: 'param', name: param.name, lineNumber: param.loc.start.line @@ -149,13 +153,14 @@ function paramToDoc(param, comment, i, prefix) { newParam.type = flowDoctrine(param.typeAnnotation.typeAnnotation); } - return addPrefix(newParam); + return addPrefix(newParam, prefix); } function insertBeforeDependents(comment, comments) { var dependentNamePrefix = comment.name + '.'; for (var insertionIndex = 0; insertionIndex < comments.length; insertionIndex++) { - if (comments[insertionIndex].name.indexOf(dependentNamePrefix) === 0) { + let commentName = comments[insertionIndex].name; + if (commentName && commentName.indexOf(dependentNamePrefix) === 0) { break; } } @@ -170,62 +175,58 @@ function insertBeforeDependents(comment, comments) { * @param {Object} comment parsed comment * @returns {Object} comment with parameters */ -function inferParams() { - return shouldSkipInference(function inferParams(comment) { - var path = findTarget(comment.context.ast); - - // In case of `/** */ var x = function () {}` findTarget returns - // the declarator. - if (t.isVariableDeclarator(path)) { - path = path.get('init'); - } +function inferParams(comment/*: Comment */) { + var path = findTarget(comment.context.ast); + + // In case of `/** */ var x = function () {}` findTarget returns + // the declarator. + if (t.isVariableDeclarator(path)) { + path = path.get('init'); + } + + if (!t.isFunction(path)) { + return comment; + } - if (!t.isFunction(path)) { - return comment; + // Ensure that explicitly specified parameters are not overridden + // by inferred parameters + var existingParams = {}; + comment.params.forEach(function (param) { + if (typeof param.name === 'string') { + existingParams[param.name] = param; } + }); - // Ensure that explicitly specified parameters are not overridden - // by inferred parameters - var existingParams = (comment.params || []).reduce(function (memo, param) { - memo[param.name] = param; - return memo; - }, {}); - - var paramOrder = {}; - var i = 0; - - path.node.params - .reduce(function (params, param, i) { - return params.concat(paramToDoc(param, comment, i)); - }, []) - .forEach(function (doc) { - if (!existingParams.hasOwnProperty(doc.name)) { - // This type is not explicitly documented - if (!comment.params) { - comment.params = []; - } - - comment.params = insertBeforeDependents(doc, comment.params); - } else if (!existingParams[doc.name].type) { - // This param has a description, but potentially it can - // be have an inferred type. Infer its type without - // dropping the description. - if (doc.type) { - existingParams[doc.name].type = doc.type; - } - } else if (existingParams[doc.name].type.type !== 'OptionalType' && - doc.default) { - existingParams[doc.name].type = { - type: 'OptionalType', - expression: existingParams[doc.name].type, - default: doc.default - }; + var paramOrder = {}; + var i = 0; + + path.node.params + .reduce(function (params, param, i) { + return params.concat(paramToDoc(param, comment, i, '')); + }, []) + .forEach(function (doc) { + if (!existingParams.hasOwnProperty(doc.name)) { + // This type is not explicitly documented + comment.params = insertBeforeDependents(doc, comment.params); + } else if (!existingParams[doc.name].type) { + // This param has a description, but potentially it can + // be have an inferred type. Infer its type without + // dropping the description. + if (doc.type) { + existingParams[doc.name].type = doc.type; } - paramOrder[doc.name] = i++; - }); + } else if (existingParams[doc.name].type.type !== 'OptionalType' && + doc.default) { + existingParams[doc.name].type = { + type: 'OptionalType', + expression: existingParams[doc.name].type, + default: doc.default + }; + } + paramOrder[doc.name] = i++; + }); - return comment; - }); + return comment; } module.exports = inferParams; diff --git a/lib/infer/properties.js b/lib/infer/properties.js index a5c16f72a..4b6112d15 100644 --- a/lib/infer/properties.js +++ b/lib/infer/properties.js @@ -1,9 +1,33 @@ + 'use strict'; +/* @flow */ -var shouldSkipInference = require('./should_skip_inference'), - t = require('babel-types'), +var t = require('babel-types'), flowDoctrine = require('../flow_doctrine'); +function prefixedName(name, prefix) { + if (prefix.length) { + return prefix.join('.') + '.' + name; + } + return name; +} + +function propertyToDoc(property, prefix)/*: CommentTag */ { + var type = flowDoctrine(property.value); + if (property.optional) { + type = { + type: 'OptionalType', + expression: type + }; + } + return { + title: 'property', + name: prefixedName(property.key.name, prefix), + lineNumber: property.loc.start.line, + type + }; +} + /** * Infers properties of TypeAlias objects (Flow or TypeScript type definitions) @@ -11,65 +35,32 @@ var shouldSkipInference = require('./should_skip_inference'), * @param {Object} comment parsed comment * @returns {Object} comment with inferred properties */ -function inferProperties() { - - function prefixedName(name, prefix) { - if (prefix.length) { - return prefix.join('.') + '.' + name; - } - return name; - } - - function propertyToDoc(property, prefix) { - var type = flowDoctrine(property.value); - if (property.optional) { - type = { - type: 'OptionalType', - expression: type - }; - } - var newProperty = { - title: 'property', - name: prefixedName(property.key.name, prefix), - lineNumber: property.loc.start.line, - type: type - }; - return newProperty; - } +function inferProperties(comment/*: Comment */)/*: Comment */ { - return shouldSkipInference(function inferProperties(comment) { + let explicitProperties = new Set(); + // Ensure that explicitly specified properties are not overridden + // by inferred properties + comment.properties.forEach(prop => explicitProperties.add(prop)); - - // Ensure that explicitly specified properties are not overridden - // by inferred properties - var explicitProperties = (comment.properties || []).reduce(function (memo, property) { - memo[property.name] = true; - return memo; - }, {}); - - function inferProperties(value, prefix) { - if (value.type === 'ObjectTypeAnnotation') { - value.properties.forEach(function (property) { - if (explicitProperties[prefixedName(property.key.name, prefix)] === undefined) { - if (!comment.properties) { - comment.properties = []; - } - comment.properties = comment.properties.concat(propertyToDoc(property, prefix)); - // Nested type parameters - if (property.value.type === 'ObjectTypeAnnotation') { - inferProperties(property.value, prefix.concat(property.key.name)); - } + function inferProperties(value, prefix) { + if (value.type === 'ObjectTypeAnnotation') { + value.properties.forEach(function (property) { + if (!explicitProperties.has(prefixedName(property.key.name, prefix))) { + comment.properties = comment.properties.concat(propertyToDoc(property, prefix)); + // Nested type parameters + if (property.value.type === 'ObjectTypeAnnotation') { + inferProperties(property.value, prefix.concat(property.key.name)); } - }); - } + } + }); } + } - if (t.isTypeAlias(comment.context.ast)) { - inferProperties(comment.context.ast.node.right, []); - } + if (t.isTypeAlias(comment.context.ast)) { + inferProperties(comment.context.ast.node.right, []); + } - return comment; - }); + return comment; } module.exports = inferProperties; diff --git a/lib/infer/return.js b/lib/infer/return.js index 790aa7a8b..9711d0ad7 100644 --- a/lib/infer/return.js +++ b/lib/infer/return.js @@ -1,8 +1,9 @@ + 'use strict'; +/* @flow */ var findTarget = require('./finders').findTarget, t = require('babel-types'), - shouldSkipInference = require('./should_skip_inference'), flowDoctrine = require('../flow_doctrine'); /** @@ -12,34 +13,35 @@ var findTarget = require('./finders').findTarget, * @param {Object} comment parsed comment * @returns {Object} comment with return tag inferred */ -module.exports = function () { - return shouldSkipInference(function inferReturn(comment) { - if (Array.isArray(comment.returns) && - comment.returns.length && - comment.returns[0].type) { - return comment; - } - var path = findTarget(comment.context.ast); - var fn = path && path.node; +function inferReturn(comment/*: Comment */) { + if (Array.isArray(comment.returns) && + comment.returns.length && + comment.returns[0].type) { + return comment; + } + var path = findTarget(comment.context.ast); + var fn = path && path.node; - // In case of `/** */ var x = function () {}` findTarget returns - // the declarator. - if (t.isVariableDeclarator(fn)) { - fn = fn.init; - } + // In case of `/** */ var x = function () {}` findTarget returns + // the declarator. + if (t.isVariableDeclarator(fn)) { + fn = fn.init; + } - if (t.isFunction(fn) && - fn.returnType && - fn.returnType.typeAnnotation) { - var returnType = flowDoctrine(fn.returnType.typeAnnotation); - if (comment.returns && comment.returns.length > 0) { - comment.returns[0].type = returnType; - } else { - comment.returns = [{ - type: returnType - }]; - } + if (t.isFunction(fn) && + fn.returnType && + fn.returnType.typeAnnotation) { + var returnType = flowDoctrine(fn.returnType.typeAnnotation); + if (comment.returns && comment.returns.length > 0) { + comment.returns[0].type = returnType; + } else { + comment.returns = [{ + title: 'returns', + type: returnType + }]; } - return comment; - }); -}; + } + return comment; +} + +module.exports = inferReturn; diff --git a/lib/infer/should_skip_inference.js b/lib/infer/should_skip_inference.js index 8554df946..5cacc1686 100644 --- a/lib/infer/should_skip_inference.js +++ b/lib/infer/should_skip_inference.js @@ -1,19 +1,12 @@ +/* @flow */ +'use strict'; + /** * Decide whether a comment should go through the AST inference * stage based on whether it has an explicit `@name` tag. - * - * @param {Function} fn parser - * @returns {boolean} true if the comment should skip inference */ -function shouldSkipInference(fn) { - return function (comment) { - if (comment.tags.some(function (tag) { - return tag.title === 'name'; - })) { - return comment; - } - return fn(comment); - }; +function shouldSkipInference(comment/*: Comment */) /*: boolean */ { + return comment.tags.some(tag => tag.title === 'name'); } module.exports = shouldSkipInference; diff --git a/lib/infer/type.js b/lib/infer/type.js index 74982cafe..3be875298 100644 --- a/lib/infer/type.js +++ b/lib/infer/type.js @@ -1,7 +1,8 @@ + 'use strict'; +/* @flow */ var findTarget = require('./finders').findTarget, - shouldSkipInference = require('./should_skip_inference'), flowDoctrine = require('../flow_doctrine'), t = require('babel-types'); @@ -18,39 +19,39 @@ var constTypeMapping = { * @param {Object} comment parsed comment * @returns {Object} comment with type tag inferred */ -module.exports = function () { - return shouldSkipInference(function inferType(comment) { - if (comment.type) { - return comment; - } +function inferType(comment/*: Comment */) { + if (comment.type) { + return comment; + } - var path = findTarget(comment.context.ast); - if (!path) { - return comment; - } + var path = findTarget(comment.context.ast); + if (!path) { + return comment; + } - var n = path.node; - var type; - switch (n.type) { - case 'VariableDeclarator': - type = n.id.typeAnnotation; - if (!type && comment.kind === 'constant') { - type = constTypeMapping[n.init.type]; - } - break; - case 'ClassProperty': - type = n.typeAnnotation; - break; - case 'TypeAlias': - type = n.right; - break; + var n = path.node; + var type; + switch (n.type) { + case 'VariableDeclarator': + type = n.id.typeAnnotation; + if (!type && comment.kind === 'constant') { + type = constTypeMapping[n.init.type]; } - if (type) { - if (t.isTypeAnnotation(type)) { - type = type.typeAnnotation; - } - comment.type = flowDoctrine(type); + break; + case 'ClassProperty': + type = n.typeAnnotation; + break; + case 'TypeAlias': + type = n.right; + break; + } + if (type) { + if (t.isTypeAnnotation(type)) { + type = type.typeAnnotation; } - return comment; - }); -}; + comment.type = flowDoctrine(type); + } + return comment; +} + +module.exports = inferType; diff --git a/lib/inline_tokenizer.js b/lib/inline_tokenizer.js index b41102f32..60b67c040 100644 --- a/lib/inline_tokenizer.js +++ b/lib/inline_tokenizer.js @@ -1,5 +1,7 @@ +/* @flow */ 'use strict'; + /** * Create a tokenizer method for Remark, our Markdown processor, * that is able to parse JSDoc inline tokens @@ -19,7 +21,7 @@ function makeTokenizer(type, regex) { } return eat(match[0])({ - type: type, + type, url: match[1], title: null, jsdoc: true, @@ -53,7 +55,7 @@ var tokenizeTutorial = makeTokenizer('tutorial', /^\{@tutorial\s+(.+?)(?:[\s|](. * @param {Object} processor - remark instance * @returns {undefined} */ -module.exports = function (processor) { +module.exports = function (processor/*: Object*/) { var proto = processor.Parser.prototype; proto.inlineTokenizers.tokenizeLink = tokenizeLink; proto.inlineTokenizers.tokenizeTutorial = tokenizeTutorial; diff --git a/lib/input/dependency.js b/lib/input/dependency.js index e7b81433e..39e9f9a51 100644 --- a/lib/input/dependency.js +++ b/lib/input/dependency.js @@ -1,7 +1,8 @@ + 'use strict'; +/* @flow */ var mdeps = require('module-deps-sortable'); -var fs = require('fs'); var path = require('path'); var babelify = require('babelify'); var concat = require('concat-stream'); @@ -15,25 +16,21 @@ var smartGlob = require('../smart_glob.js'); * This stream requires filesystem access, and thus isn't suitable * for a browser environment. * - * @param {Array} indexes paths to entry files as strings - * @param {Object} options optional options passed - * @param {Function} callback called with (err, inputs) - * @returns {undefined} calls callback + * @param indexes paths to entry files as strings + * @param config optional options passed + * @returns results */ -function dependencyStream(indexes, options, callback) { +function dependencyStream(indexes/*: Array*/, + config/*: DocumentationConfig */)/*: Promise>*/ { var md = mdeps({ /** * Determine whether a module should be included in documentation * @param {string} id path to a module * @returns {boolean} true if the module should be included. */ - filter: function (id) { - return !!options.external || moduleFilters.internalOnly(id); - }, - extensions: [].concat(options.requireExtension || []) - .map(function (ext) { - return '.' + ext.replace(/^\./, ''); - }) + filter: id => !!config.external || moduleFilters.internalOnly(id), + extensions: [].concat(config.requireExtension || []) + .map(ext => '.' + ext.replace(/^\./, '')) .concat(['.js', '.json', '.es6', '.jsx']), transform: [babelify.configure({ sourceMap: false, @@ -50,33 +47,33 @@ function dependencyStream(indexes, options, callback) { require('babel-plugin-system-import-transformer').default ] })], - postFilter: moduleFilters.externals(indexes, options) + postFilter: moduleFilters.externals(indexes, config) }); - smartGlob(indexes, options.parseExtensions).forEach(function (index) { + smartGlob(indexes, config.parseExtension).forEach(index => { md.write(path.resolve(index)); }); md.end(); - md.once('error', function (error) { - return callback(error); + + return new Promise((resolve, reject) => { + md.once('error', reject); + md.pipe(concat(function (inputs) { + resolve(inputs + .filter(input => + // At this point, we may have allowed a JSON file to be caught by + // module-deps, or anything else allowed by requireExtension. + // otherwise module-deps would complain about + // it not being found. But Babel can't parse JSON, so we filter non-JavaScript + // files away. + config.parseExtension.indexOf( + path.extname(input.file).replace(/^\./, '') + ) > -1) + .map(input => { + // remove source file, since it's transformed anyway + delete input.source; + return input; + })); + })); }); - md.pipe(concat(function (inputs) { - callback(null, inputs - .filter(function (input) { - // At this point, we may have allowed a JSON file to be caught by - // module-deps, or anything else allowed by requireExtension. - // otherwise module-deps would complain about - // it not being found. But Babel can't parse JSON, so we filter non-JavaScript - // files away. - return options.parseExtensions.indexOf( - path.extname(input.file).replace(/^\./, '') - ) > -1; - }) - .map(function (input) { - // un-transform babelify transformed source - input.source = fs.readFileSync(input.file, 'utf8'); - return input; - })); - })); } module.exports = dependencyStream; diff --git a/lib/input/shallow.js b/lib/input/shallow.js index ec52d2239..5727f0484 100644 --- a/lib/input/shallow.js +++ b/lib/input/shallow.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var smartGlob = require('../smart_glob.js'); @@ -14,22 +16,26 @@ var smartGlob = require('../smart_glob.js'); * at all. This is one way of getting documentation.js to run in a browser * or without fs access. * - * @param {Array} indexes entry points - * @param {Object} options parsing options - * @param {Function} callback called with (err, inputs) - * @return {undefined} calls callback + * @param indexes entry points + * @param options parsing options + * @return promise with parsed files */ -module.exports = function (indexes, options, callback) { +module.exports = function (indexes/*: Array*/, + config/*: DocumentationConfig */)/*: Promise>*/ { var objects = []; var strings = []; - indexes.forEach(function (index) { + for (var index of indexes) { if (typeof index === 'string') { strings.push(index); } else if (typeof index === 'object') { objects.push(index); } else { - throw new Error('Indexes should be either strings or objects'); + return Promise.reject(new Error('Indexes should be either strings or objects')); } - }); - return callback(null, objects.concat(smartGlob(strings, options.parseExtensions))); + } + return Promise.resolve(objects + .concat(smartGlob(strings, config.parseExtension) + .map(file => ({ + file + })))); }; diff --git a/lib/is_jsdoc_comment.js b/lib/is_jsdoc_comment.js index 4f4b14385..fd5a70f32 100644 --- a/lib/is_jsdoc_comment.js +++ b/lib/is_jsdoc_comment.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ /** * Detect whether a comment is a JSDoc comment: it must be a block @@ -12,7 +14,10 @@ * @param {Object} comment an ast node of the comment * @return {boolean} whether it is valid */ -module.exports = function isJSDocComment(comment) { +module.exports = function isJSDocComment(comment/*: { + value: string, + type: string +}*/) { var asterisks = comment.value.match(/^(\*+)/); return (comment.type === 'CommentBlock' || // estree comment.type === 'Block') // get-comments / traditional diff --git a/lib/lint.js b/lib/lint.js index aa32990c0..89575bc0f 100644 --- a/lib/lint.js +++ b/lib/lint.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var VFile = require('vfile'), walk = require('../lib/walk'), @@ -22,10 +24,10 @@ var CANONICAL = { * @param {Object} comment parsed comment * @returns {Array} array of errors */ -function lintComments(comment) { +function lintComments(comment/*: Comment*/) { comment.tags.forEach(function (tag) { function nameInvariant(name) { - if (CANONICAL[name]) { + if (name && typeof CANONICAL[name] === 'string') { comment.errors.push({ message: 'type ' + name + ' found, ' + CANONICAL[name] + ' is standard', commentLineNumber: tag.lineNumber @@ -38,7 +40,12 @@ function lintComments(comment) { nameInvariant(type.name); } - [type.elements, type.applications].forEach(checkSubtypes); + if (type.elements) { + checkSubtypes(type.elements); + } + if (type.applications) { + checkSubtypes(type.applications); + } } function checkSubtypes(subtypes) { @@ -60,7 +67,7 @@ function lintComments(comment) { * @param {Array} comments a list of comments * @return {string} user-readable output */ -function formatLint(comments) { +function formatLint(comments/*: Array*/)/*: string */ { var vFiles = {}; walk(comments, function (comment) { comment.errors.forEach(function (error) { @@ -73,9 +80,7 @@ function formatLint(comments) { }); }); }); - return reporter(Object.keys(vFiles).map(function (p) { - return vfileSort(vFiles[p]); - })); + return reporter(Object.keys(vFiles).map(p => vfileSort(vFiles[p]))); } module.exports.lintComments = lintComments; diff --git a/lib/load_config.js b/lib/load_config.js deleted file mode 100644 index 3e0e9781b..000000000 --- a/lib/load_config.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -var yaml = require('js-yaml'), - fs = require('fs'), - path = require('path'), - stripComments = require('strip-json-comments'); - -/** - * Try to load a configuration file: since this is configuration, we're - * lenient with respect to its structure. It can be JSON or YAML, - * and can contain comments, unlike normal JSON. - * - * @param {string} filePath the user-provided path to configuration - * @returns {Object} configuration, if it can be parsed - * @throws {Error} if the file cannot be read. - */ -function loadConfig(filePath) { - var ext = path.extname(filePath); - var absFilePath = path.resolve(process.cwd(), filePath); - var rawFile = fs.readFileSync(absFilePath, 'utf8'); - - try { - if (ext === '.json') { - return processToc(JSON.parse(stripComments(rawFile))); - } - - return processToc(yaml.safeLoad(rawFile)); - } catch (e) { - e.message = 'Cannot read config file: ' + - filePath + - '\nError: ' + - e.message; - throw e; - } - - function processToc(config) { - if (!config || !config.toc) { - return config; - } - - config.toc = config.toc.map(function (entry) { - if (entry && entry.file) { - entry.file = path.join( - path.dirname(absFilePath), - entry.file - ); - } - - return entry; - }); - - return config; - } -} - -module.exports = loadConfig; diff --git a/lib/merge_config.js b/lib/merge_config.js new file mode 100644 index 000000000..f0e765b19 --- /dev/null +++ b/lib/merge_config.js @@ -0,0 +1,87 @@ + +'use strict'; +/* @flow */ + +var yaml = require('js-yaml'), + fs = require('fs'), + pify = require('pify'), + _ = require('lodash'), + readPkgUp = require('read-pkg-up'), + path = require('path'), + stripComments = require('strip-json-comments'); + +function processToc(config /*: DocumentationConfig */, absFilePath/*: string*/) { + if (!config || !config.toc) { + return config; + } + + config.toc = config.toc.map(entry => { + if (entry && entry.file) { + entry.file = path.join( + path.dirname(absFilePath), + entry.file + ); + } + + return entry; + }); + + return config; +} + +/** + * Use the nearest package.json file for the default + * values of `name` and `version` config. + * + * @param {Object} config the user-provided config, usually via argv + * @returns {Object} configuration with inferred parameters + * @throws {Error} if the file cannot be read. + */ +function mergePackage(config/*: Object */)/*: Promise */ { + if (config.noPackage) { + return Promise.resolve(config); + } + return readPkgUp() + .then(pkg => + _.defaults({}, _.mapKeys(_.pick(pkg.pkg, ['name', 'homepage', 'version']), + (val, key) => `project-${key}`), config)) + // Allow this to fail: this inference is not required. + .catch(() => config); +} + +/** + * Merge a configuration file into program config, assuming that the location + * of the configuration file is given as one of those config. + * + * @param {Object} config the user-provided config, usually via argv + * @returns {Promise} configuration, if it can be parsed + * @throws {Error} if the file cannot be read. + */ +function mergeConfigFile(config)/*: Promise */ { + + if (config && typeof config.config === 'string') { + var filePath = config.config; + var ext = path.extname(filePath); + var absFilePath = path.resolve(process.cwd(), filePath); + return pify(fs).readFile(absFilePath, 'utf8') + .then(rawFile => { + if (ext === '.json') { + return Object.assign({}, config, processToc(JSON.parse(stripComments(rawFile)), absFilePath)); + } + return Object.assign({}, config, processToc(yaml.safeLoad(rawFile), absFilePath)); + }); + } + + return Promise.resolve(config || {}); +} + +function mergeConfig(config/*: Object */)/*: Promise */ { + + config.parseExtension = (config.parseExtension || []) + .concat(['js', 'jsx', 'es5', 'es6']); + + return mergeConfigFile(config) + .then(mergePackage); +} + +module.exports = mergeConfig; diff --git a/lib/module_filters.js b/lib/module_filters.js index 6dc31edae..6c10b1855 100644 --- a/lib/module_filters.js +++ b/lib/module_filters.js @@ -1,4 +1,6 @@ +/* @flow */ 'use strict'; + var path = require('path'); var micromatch = require('micromatch'); @@ -27,10 +29,10 @@ module.exports = { * @return {function} - A function for use as the module-deps `postFilter` * options. */ - externals: function externalModuleFilter(indexes, options) { + externals: function externalModuleFilter(indexes/*: Array*/, options/*: Object*/) { var externalFilters = false; if (options.external) { - externalFilters = indexes.map(function (index) { + externalFilters = indexes.map((index) => { // grab the path of the top-level node_modules directory. var topNodeModules = path.join(path.dirname(index), 'node_modules'); return function matchGlob(file, pkg) { @@ -53,13 +55,13 @@ module.exports = { }); } - return function (id, file, pkg) { + return function (id/*: string*/, + file/*: string*/, + pkg/*: Object*/) { var internal = internalModuleRegexp.test(id); return internal || (externalFilters && externalFilters - .some(function (f) { - return f(file, pkg); - })); + .some(f => f(file, pkg))); }; } }; diff --git a/lib/nest.js b/lib/nest.js index 0c688e395..af295d34d 100644 --- a/lib/nest.js +++ b/lib/nest.js @@ -1,16 +1,21 @@ +/* @flow */ 'use strict'; + /** * Nest nestable tags, like param and property, into nested * arrays that are suitable for output. * * @private * @param {Object} comment a comment with tags - * @param {string} tagName the tag to nest + * @param {string} tagTitle the tag to nest * @param {string} target the tag to nest into * @returns {Object} nested comment */ -function nestTag(comment, tagName, target) { +function nestTag( + comment/*: Comment */, + tagTitle/*: string */, + target/*: string */) { if (!comment[target]) { return comment; } @@ -18,26 +23,27 @@ function nestTag(comment, tagName, target) { var result = [], index = {}; - comment[target].forEach(function (tag) { - index[tag.name] = tag; - var parts = tag.name.split(/(\[\])?\./) - .filter(function (part) { - return part && part !== '[]'; - }); - if (parts.length > 1) { - var parent = index[parts.slice(0, -1).join('.')]; - if (parent === undefined) { - comment.errors.push({ - message: '@' + tagName + ' ' + tag.name + '\'s parent ' + parts[0] + ' not found', - commentLineNumber: tag.lineNumber - }); + comment[target].forEach(tag => { + var tagName = tag.name; + if (tagName) { + index[tagName] = tag; + var parts = tagName.split(/(\[\])?\./) + .filter(part => part && part !== '[]'); + if (parts.length > 1) { + var parent = index[parts.slice(0, -1).join('.')]; + if (parent === undefined) { + comment.errors.push({ + message: '@' + tagTitle + ' ' + tag.name + '\'s parent ' + parts[0] + ' not found', + commentLineNumber: tag.lineNumber + }); + result.push(tag); + return; + } + parent.properties = parent.properties || []; + parent.properties.push(tag); + } else { result.push(tag); - return; } - parent.properties = parent.properties || []; - parent.properties.push(tag); - } else { - result.push(tag); } }); @@ -58,7 +64,7 @@ function nestTag(comment, tagName, target) { * @param {Object} comment input comment * @return {Object} nested comment */ -function nest(comment) { +function nest(comment/*: Comment*/) { return nestTag(nestTag(comment, 'param', 'params'), 'property', 'properties'); } diff --git a/lib/output/highlighter.js b/lib/output/highlighter.js index 69caabfe4..234c8b0f3 100644 --- a/lib/output/highlighter.js +++ b/lib/output/highlighter.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var visit = require('unist-util-visit'); var hljs = require('highlight.js'); @@ -16,7 +18,7 @@ function visitor(node) { } } -module.exports = function (ast) { +module.exports = function (ast/*: Object*/) { visit(ast, 'code', visitor); return ast; }; diff --git a/lib/output/html.js b/lib/output/html.js index 249b632d3..88445cac6 100644 --- a/lib/output/html.js +++ b/lib/output/html.js @@ -1,15 +1,17 @@ + 'use strict'; +/* @flow */ var path = require('path'); +var mergeConfig = require('../merge_config'); /** * Formats documentation as HTML. * - * @param {Array} comments parsed comments - * @param {Object} options Options that can customize the output - * @param {string} [options.theme='default_theme'] Name of a module used for an HTML theme. - * @param {Function} callback Called with array of results as vinyl-fs objects. - * @returns {undefined} Calls callback. + * @param comments parsed comments + * @param {Object} args Options that can customize the output + * @param {string} [args.theme='default_theme'] Name of a module used for an HTML theme. + * @returns {Promise>} Promise with results * @name formats.html * @public * @example @@ -17,19 +19,21 @@ var path = require('path'); * var streamArray = require('stream-array'); * var vfs = require('vinyl-fs'); * - * documentation.build(['index.js'], {}, function (err, res) { - * documentation.formats.html(res, {}, function(err, output) { + * documentation.build(['index.js']) + * .then(documentation.formats.html) + * .then(output => { * streamArray(output).pipe(vfs.dest('./output-directory')); * }); - * }); */ -module.exports = function html(comments, options, callback) { - options = options || {}; - var theme; - if (options.theme) { - theme = require(path.resolve(process.cwd(), options.theme)); - } else { - theme = require('../../default_theme/'); - } - theme(comments, options, callback); -}; +function html(comments/*: Array*/, + config/*: DocumentationConfig*/) { + return mergeConfig(config).then(config => { + var themePath = '../../default_theme/'; + if (config.theme) { + themePath = path.resolve(process.cwd(), config.theme); + } + return require(themePath)(comments, config); + }); +} + +module.exports = html; diff --git a/lib/output/json.js b/lib/output/json.js index c9f10c293..b56d4a82c 100644 --- a/lib/output/json.js +++ b/lib/output/json.js @@ -1,35 +1,36 @@ + 'use strict'; +/* @flow */ var walk = require('../walk'); /** * Formats documentation as a JSON string. * - * @param {Array} comments parsed comments - * @param {Object} opts Options that can customize the output - * @param {Function} callback called with null, string + * @param comments parsed comments * @name formats.json - * @return {undefined} calls callback * @public * @example * var documentation = require('documentation'); * var fs = require('fs'); * - * documentation.build(['index.js'], {}, function (err, res) { - * documentation.formats.json(res, {}, function(err, output) { + * documentation.build(['index.js']) + * .then(documentation.formats.json) + * .then(output => { * // output is a string of JSON data * fs.writeFileSync('./output.json', output); * }); - * }); */ -module.exports = function (comments, opts, callback) { +function json(comments/*: Array*/)/*: Promise*/ { - walk(comments, function (comment) { + walk(comments, comment => { delete comment.errors; if (comment.context) { delete comment.context.sortKey; } }); - return callback(null, JSON.stringify(comments, null, 2)); -}; + return Promise.resolve(JSON.stringify(comments, null, 2)); +} + +module.exports = json; diff --git a/lib/output/markdown.js b/lib/output/markdown.js index b2b29bf10..e7b2d36d9 100644 --- a/lib/output/markdown.js +++ b/lib/output/markdown.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var remark = require('remark'), markdownAST = require('./markdown_ast'); @@ -8,24 +10,24 @@ var remark = require('remark'), * [Markdown](http://daringfireball.net/projects/markdown/). * * @param {Array} comments parsed comments - * @param {Object} options Options that can customize the output - * @param {Function} callback called with null, string + * @param {Object} args Options that can customize the output * @name formats.markdown - * @return {undefined} calls callback + * @return {Promise} a promise of the eventual value * @public * @example * var documentation = require('documentation'); * var fs = require('fs'); * - * documentation.build(['index.js'], {}, function (err, res) { - * documentation.formats.md(res, {}, function(err, output) { - * // output is a string of JSON data + * documentation.build(['index.js']) + * .then(documentation.formats.md) + * .then(output => { + * // output is a string of Markdown data * fs.writeFileSync('./output.md', output); * }); - * }); */ -module.exports = function (comments, options, callback) { - markdownAST(comments, options, function (err, ast) { - return callback(null, remark().stringify(ast)); - }); -}; +function markdown(comments/*: Array*/, args/*: Object*/)/*: Promise */ { + return markdownAST(comments, args) + .then(ast => remark().stringify(ast)); +} + +module.exports = markdown; diff --git a/lib/output/markdown_ast.js b/lib/output/markdown_ast.js index d55466749..1dd95acff 100644 --- a/lib/output/markdown_ast.js +++ b/lib/output/markdown_ast.js @@ -1,30 +1,44 @@ +/* @flow */ +'use strict'; + + var u = require('unist-builder'), remark = require('remark'), + mergeConfig = require('../merge_config'), toc = require('remark-toc'), hljs = require('highlight.js'), GithubSlugger = require('github-slugger'), - createLinkerStack = require('./util/linker_stack'), + LinkerStack = require('./util/linker_stack'), rerouteLinks = require('./util/reroute_links'), _formatType = require('./util/format_type'); +var DEFAULT_LANGUAGE = 'javascript'; + /** * Given a hierarchy-nested set of comments, generate an remark-compatible * Abstract Syntax Tree usable for generating Markdown output * - * @param {Array} comments nested comment - * @param {Object} options currently none accepted - * @param {Function} callback called with AST - * @returns {undefined} calls callback + * @param comments nested comment + * @param {Object} args currently none accepted + * @param {boolean} [args.markdownToc=true] whether to include a table of contents + * in markdown output. + * @param {Object} [args.hljs={}] config to be passed to highlightjs for code highlighting: + * consult hljs.configure for the full list. + * @returns {Promise} returns an eventual Markdown value */ -function markdownAST(comments, options, callback) { +function markdownAST(comments/*: Array */, args/*: Object */) { + return mergeConfig(args) + .then(config => buildMarkdownAST(comments, config)); +} + +function buildMarkdownAST(comments/*: Array */, config/*: DocumentationConfig*/) { // Configure code highlighting - var hljsOptions = (options || {}).hljs || {}, - language = !hljsOptions.highlightAuto ? 'javascript' : undefined; + var hljsOptions = config.hljs || {}; hljs.configure(hljsOptions); - var linkerStack = createLinkerStack(options) - .namespaceResolver(comments, function (namespace) { + var linkerStack = new LinkerStack(config) + .namespaceResolver(comments, namespace => { var slugger = new GithubSlugger(); return '#' + slugger.slug(namespace); }); @@ -47,9 +61,9 @@ function markdownAST(comments, options, callback) { * @param {Object} comment a single comment * @returns {Object} remark-compatible AST */ - function generate(depth, comment) { + function generate(depth/*: number */, comment/*: Comment */) { - function typeSection(comment) { + function typeSection(comment/*: Comment */) { return comment.type && u('paragraph', [ u('text', 'Type: ') ].concat( @@ -57,9 +71,9 @@ function markdownAST(comments, options, callback) { )); } - function paramList(params) { - return u('list', { ordered: false }, params.map(function (param) { - return u('listItem', [ + function paramList(params/*: Array */) { + return u('list', { ordered: false }, params.map(param => + u('listItem', [ u('paragraph', [ u('inlineCode', param.name), u('text', ' '), @@ -74,28 +88,27 @@ function markdownAST(comments, options, callback) { ]) ]).filter(Boolean)) ].concat(param.properties && paramList(param.properties)) - .filter(Boolean)); - })); + .filter(Boolean)))); } - function paramSection(comment) { - return !!comment.params && [ + function paramSection(comment/*: Comment */) { + return comment.params.length > 0 && [ u('strong', [u('text', 'Parameters')]), paramList(comment.params) ]; } - function propertySection(comment) { - return !!comment.properties && [ + function propertySection(comment/*: Comment */) { + return comment.properties.length > 0 && [ u('strong', [u('text', 'Properties')]), propertyList(comment.properties) ]; } - function propertyList(properties) { + function propertyList(properties/*: Array */) { return u('list', { ordered: false }, - properties.map(function (property) { - return u('listItem', [ + properties.map(property => + u('listItem', [ u('paragraph', [ u('inlineCode', property.name), u('text', ' '), @@ -105,88 +118,90 @@ function markdownAST(comments, options, callback) { .concat(property.description ? property.description.children: []) .filter(Boolean)), property.properties && propertyList(property.properties) - ].filter(Boolean)); - })); + ].filter(Boolean)))); } - function examplesSection(comment) { - return !!comment.examples && [u('strong', [u('text', 'Examples')])] + function examplesSection(comment/*: Comment */) { + return comment.examples.length > 0 && [u('strong', [u('text', 'Examples')])] .concat(comment.examples.reduce(function (memo, example) { - language = hljsOptions.highlightAuto ? - hljs.highlightAuto(example.description).language : 'javascript'; + var language = hljsOptions.highlightAuto ? + hljs.highlightAuto(example.description).language : DEFAULT_LANGUAGE; return memo.concat(example.caption ? [u('paragraph', [u('emphasis', example.caption)])] : []).concat([u('code', { lang: language }, example.description)]); }, [])); } - function returnsSection(comment) { - return !!comment.returns && comment.returns.map(function (returns) { - return u('paragraph', [ + function returnsSection(comment/*: Comment */) { + return comment.returns.length > 0 && comment.returns.map(returns => + u('paragraph', [ u('text', 'Returns '), u('strong', formatType(returns.type)), u('text', ' ') - ].concat(returns.description ? returns.description.children : [])); - }); + ].concat(returns.description ? returns.description.children : []))); } - function throwsSection(comment) { - return !!comment.throws && + function throwsSection(comment/*: Comment */) { + return comment.throws.length > 0 && u('list', { ordered: false }, - comment.throws.map(function (returns) { - return u('listItem', [ + comment.throws.map(returns => u('listItem', [ u('paragraph', [ u('text', 'Throws '), u('strong', formatType(returns.type)), u('text', ' ') ].concat(returns.description ? returns.description.children : [])) - ]); - })); + ]))); } - function augmentsLink(comment) { - return comment.augments && u('paragraph', [ + function augmentsLink(comment/*: Comment */) { + return comment.augments.length > 0 && u('paragraph', [ u('strong', [ u('text', 'Extends '), - u('text', comment.augments.map(function (tag) { - return tag.name; - }).join(', ')) + u('text', comment.augments.map(tag => tag.name).join(', ')) ]) ]); } - function githubLink(comment) { + function githubLink(comment/*: Comment */) { return comment.context && comment.context.github && u('paragraph', [ u('link', { title: 'Source code on GitHub', - url: comment.context.github - }, [u('text', comment.context.path + ':' + + url: comment.context.github.url + }, [u('text', comment.context.github.path + ':' + comment.context.loc.start.line + '-' + comment.context.loc.end.line)]) ]); } - function metaSection(comment) { - var meta = ['version', 'since', 'copyright', 'author', 'license'] - .reduce(function (memo, tag) { - if (comment[tag]) { - memo.push({ tag: tag, value: comment[tag] }); - } - return memo; - }, []); + function metaSection(comment/*: Comment */) { + let meta = ['version', 'since', 'copyright', 'author', 'license'] + .filter(tag => comment[tag]); return !!meta.length && [u('strong', [u('text', 'Meta')])].concat( u('list', { ordered: false }, - meta.map(function (item) { + meta + .map(tag => { + let metaContent; + if (tag === 'copyright') { + metaContent = comment[tag]; + } else { + metaContent = u('text', comment[tag]); + } return u('listItem', [ u('paragraph', [ - u('strong', [u('text', item.tag)]), - u('text', ': ' + item.value) + u('strong', [u('text', tag)]), + u('text', ': '), + metaContent ]) ]); }))); } - return [u('heading', { depth: depth }, [u('text', comment.name || '')])] + if (comment.kind === 'note') { + return [u('heading', { depth }, [u('text', comment.name || '')])] + .concat(comment.description); + } + + return [u('heading', { depth }, [u('text', comment.name || '')])] .concat(githubLink(comment)) .concat(augmentsLink(comment)) .concat(comment.description ? comment.description.children : []) @@ -198,30 +213,25 @@ function markdownAST(comments, options, callback) { .concat(returnsSection(comment)) .concat(metaSection(comment)) .concat(!!comment.members.instance.length && - comment.members.instance.reduce(function (memo, child) { - return memo.concat(generate(depth + 1, child)); - }, [])) + comment.members.instance.reduce((memo, child) => + memo.concat(generate(depth + 1, child)), [])) .concat(!!comment.members.static.length && - comment.members.static.reduce(function (memo, child) { - return memo.concat(generate(depth + 1, child)); - }, [])) + comment.members.static.reduce((memo, child) => + memo.concat(generate(depth + 1, child)), [])) .filter(Boolean); } var root = rerouteLinks(linkerStack.link, u('root', generatorComment - .concat(options.markdownToc ? tableOfContentsHeading : []) - .concat(comments.reduce(function (memo, comment) { - return memo.concat(generate(2, comment)); - }, [])))); - - if (!options['no-markdown-toc']) { - return remark().use(toc, { - tight: true - }).run(root, callback); + .concat(config.markdownToc ? tableOfContentsHeading : []) + .concat(comments.reduce((memo, comment) => + memo.concat(generate(2, comment)), [])))); + + if (config.markdownToc) { + root = remark().use(toc, { tight: true }).run(root); } - return callback(null, root); + return Promise.resolve(root); } module.exports = markdownAST; diff --git a/lib/output/util/format_type.js b/lib/output/util/format_type.js index ff7b47302..19ed6913d 100644 --- a/lib/output/util/format_type.js +++ b/lib/output/util/format_type.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var Syntax = require('doctrine').Syntax, u = require('unist-builder'); @@ -31,7 +33,7 @@ function link(text, getHref, description) { // and then we should remove the 'href' property and only // have the url property of links return u('link', { - href: href, + href, url: href }, [t(description || text)]); } @@ -95,7 +97,7 @@ function decorate(formatted, str, prefix) { * formatType({ type: 'NameExpression', name: 'String' })[0].url * // => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String' */ -function formatType(getHref, node) { +function formatType(getHref/*: Function*/, node/*: ?Object */) { var result = []; if (!node) { diff --git a/lib/output/util/formatters.js b/lib/output/util/formatters.js index d2cb1b036..7d02c5b5a 100644 --- a/lib/output/util/formatters.js +++ b/lib/output/util/formatters.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var remark = require('remark'), html = require('remark-html'), Syntax = require('doctrine').Syntax, @@ -10,10 +12,10 @@ var remark = require('remark'), * Create a formatter group, given a linker method that resolves * namespaces to URLs * - * @param {Function} getHref linker method + * @param getHref linker method * @returns {formatters} formatter object */ -module.exports = function (getHref) { +module.exports = function (getHref/*: Function*/) { var rerouteLinks = _rerouteLinks.bind(undefined, getHref); var formatters = {}; @@ -27,7 +29,7 @@ module.exports = function (getHref) { * @param {boolean} short whether to cut the details and make it skimmable * @returns {string} formatted parameter representation. */ - formatters.parameter = function (param, short) { + formatters.parameter = function (param/*: Object*/, short/*: boolean */)/*: string */ { if (short) { if (param.type && param.type.type == Syntax.OptionalType) { if (param.default) { @@ -51,6 +53,7 @@ module.exports = function (getHref) { .use(html) .stringify(highlighter(rerouteLinks(ast))); } + return ''; }; /** @@ -59,7 +62,7 @@ module.exports = function (getHref) { * @param {Object} type doctrine-format type * @returns {string} HTML */ - formatters.type = function (type) { + formatters.type = function (type/*: Object*/) { return formatters.markdown(u('root', formatType(getHref, type))).replace(/\n/g, ''); }; @@ -69,14 +72,14 @@ module.exports = function (getHref) { * @param {string} description link text override * @returns {string} potentially linked HTML */ - formatters.autolink = function (text) { + formatters.autolink = function (text/*: string*/) { var href = getHref(text); if (href) { // TODO: this is a temporary fix until we drop remark 3.x support, // and then we should remove the 'href' property and only // have the url property of links return formatters.markdown(u('link', { - href: href, + href, url: href }, [u('text', text)])).replace(/\n/g, ''); } @@ -92,7 +95,7 @@ module.exports = function (getHref) { * @param {boolean} short whether to cut the details and make it skimmable * @returns {string} formatted parameters */ - formatters.parameters = function (section, short) { + formatters.parameters = function (section/*: Comment*/, short/*: boolean */) { if (section.params) { return '(' + section.params.map(function (param) { return formatters.parameter(param, short); diff --git a/lib/output/util/linker_stack.js b/lib/output/util/linker_stack.js index 4eb16728f..0888ecebf 100644 --- a/lib/output/util/linker_stack.js +++ b/lib/output/util/linker_stack.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var globalsDocs = require('globals-docs'); var walk = require('../../walk'); @@ -7,7 +9,7 @@ var walk = require('../../walk'); * @param {Object} paths an object specified in documentation.yml of hard paths * @returns {Function} linker */ -function pathsLinker(paths) { +function pathsLinker(paths/* Object */) { return function (namespace) { if (paths[namespace]) { return paths[namespace]; @@ -23,7 +25,7 @@ function pathsLinker(paths) { * @param {*} input any input * @returns {*} any output */ -function firstPass(fns, input) { +function firstPass(fns/*: Array */, input) { for (var i = 0; i < fns.length; i++) { var output = fns[i](input); if (output) { @@ -39,73 +41,76 @@ function firstPass(fns, input) { * @param {Object} config - configuration value * @returns {Function} linker method */ -function LinkerStack(config) { - config = config || {}; - this.stack = []; +class LinkerStack { - if (config.defaultGlobals !== false) { - this.stack.unshift(function (namespace) { - if (namespace) { - return globalsDocs.getDoc(namespace, config.defaultGlobalsEnvs); + /* :: stack: Array */ + /* :: link: Function */ + + constructor(config/*: DocumentationConfig */) { + this.stack = []; + + if (config.defaultGlobals !== false) { + this.stack.unshift(namespace => { + if (namespace) { + return globalsDocs.getDoc(namespace, config.defaultGlobalsEnvs); + } + }); + } + + if (config.paths) { + this.stack.unshift(pathsLinker(config.paths)); + } + + this.link = this._link.bind(this); + } + + /** + * Given that the linker stack is a stack of functions, each of which might + * be able to resolve the URL target of a given namespace, namespaceResolver + * adds a function to the stack. You give it a list of comments and it + * adds a function that, if it matches a namespace to a comment, runs + * `resolver` on that comment's namespace in order to get a URL. This makes + * it possible for themes to put each function on a separate page, or at + * different anchors on the same page, and the resolver does stuff like + * adding '#' in front of the namespace or turning the namespace into a URL + * path. + * + * @param {Array} comments a list of comments + * @param {Function} resolver a method that turns a namespace into a URL + * @returns {LinkerStack} returns this + * @private + * @example + * var linkerStack = new LinkerStack(options) + * .namespaceResolver(comments, function (namespace) { + * var slugger = new GithubSlugger(); + * return '#' + slugger.slug(namespace); + * }); + */ + namespaceResolver(comments /*: Array */, resolver/*: Function */) { + var namespaces = {}; + walk(comments, comment => { + namespaces[comment.namespace] = true; + }); + this.stack.unshift(namespace => { + if (namespaces[namespace] === true) { + return resolver(namespace); } }); + return this; } - if (config.paths) { - this.stack.unshift(pathsLinker(config.paths)); + /** + * Now that you've configured the LinkerStack with `namespaceResolver` + * and a configuration, run it against a namepath. Might return a URL if + * it can resolve a target, otherwise returns undefined. + * + * @param {string} namepath the namepath of a comment + * @returns {string?} URL target or maybe undefined + * @private + */ + _link(namepath/*: string */) { + return firstPass(this.stack, namepath); } - - this.link = this.link.bind(this); } -/** - * Given that the linker stack is a stack of functions, each of which might - * be able to resolve the URL target of a given namespace, namespaceResolver - * adds a function to the stack. You give it a list of comments and it - * adds a function that, if it matches a namespace to a comment, runs - * `resolver` on that comment's namespace in order to get a URL. This makes - * it possible for themes to put each function on a separate page, or at - * different anchors on the same page, and the resolver does stuff like - * adding '#' in front of the namespace or turning the namespace into a URL - * path. - * - * @param {Array} comments a list of comments - * @param {Function} resolver a method that turns a namespace into a URL - * @returns {LinkerStack} returns this - * @private - * @example - * var linkerStack = createLinkerStack(options) - * .namespaceResolver(comments, function (namespace) { - * var slugger = new GithubSlugger(); - * return '#' + slugger.slug(namespace); - * }); - */ -LinkerStack.prototype.namespaceResolver = function (comments, resolver) { - var namespaces = {}; - walk(comments, function (comment) { - namespaces[comment.namespace] = true; - }); - this.stack.unshift(function (namespace) { - if (namespaces[namespace] === true) { - return resolver(namespace); - } - }); - return this; -}; - -/** - * Now that you've configured the LinkerStack with `namespaceResolver` - * and a configuration, run it against a namepath. Might return a URL if - * it can resolve a target, otherwise returns undefined. - * - * @param {string} namepath the namepath of a comment - * @returns {string?} URL target or maybe undefined - * @private - */ -LinkerStack.prototype.link = function (namepath) { - return firstPass(this.stack, namepath); -}; - -module.exports = function (opts) { - return new LinkerStack(opts); -}; +module.exports = LinkerStack; diff --git a/lib/output/util/reroute_links.js b/lib/output/util/reroute_links.js index 7fc828fce..ebc2a5209 100644 --- a/lib/output/util/reroute_links.js +++ b/lib/output/util/reroute_links.js @@ -1,13 +1,15 @@ +/* @flow */ +'use strict'; var visit = require('unist-util-visit'); /** * Reroute inline jsdoc links in documentation - * @param {Function} getHref a method that resolves namespaces - * @param {Object} ast remark AST + * @param getHref a method that resolves namespaces + * @param ast remark AST * @returns {Object} that ast with rerouted links * @private */ -module.exports = function rerouteLinks(getHref, ast) { +module.exports = function rerouteLinks(getHref/*: Function */, ast/*: Object*/) { visit(ast, 'link', function (node) { if (node.jsdoc && !node.url.match(/^(http|https|\.)/) && getHref(node.url)) { node.url = getHref(node.url); diff --git a/lib/parse.js b/lib/parse.js index f74306630..2a547cb65 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var doctrine = require('doctrine'); var parseMarkdown = require('./parse_markdown'); @@ -32,9 +34,6 @@ var flatteners = { * @returns {undefined} has side-effects */ 'augments': function (result, tag) { - if (!result.augments) { - result.augments = []; - } // Google variation of augments/extends tag: // uses type with brackets instead of name. // https://github.com/google/closure-library/issues/746 @@ -112,11 +111,7 @@ var flatteners = { return; } - if (!result.examples) { - result.examples = []; - } - - var example = { + var example/*: CommentExample */ = { description: tag.description }; @@ -236,11 +231,8 @@ var flatteners = { * @returns {undefined} has side-effects */ 'param': function (result, tag) { - if (!result.params) { - result.params = []; - } - - var param = { + var param/*: CommentTag */ = { + title: 'param', name: tag.name, lineNumber: tag.lineNumber // TODO: remove }; @@ -277,11 +269,8 @@ var flatteners = { * @returns {undefined} has side-effects */ 'property': function (result, tag) { - if (!result.properties) { - result.properties = []; - } - - var property = { + var property/*: CommentTag */ = { + title: 'property', name: tag.name, lineNumber: tag.lineNumber // TODO: remove }; @@ -325,12 +314,9 @@ var flatteners = { * @returns {undefined} has side-effects */ 'returns': function (result, tag) { - if (!result.returns) { - result.returns = []; - } - - var returns = { - description: parseMarkdown(tag.description) + var returns/*: CommentTag */ = { + description: parseMarkdown(tag.description), + title: 'returns' }; if (tag.type) { @@ -347,9 +333,6 @@ var flatteners = { * @returns {undefined} has side-effects */ 'see': function (result, tag) { - if (!result.sees) { - result.sees = []; - } result.sees.push(parseMarkdown(tag.description)); }, 'since': flattenDescription, @@ -372,10 +355,6 @@ var flatteners = { * @returns {undefined} has side-effects */ 'throws': function (result, tag) { - if (!result.throws) { - result.throws = []; - } - var throws = {}; if (tag.description) { @@ -396,9 +375,6 @@ var flatteners = { * @returns {undefined} has side-effects */ 'todo': function (result, tag) { - if (!result.todos) { - result.todos = []; - } result.todos.push(parseMarkdown(tag.description)); }, 'tutorial': todo, @@ -584,7 +560,9 @@ function flattenKindShorthand(result, tag, key) { * @return {Comment} an object conforming to the * [documentation schema](https://github.com/documentationjs/api-json) */ -function parseJSDoc(comment, loc, context) { +function parseJSDoc(comment/*: string*/, + loc/*: ?Object*/, + context/*: ?Object*/)/*: Comment */ { var result = doctrine.parse(comment, { // have doctrine itself remove the comment asterisks from content unwrap: true, @@ -598,7 +576,16 @@ function parseJSDoc(comment, loc, context) { result.loc = loc; result.context = context; + + result.augments = []; result.errors = []; + result.examples = []; + result.params = []; + result.properties = []; + result.returns = []; + result.sees = []; + result.throws = []; + result.todos = []; if (result.description) { result.description = parseMarkdown(result.description); diff --git a/lib/parse_markdown.js b/lib/parse_markdown.js index 6814b52c5..4b12060d9 100644 --- a/lib/parse_markdown.js +++ b/lib/parse_markdown.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var remark = require('remark'); var inlineTokenizer = require('./inline_tokenizer'); @@ -9,7 +11,7 @@ var inlineTokenizer = require('./inline_tokenizer'); * @returns {Object} abstract syntax tree * @private */ -function parseMarkdown(string) { +function parseMarkdown(string/*: string */) { return remark().use(inlineTokenizer).parse(string); } diff --git a/lib/parsers/javascript.js b/lib/parsers/javascript.js index 9fada0ed1..cd9ff2edc 100644 --- a/lib/parsers/javascript.js +++ b/lib/parsers/javascript.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var _ = require('lodash'), parse = require('../../lib/parse'), @@ -27,35 +29,39 @@ function leftPad(str, width) { * reads the file, parses the JavaScript, and parses the JSDoc. * * @param {Object} data a chunk of data provided by module-deps - * @param {Object} options options + * @param {Object} config config * @return {Array} an array of parsed comments */ -function parseJavaScript(data, options) { - options = options || {}; - var visited = Object.create(null); +function parseJavaScript(data/*: Object*/, + config/*: DocumentationConfig */) { + var visited = new Set(); var ast = parseToAst(data.source, data.file); var addComment = _addComment.bind(null, visited); - return _.flatMap(options.documentExported ? [ + return _.flatMap(config.documentExported ? [ walkExported ] : [ walkComments.bind(null, 'leadingComments', true), walkComments.bind(null, 'innerComments', false), walkComments.bind(null, 'trailingComments', false) - ], function (fn) { - return fn(ast, data, addComment); - }).filter(Boolean); + ], fn => fn(ast, data, addComment)).filter(Boolean); } function _addComment(visited, data, commentValue, commentLoc, path, nodeLoc, includeContext) { // Avoid visiting the same comment twice as a leading // and trailing node var key = data.file + ':' + commentLoc.start.line + ':' + commentLoc.start.column; - if (!visited[key]) { - visited[key] = true; + if (!visited.has(key)) { + visited.add(key); - var context = { + var context/* : { + loc: Object, + file: string, + sortKey: string, + ast?: Object, + code?: string + }*/ = { loc: nodeLoc, file: data.file, sortKey: data.sortKey + ' ' + leftPad(nodeLoc.start.line, 8) @@ -65,6 +71,7 @@ function _addComment(visited, data, commentValue, commentLoc, path, nodeLoc, inc // This is non-enumerable so that it doesn't get stringified in // output; e.g. by the documentation binary. Object.defineProperty(context, 'ast', { + configurable: true, enumerable: false, value: path }); diff --git a/lib/parsers/parse_to_ast.js b/lib/parsers/parse_to_ast.js index 22700d5f0..4b539d214 100644 --- a/lib/parsers/parse_to_ast.js +++ b/lib/parsers/parse_to_ast.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var babylon = require('babylon'); @@ -23,7 +25,7 @@ var opts = { ] }; -function parseToAst(source) { +function parseToAst(source/*: string*/) { return babylon.parse(source, opts); } diff --git a/lib/parsers/polyglot.js b/lib/parsers/polyglot.js index 3cfee500c..d521c3082 100644 --- a/lib/parsers/polyglot.js +++ b/lib/parsers/polyglot.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var getComments = require('get-comments'), extend = require('extend'), @@ -12,14 +14,14 @@ var getComments = require('get-comments'), * @param {Object} data a chunk of data provided by module-deps * @return {Array} adds to memo */ -function parsePolyglot(data) { - return getComments(data.source, true) +function parsePolyglot(sourceFile/*: SourceFile*/) { + return getComments(sourceFile.source, true) .filter(isJSDocComment) - .map(function (comment) { + .map(comment => { var context = { loc: extend({}, comment.loc), - file: data.file, - sortKey: data.file + ' ' + comment.loc.start.line + file: sourceFile.file, + sortKey: sourceFile.file + ' ' + comment.loc.start.line }; return parse(comment.value, comment.loc, context); }); diff --git a/lib/serve/error_page.js b/lib/serve/error_page.js index c131e300a..03c414c77 100644 --- a/lib/serve/error_page.js +++ b/lib/serve/error_page.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var File = require('vinyl'); var ansiHTML = require('ansi-html'); @@ -20,10 +22,10 @@ ansiHTML.setColors({ /** * Given an error, generate an HTML page that represents the error. - * @param {Error} error parse or generation error + * @param error parse or generation error * @returns {Object} vinyl file object */ -function errorPage(error) { +function errorPage(error/*: Error*/) { var errorText = error.toString(); if (error.codeFrame) { errorText += '
' + ansiHTML(error.codeFrame) + '
'; diff --git a/lib/serve/server.js b/lib/serve/server.js index 7440239a3..921b26387 100644 --- a/lib/serve/server.js +++ b/lib/serve/server.js @@ -1,10 +1,19 @@ +/* @flow */ +'use strict'; var http = require('http'), mime = require('mime'), - util = require('util'), + pify = require('pify'), EventEmitter = require('events').EventEmitter, liveReload = require('tiny-lr'), sep = require('path').sep; +/* :: +declare type ServerFile = { + relative: string, + contents: string +}; +*/ + /** * A static file server designed to support documentation.js's --serve * option. It serves from an array of Vinyl File objects (virtual files in @@ -12,119 +21,114 @@ var http = require('http'), * of files and notifies any browsers using LiveReload to reload * and display the new content. * @class - * @param {number} port server port to serve on. + * @param port server port to serve on. */ -function Server(port) { - if (typeof port !== 'number') { - throw new Error('port argument required to initialize a server'); - } - this._port = port; - this._files = []; -} +class Server extends EventEmitter { -util.inherits(Server, EventEmitter); - -/** - * Update the set of files exposed by this server and notify LiveReload - * clients - * - * @param {Array} files new content. replaces any previously-set content. - * @returns {Server} self - */ -Server.prototype.setFiles = function (files) { - this._files = files; - if (this._lr) { - this._lr.changed({ body: { files: '*' } }); - } - return this; -}; + /* :: _lr: Object; */ + /* :: _port: number; */ + /* :: _files: Array; */ + /* :: _http: http.Server; */ -/** - * Internal handler for server requests. The server serves - * very few types of things: html, images, and so on, and it - * only handles GET requests. - * - * @param {http.Request} request content wanted - * @param {http.Response} response content returned - * @returns {undefined} nothing - * @private - */ -Server.prototype.handler = function (request, response) { - var path = request.url.substring(1); - if (path === '') { - path = 'index.html'; + constructor(port/*: number*/) { + super(); + if (typeof port !== 'number') { + throw new Error('port argument required to initialize a server'); + } + this._port = port; + this._files = []; } - for (var i = 0; i < this._files.length; i++) { - var file = this._files[i]; - var filePath = file.relative.split(sep).join('/'); - if (filePath === path) { - response.writeHead(200, { 'Content-Type': mime.lookup(path) }); - response.end(file.contents); - return; + /** + * Update the set of files exposed by this server and notify LiveReload + * clients + * + * @param files new content. replaces any previously-set content. + * @returns {Server} self + */ + setFiles(files/*: Array */) { + this._files = files; + if (this._lr) { + this._lr.changed({ body: { files: '*' } }); } + return this; } - response.writeHead(404, { 'Content-Type': 'text/plain' }); - response.end('Not found'); -}; - -/** - * Boot up the server's HTTP & LiveReload endpoints. This method - * can be called multiple times. - * - * @param {Function} [callback=] called when server is started - * @returns {undefined} - */ -Server.prototype.start = function (callback) { - callback = callback || noop; + /** + * Internal handler for server requests. The server serves + * very few types of things: html, images, and so on, and it + * only handles GET requests. + * + * @param {http.Request} request content wanted + * @param {http.Response} response content returned + * @returns {undefined} nothing + * @private + */ + handler(request/*: http.IncomingMessage */, response/*: http.ServerResponse */) { + var path = request.url.substring(1); + if (path === '') { + path = 'index.html'; + } - // idempotent - if (this._lr) { - return callback(); + for (var i = 0; i < this._files.length; i++) { + var file = this._files[i]; + var filePath = file.relative.split(sep).join('/'); + if (filePath === path) { + response.writeHead(200, { 'Content-Type': mime.lookup(path) }); + response.end(file.contents); + return; + } + } + response.writeHead(404, { 'Content-Type': 'text/plain' }); + response.end('Not found'); } - this._lr = liveReload(); - this._http = http.createServer(this.handler.bind(this)); - - this._lr.listen(35729, function () { - this._http.listen(this._port, function () { - this.emit('listening'); - callback(); - }.bind(this)); - }.bind(this)); -}; - -/** - * Shut down the server's HTTP & LiveReload endpoints. This method - * can be called multiple times. - * - * @param {Function} [callback=] called when server is closed - * @returns {undefined} - */ -Server.prototype.stop = function (callback) { - - callback = callback || noop; - - // idempotent - if (!this._lr) { - return callback(); + /** + * Boot up the server's HTTP & LiveReload endpoints. This method + * can be called multiple times. + * + * @returns {Promise} resolved when server starts + */ + start()/*: Promise */ { + return new Promise(resolve => { + // idempotent + if (this._lr) { + return resolve(true); + } + + this._lr = liveReload(); + this._http = http.createServer(this.handler.bind(this)); + + return Promise.all([ + pify(this._lr.listen.bind(this._lr))(35729), + pify(this._http.listen.bind(this._http))(this._port) + ]).then(() => { + this.emit('listening'); + return resolve(true); + }); + }); } - this._http.close(function () { - this._lr.close(); - this._http = null; - this._lr = null; - callback(); - }.bind(this)); -}; - -/** - * A placeholder method that will be called instead of `callback` if - * callback is omitted for the server control methods - * @private - * @returns {undefined} doesn't return anything - */ -function noop() {} + /** + * Shut down the server's HTTP & LiveReload endpoints. This method + * can be called multiple times. + */ + stop()/*: Promise */ { + + return new Promise(resolve => { + // idempotent + if (!this._lr) { + return resolve(true); + } + + this._http.close(() => { + this._lr.close(); + delete this._http; + delete this._lr; + resolve(true); + }); + }); + } +} module.exports = Server; diff --git a/lib/smart_glob.js b/lib/smart_glob.js index 72f81277f..c149f11ed 100644 --- a/lib/smart_glob.js +++ b/lib/smart_glob.js @@ -1,3 +1,5 @@ +/* @flow */ +'use strict'; var fs = require('fs'); var path = require('path'); var glob = require('glob'); @@ -81,12 +83,12 @@ function resolveFileGlobPatterns(patterns, extensions) { * Build a list of absolute filesnames on which ESLint will act. * Ignored files are excluded from the results, as are duplicates. * - * @param {string[]} globPatterns Glob patterns. - * @returns {string[]} Resolved absolute filenames. + * @param globPatterns Glob patterns. + * @returns Resolved absolute filenames. */ -function listFilesToProcess(globPatterns) { +function listFilesToProcess(globPatterns/*: Array*/)/*: Array */ { var files = [], - added = Object.create(null); + added = new Set(); var cwd = process.cwd(); @@ -97,11 +99,11 @@ function listFilesToProcess(globPatterns) { * @returns {void} */ function addFile(filename) { - if (added[filename]) { + if (added.has(filename)) { return; } files.push(filename); - added[filename] = true; + added.add(filename); } globPatterns.forEach(function (pattern) { @@ -124,7 +126,8 @@ function listFilesToProcess(globPatterns) { return files; } -function smartGlob(indexes, extensions) { +function smartGlob(indexes/*: Array*/, + extensions/*: Array*/) { return listFilesToProcess( resolveFileGlobPatterns(indexes, extensions) ); diff --git a/lib/sort.js b/lib/sort.js index cac44ffb4..32d536b68 100644 --- a/lib/sort.js +++ b/lib/sort.js @@ -1,4 +1,6 @@ + 'use strict'; +/* @flow */ var parseMarkdown = require('./parse_markdown'); var chalk = require('chalk'); @@ -14,7 +16,7 @@ var fs = require('fs'); * @return {number} sorting value * @private */ -module.exports = function sortDocs(comments, options) { +module.exports = function sortDocs(comments/*: Array*/, options/*: Object*/) { if (!options || !options.toc) { return sortComments(comments, options && options.sortOrder); } @@ -35,27 +37,27 @@ module.exports = function sortDocs(comments, options) { }, Object.create(null)); // Table of contents 'theme' entries: defined as objects // in the YAML list - var fixed = options.toc.filter(function (val) { - return typeof val === 'object' && val.name; - }).map(function (val) { - if (typeof val.file === 'string') { - var filename = val.file; - if (!path.isAbsolute(val.file)) { - filename = path.join(process.cwd(), val.file); - } + var fixed = options.toc + .filter(val => typeof val === 'object' && val.name) + .map(function (val) { + if (typeof val.file === 'string') { + var filename = val.file; + if (!path.isAbsolute(val.file)) { + filename = path.join(process.cwd(), val.file); + } - try { - val.description = fs.readFileSync(filename).toString(); - delete val.file; - } catch (err) { - process.stderr.write(chalk.red('Failed to read file ' + filename)); + try { + val.description = fs.readFileSync(filename).toString(); + delete val.file; + } catch (err) { + process.stderr.write(chalk.red(`Failed to read file ${filename}`)); + } } - } - if (typeof val.description === 'string') { - val.description = parseMarkdown(val.description); - } - return val; - }); + if (typeof val.description === 'string') { + val.description = parseMarkdown(val.description); + } + return val; + }); var unfixed = []; comments .forEach(function (comment) { @@ -75,38 +77,33 @@ module.exports = function sortDocs(comments, options) { unfixed.push(comment); } }); - fixed.sort(function (a, b) { + fixed.sort((a, b) => { if (indexes[a.name] !== undefined && indexes[b.name] !== undefined) { return indexes[a.name] - indexes[b.name]; } }); sortComments(unfixed, options.sortOrder); - Object.keys(toBeSorted).filter(function (key) { - return toBeSorted[key] === false; - }).forEach(function (key) { - process.stderr.write(chalk.red('Table of contents defined sorting of ' + key + - ' but no documentation with that namepath was found\n')); - }); + Object.keys(toBeSorted) + .filter(key => toBeSorted[key] === false) + .forEach(key => { + process.stderr.write(chalk.red('Table of contents defined sorting of ' + key + + ' but no documentation with that namepath was found\n')); + }); return fixed.concat(unfixed); }; -function compare(a, b) { +function compare(a/*: string */, b/*: string */) { return a.localeCompare(b, undefined, {caseFirst: 'upper'}); } function compareCommentsByName(a, b) { - var rv; - if (a.memberof) { - if (b.memberof) { - rv = compare(a.memberof, b.memberof); - } else { - rv = compare(a.memberof, b.name); - } - } else if (b.memberof) { - rv = compare(a.name, b.memberof); - } + var akey = a.memberof || a.name; + var bkey = b.memberof || b.name; - return rv || compare(a.name, b.name); + if (akey && bkey) { + return compare(akey, bkey); + } + return 0; } function compareCommentsBySourceLocation(a, b) { diff --git a/lib/walk.js b/lib/walk.js index dc9069b59..119ac84d8 100644 --- a/lib/walk.js +++ b/lib/walk.js @@ -1,3 +1,6 @@ +/* @flow */ +'use strict'; + /** * Apply a function to all comments within a hierarchy: this iterates * through children in the 'members' property. @@ -7,8 +10,8 @@ * @param {Object} [options] options passed through to walker function * @returns {Array} comments */ -function walk(comments, fn, options) { - comments.forEach(function (comment) { +function walk(comments/*: Array*/, fn/*: Function*/, options/*: ?Object*/) { + comments.forEach(comment => { fn(comment, options); for (var scope in comment.members) { walk(comment.members[scope], fn, options); diff --git a/package.json b/package.json index 7cbbc77d3..2caf3781c 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "get-comments": "^1.0.1", "git-url-parse": "^6.0.1", "github-slugger": "1.1.1", - "globals-docs": "^2.3.0", "glob": "^7.0.0", + "globals-docs": "^2.3.0", "highlight.js": "^9.1.0", "js-yaml": "^3.3.1", "lodash": "^4.11.1", @@ -39,6 +39,8 @@ "mime": "^1.3.4", "module-deps-sortable": "4.0.6", "parse-filepath": "^0.6.3", + "pify": "^2.3.0", + "read-pkg-up": "^2.0.0", "remark": "^6.0.1", "remark-html": "5.0.1", "remark-toc": "^3.0.0", @@ -58,14 +60,18 @@ "yargs": "^6.0.0" }, "devDependencies": { + "are-we-flow-yet": "^1.0.0", + "babel-eslint": "^7.1.1", "chdir": "0.0.0", - "standard-changelog": "0.0.1", "cz-conventional-changelog": "1.2.0", "documentation-schema": "0.0.1", "eslint": "^3.12.2", + "eslint-plugin-flowtype": "^2.29.2", + "flow-bin": "^0.37.4", "fs-extra": "^1.0.0", "json-schema": "0.2.3", "mock-fs": "^3.5.0", + "standard-changelog": "0.0.1", "tap": "^8.0.0", "tmp": "^0.0.29" }, @@ -88,11 +94,15 @@ "doc": "./bin/documentation.js build 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": "npm run lint && npm run self-lint && tap -t 120 --coverage --nyc-arg=--cache test/*.js test/lib test/streams" + "test": "are-we-flow-yet lib && flow check && npm run lint && npm run self-lint && npm run test-tap", + "test-tap": "tap -t 120 --coverage --nyc-arg=--cache test/*.js test/lib test/streams" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } + }, + "engines": { + "node": ">=4" } } diff --git a/test/bin-readme.js b/test/bin-readme.js index e930df13c..381258d6b 100644 --- a/test/bin-readme.js +++ b/test/bin-readme.js @@ -1,3 +1,4 @@ +'use strict'; var test = require('tap').test, path = require('path'), os = require('os'), @@ -91,6 +92,16 @@ test('readme command', function (group) { }); }); + group.test('-s: not found', function (t) { + t.error(err); + fs.copySync(path.join(fixtures, 'README.output.md'), path.join(d, 'uptodate.md')); + documentation(['readme index.js --diff-only -s NOTFOUND --readme-file uptodate.md'], + {cwd: d}, function (err, stdout, stderr) { + t.ok(err); + t.end(); + }); + }); + group.test('requires -s option', function (t) { documentation(['readme index.js'], {cwd: d}, function (err, stdout, stderr) { t.ok(err); diff --git a/test/bin.js b/test/bin.js index c63a73cd5..533b98ba4 100644 --- a/test/bin.js +++ b/test/bin.js @@ -122,6 +122,14 @@ test('accepts config file - reports failures', options, function (t) { }, false); }); +test('accepts config file - reports parse failures', options, function (t) { + documentation(['build fixture/sorting/input.js -c fixture/config-malformed.json'], {}, + function (err, data, stderr) { + t.match(stderr, /SyntaxError/g, 'Reports a SyntaxError with bad config'); + t.end(); + }, false); +}); + test('--shallow option', function (t) { documentation(['build --shallow fixture/internal.input.js'], function (err, data) { t.error(err); @@ -258,6 +266,15 @@ test('lint command', function (group) { }, false); }); + group.test('lint with no inputs', options, function (t) { + documentation(['lint'], { + cwd: path.join(__dirname, 'fixture/bad') + }, function (err, data) { + t.ok(err.code > 0, 'exits with a > 0 exit code'); + t.end(); + }, false); + }); + group.end(); }); diff --git a/test/fixture/_external-deps-included.json b/test/fixture/_external-deps-included.json index 15b2c155d..7968ca9cf 100644 --- a/test/fixture/_external-deps-included.json +++ b/test/fixture/_external-deps-included.json @@ -109,7 +109,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { @@ -211,7 +219,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -266,12 +278,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "main", "kind": "function", "members": { @@ -373,7 +389,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -428,12 +448,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "index", "kind": "function", "members": { diff --git a/test/fixture/_multi-file-input.json b/test/fixture/_multi-file-input.json index dd227b807..d3a6bf704 100644 --- a/test/fixture/_multi-file-input.json +++ b/test/fixture/_multi-file-input.json @@ -100,9 +100,16 @@ } } }, + "augments": [], "errors": [], + "examples": [ + { + "description": "var result = returnTwo(4);\n// result is 6" + } + ], "params": [ { + "title": "param", "name": "a", "lineNumber": 3, "description": { @@ -163,6 +170,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -217,17 +225,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], - "examples": [ - { - "description": "var result = returnTwo(4);\n// result is 6" - } - ], + "sees": [], + "throws": [], + "todos": [], "name": "returnTwo", "kind": "function", "members": { @@ -329,7 +336,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -384,12 +395,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple.input", "kind": "function", "members": { diff --git a/test/fixture/boolean-literal-type.output.json b/test/fixture/boolean-literal-type.output.json index 51d31929a..69345a958 100644 --- a/test/fixture/boolean-literal-type.output.json +++ b/test/fixture/boolean-literal-type.output.json @@ -24,9 +24,9 @@ } } }, + "augments": [], "errors": [], - "name": "f", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -47,8 +47,10 @@ } } ], + "properties": [], "returns": [ { + "title": "returns", "type": { "type": "ArrayType", "elements": [ @@ -64,6 +66,11 @@ } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "f", + "kind": "function", "members": { "instance": [], "static": [], diff --git a/test/fixture/boolean-literal-type.output.md.json b/test/fixture/boolean-literal-type.output.md.json index 3f5dff173..c6e85d7d4 100644 --- a/test/fixture/boolean-literal-type.output.md.json +++ b/test/fixture/boolean-literal-type.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "f" } - ], - "data": { - "id": "f", - "htmlAttributes": { - "id": "f" - }, - "hProperties": { - "id": "f" - } - } + ] }, { "type": "strong", diff --git a/test/fixture/class.config.output.md b/test/fixture/class.config.output.md index 5f0f252c7..ff4da14ba 100644 --- a/test/fixture/class.config.output.md +++ b/test/fixture/class.config.output.md @@ -27,3 +27,4 @@ Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ## Hello World + diff --git a/test/fixture/class.output.json b/test/fixture/class.output.json index 49b3b81e0..2f517cc09 100644 --- a/test/fixture/class.output.json +++ b/test/fixture/class.output.json @@ -93,11 +93,13 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "MyClass", + "examples": [], + "params": [], "properties": [ { + "title": "property", "name": "howMany", "lineNumber": 3, "description": { @@ -158,6 +160,12 @@ } } ], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "MyClass", "members": { "instance": [ { @@ -256,9 +264,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "getIt", "lineNumber": 2, "description": { @@ -319,6 +330,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -373,12 +385,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "getFoo", "kind": "function", "memberof": "MyClass", @@ -486,7 +502,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -541,11 +561,15 @@ } } }, + "title": "returns", "type": { "type": "UndefinedLiteral" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "getUndefined", "kind": "function", "memberof": "MyClass", diff --git a/test/fixture/class.output.md.json b/test/fixture/class.output.md.json index 962b34920..4292255b6 100644 --- a/test/fixture/class.output.md.json +++ b/test/fixture/class.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "MyClass" } - ], - "data": { - "id": "myclass", - "htmlAttributes": { - "id": "myclass" - }, - "hProperties": { - "id": "myclass" - } - } + ] }, { "type": "paragraph", @@ -155,16 +146,7 @@ "type": "text", "value": "getFoo" } - ], - "data": { - "id": "getfoo", - "htmlAttributes": { - "id": "getfoo" - }, - "hProperties": { - "id": "getfoo" - } - } + ] }, { "type": "paragraph", @@ -361,16 +343,7 @@ "type": "text", "value": "getUndefined" } - ], - "data": { - "id": "getundefined", - "htmlAttributes": { - "id": "getundefined" - }, - "hProperties": { - "id": "getundefined" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/config-malformed.json b/test/fixture/config-malformed.json new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/test/fixture/config-malformed.json @@ -0,0 +1 @@ +* diff --git a/test/fixture/custom_theme/index.js b/test/fixture/custom_theme/index.js index db1e3a385..7f1730a5a 100644 --- a/test/fixture/custom_theme/index.js +++ b/test/fixture/custom_theme/index.js @@ -5,7 +5,7 @@ var File = require('vinyl'); * support. */ module.exports = function(comments, options, callback) { - return callback(null, [new File({ + return Promise.resolve([new File({ base: '/', path: '/index.html', contents: new Buffer('Hello world') diff --git a/test/fixture/document-exported-export-default-object.output.json b/test/fixture/document-exported-export-default-object.output.json index 03b839755..74cd9bffa 100644 --- a/test/fixture/document-exported-export-default-object.output.json +++ b/test/fixture/document-exported-export-default-object.output.json @@ -24,7 +24,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "document-exported-export-default-object.input", "members": { "instance": [], @@ -63,7 +71,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "x", "members": { "instance": [], diff --git a/test/fixture/document-exported-export-default-object.output.md.json b/test/fixture/document-exported-export-default-object.output.md.json index 6ca318d68..c79cb8e64 100644 --- a/test/fixture/document-exported-export-default-object.output.md.json +++ b/test/fixture/document-exported-export-default-object.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "document-exported-export-default-object.input" } - ], - "data": { - "id": "document-exported-export-default-objectinput", - "htmlAttributes": { - "id": "document-exported-export-default-objectinput" - }, - "hProperties": { - "id": "document-exported-export-default-objectinput" - } - } + ] }, { "depth": 2, @@ -32,16 +23,7 @@ "type": "text", "value": "x" } - ], - "data": { - "id": "x", - "htmlAttributes": { - "id": "x" - }, - "hProperties": { - "id": "x" - } - } + ] } ] } \ No newline at end of file diff --git a/test/fixture/document-exported-export-default-value.output.json b/test/fixture/document-exported-export-default-value.output.json index baa003f74..8b6095ade 100644 --- a/test/fixture/document-exported-export-default-value.output.json +++ b/test/fixture/document-exported-export-default-value.output.json @@ -24,7 +24,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "document-exported-export-default-value.input", "members": { "instance": [], diff --git a/test/fixture/document-exported-export-default-value.output.md.json b/test/fixture/document-exported-export-default-value.output.md.json index d4a0c52d9..686f080df 100644 --- a/test/fixture/document-exported-export-default-value.output.md.json +++ b/test/fixture/document-exported-export-default-value.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "document-exported-export-default-value.input" } - ], - "data": { - "id": "document-exported-export-default-valueinput", - "htmlAttributes": { - "id": "document-exported-export-default-valueinput" - }, - "hProperties": { - "id": "document-exported-export-default-valueinput" - } - } + ] } ] } \ No newline at end of file diff --git a/test/fixture/document-exported.output.json b/test/fixture/document-exported.output.json index 29d6660e1..230b19314 100644 --- a/test/fixture/document-exported.output.json +++ b/test/fixture/document-exported.output.json @@ -24,7 +24,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "z", "kind": "class", "members": { @@ -54,7 +62,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "zMethod", "kind": "function", "memberof": "z", @@ -114,9 +130,9 @@ } } }, + "augments": [], "errors": [], - "name": "x", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -124,6 +140,13 @@ "lineNumber": 1 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "x", + "kind": "function", "members": { "instance": [], "static": [], @@ -162,7 +185,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "Class", "kind": "class", "members": { @@ -192,7 +223,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "classMethod", "kind": "function", "memberof": "Class", @@ -240,7 +279,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "classGetter", "kind": "member", "memberof": "Class", @@ -288,9 +335,9 @@ } } }, + "augments": [], "errors": [], - "name": "classSetter", - "kind": "member", + "examples": [], "params": [ { "title": "param", @@ -298,6 +345,13 @@ "lineNumber": 6 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "classSetter", + "kind": "member", "memberof": "Class", "scope": "instance", "members": { @@ -345,7 +399,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "staticMethod", "kind": "function", "memberof": "Class", @@ -393,7 +455,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "staticGetter", "kind": "member", "memberof": "Class", @@ -441,9 +511,9 @@ } } }, + "augments": [], "errors": [], - "name": "staticSetter", - "kind": "member", + "examples": [], "params": [ { "title": "param", @@ -451,6 +521,13 @@ "lineNumber": 9 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "staticSetter", + "kind": "member", "memberof": "Class", "scope": "static", "members": { @@ -507,7 +584,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "T5", "kind": "typedef", "type": { @@ -552,7 +637,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "y2Default", "members": { "instance": [], @@ -642,9 +735,9 @@ } } }, + "augments": [], "errors": [], - "name": "y4", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -656,13 +749,20 @@ } } ], + "properties": [], "returns": [ { + "title": "returns", "type": { "type": "VoidLiteral" } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "y4", + "kind": "function", "members": { "instance": [], "static": [], @@ -701,7 +801,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "object", "members": { "instance": [], @@ -731,7 +839,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "prop", "memberof": "object", "scope": "static", @@ -776,7 +892,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "func", "kind": "function", "memberof": "object", @@ -833,7 +957,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "method", "kind": "function", "members": { @@ -874,7 +1006,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "getter", "kind": "member", "members": { @@ -915,9 +1055,9 @@ } } }, + "augments": [], "errors": [], - "name": "setter", - "kind": "member", + "examples": [], "params": [ { "title": "param", @@ -925,6 +1065,13 @@ "lineNumber": 15 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "setter", + "kind": "member", "members": { "instance": [], "static": [], @@ -963,7 +1110,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "f1", "kind": "function", "members": { @@ -1004,7 +1159,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "f3", "kind": "function", "members": { @@ -1045,7 +1208,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "T", "kind": "typedef", "type": { @@ -1090,7 +1261,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "T2", "kind": "typedef", "type": { @@ -1135,7 +1314,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "T4", "kind": "typedef", "type": { @@ -1180,9 +1367,9 @@ } } }, + "augments": [], "errors": [], - "name": "f4", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -1194,6 +1381,13 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "f4", + "kind": "function", "members": { "instance": [], "static": [], @@ -1232,7 +1426,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "o1", "members": { "instance": [], @@ -1271,7 +1473,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "om1", "kind": "function", "members": { @@ -1363,9 +1573,9 @@ } } }, + "augments": [], "errors": [], - "name": "f5", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -1377,6 +1587,13 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "f5", + "kind": "function", "members": { "instance": [], "static": [], @@ -1415,7 +1632,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "o2", "members": { "instance": [], @@ -1454,7 +1679,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "om2", "kind": "function", "members": { diff --git a/test/fixture/document-exported.output.md.json b/test/fixture/document-exported.output.md.json index 6065877bc..ad889a0a2 100644 --- a/test/fixture/document-exported.output.md.json +++ b/test/fixture/document-exported.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "z" } - ], - "data": { - "id": "z", - "htmlAttributes": { - "id": "z" - }, - "hProperties": { - "id": "z" - } - } + ] }, { "depth": 3, @@ -32,16 +23,7 @@ "type": "text", "value": "zMethod" } - ], - "data": { - "id": "zmethod", - "htmlAttributes": { - "id": "zmethod" - }, - "hProperties": { - "id": "zmethod" - } - } + ] }, { "depth": 2, @@ -51,16 +33,7 @@ "type": "text", "value": "x" } - ], - "data": { - "id": "x", - "htmlAttributes": { - "id": "x" - }, - "hProperties": { - "id": "x" - } - } + ] }, { "type": "strong", @@ -107,16 +80,7 @@ "type": "text", "value": "Class" } - ], - "data": { - "id": "class", - "htmlAttributes": { - "id": "class" - }, - "hProperties": { - "id": "class" - } - } + ] }, { "depth": 3, @@ -126,16 +90,7 @@ "type": "text", "value": "classMethod" } - ], - "data": { - "id": "classmethod", - "htmlAttributes": { - "id": "classmethod" - }, - "hProperties": { - "id": "classmethod" - } - } + ] }, { "depth": 3, @@ -145,16 +100,7 @@ "type": "text", "value": "classGetter" } - ], - "data": { - "id": "classgetter", - "htmlAttributes": { - "id": "classgetter" - }, - "hProperties": { - "id": "classgetter" - } - } + ] }, { "depth": 3, @@ -164,16 +110,7 @@ "type": "text", "value": "classSetter" } - ], - "data": { - "id": "classsetter", - "htmlAttributes": { - "id": "classsetter" - }, - "hProperties": { - "id": "classsetter" - } - } + ] }, { "type": "strong", @@ -220,16 +157,7 @@ "type": "text", "value": "staticMethod" } - ], - "data": { - "id": "staticmethod", - "htmlAttributes": { - "id": "staticmethod" - }, - "hProperties": { - "id": "staticmethod" - } - } + ] }, { "depth": 3, @@ -239,16 +167,7 @@ "type": "text", "value": "staticGetter" } - ], - "data": { - "id": "staticgetter", - "htmlAttributes": { - "id": "staticgetter" - }, - "hProperties": { - "id": "staticgetter" - } - } + ] }, { "depth": 3, @@ -258,16 +177,7 @@ "type": "text", "value": "staticSetter" } - ], - "data": { - "id": "staticsetter", - "htmlAttributes": { - "id": "staticsetter" - }, - "hProperties": { - "id": "staticsetter" - } - } + ] }, { "type": "strong", @@ -314,16 +224,7 @@ "type": "text", "value": "T5" } - ], - "data": { - "id": "t5", - "htmlAttributes": { - "id": "t5" - }, - "hProperties": { - "id": "t5" - } - } + ] }, { "type": "paragraph", @@ -353,16 +254,7 @@ "type": "text", "value": "y2Default" } - ], - "data": { - "id": "y2default", - "htmlAttributes": { - "id": "y2default" - }, - "hProperties": { - "id": "y2default" - } - } + ] }, { "depth": 2, @@ -372,16 +264,7 @@ "type": "text", "value": "y4" } - ], - "data": { - "id": "y4", - "htmlAttributes": { - "id": "y4" - }, - "hProperties": { - "id": "y4" - } - } + ] }, { "type": "paragraph", @@ -501,16 +384,7 @@ "type": "text", "value": "object" } - ], - "data": { - "id": "object", - "htmlAttributes": { - "id": "object" - }, - "hProperties": { - "id": "object" - } - } + ] }, { "depth": 3, @@ -520,16 +394,7 @@ "type": "text", "value": "prop" } - ], - "data": { - "id": "prop", - "htmlAttributes": { - "id": "prop" - }, - "hProperties": { - "id": "prop" - } - } + ] }, { "depth": 3, @@ -539,16 +404,7 @@ "type": "text", "value": "func" } - ], - "data": { - "id": "func", - "htmlAttributes": { - "id": "func" - }, - "hProperties": { - "id": "func" - } - } + ] }, { "depth": 2, @@ -558,16 +414,7 @@ "type": "text", "value": "method" } - ], - "data": { - "id": "method", - "htmlAttributes": { - "id": "method" - }, - "hProperties": { - "id": "method" - } - } + ] }, { "depth": 2, @@ -577,16 +424,7 @@ "type": "text", "value": "getter" } - ], - "data": { - "id": "getter", - "htmlAttributes": { - "id": "getter" - }, - "hProperties": { - "id": "getter" - } - } + ] }, { "depth": 2, @@ -596,16 +434,7 @@ "type": "text", "value": "setter" } - ], - "data": { - "id": "setter", - "htmlAttributes": { - "id": "setter" - }, - "hProperties": { - "id": "setter" - } - } + ] }, { "type": "strong", @@ -652,16 +481,7 @@ "type": "text", "value": "f1" } - ], - "data": { - "id": "f1", - "htmlAttributes": { - "id": "f1" - }, - "hProperties": { - "id": "f1" - } - } + ] }, { "depth": 2, @@ -671,16 +491,7 @@ "type": "text", "value": "f3" } - ], - "data": { - "id": "f3", - "htmlAttributes": { - "id": "f3" - }, - "hProperties": { - "id": "f3" - } - } + ] }, { "depth": 2, @@ -690,16 +501,7 @@ "type": "text", "value": "T" } - ], - "data": { - "id": "t", - "htmlAttributes": { - "id": "t" - }, - "hProperties": { - "id": "t" - } - } + ] }, { "type": "paragraph", @@ -729,16 +531,7 @@ "type": "text", "value": "T2" } - ], - "data": { - "id": "t2", - "htmlAttributes": { - "id": "t2" - }, - "hProperties": { - "id": "t2" - } - } + ] }, { "type": "paragraph", @@ -768,16 +561,7 @@ "type": "text", "value": "T4" } - ], - "data": { - "id": "t4", - "htmlAttributes": { - "id": "t4" - }, - "hProperties": { - "id": "t4" - } - } + ] }, { "type": "paragraph", @@ -807,16 +591,7 @@ "type": "text", "value": "f4" } - ], - "data": { - "id": "f4", - "htmlAttributes": { - "id": "f4" - }, - "hProperties": { - "id": "f4" - } - } + ] }, { "type": "strong", @@ -872,16 +647,7 @@ "type": "text", "value": "o1" } - ], - "data": { - "id": "o1", - "htmlAttributes": { - "id": "o1" - }, - "hProperties": { - "id": "o1" - } - } + ] }, { "depth": 2, @@ -891,16 +657,7 @@ "type": "text", "value": "om1" } - ], - "data": { - "id": "om1", - "htmlAttributes": { - "id": "om1" - }, - "hProperties": { - "id": "om1" - } - } + ] }, { "depth": 2, @@ -910,16 +667,7 @@ "type": "text", "value": "f5" } - ], - "data": { - "id": "f5", - "htmlAttributes": { - "id": "f5" - }, - "hProperties": { - "id": "f5" - } - } + ] }, { "type": "paragraph", @@ -1010,16 +758,7 @@ "type": "text", "value": "o2" } - ], - "data": { - "id": "o2", - "htmlAttributes": { - "id": "o2" - }, - "hProperties": { - "id": "o2" - } - } + ] }, { "depth": 2, @@ -1029,16 +768,7 @@ "type": "text", "value": "om2" } - ], - "data": { - "id": "om2", - "htmlAttributes": { - "id": "om2" - }, - "hProperties": { - "id": "om2" - } - } + ] } ] } \ No newline at end of file diff --git a/test/fixture/es6-class.output.json b/test/fixture/es6-class.output.json index 20a562615..cb01e1dbb 100644 --- a/test/fixture/es6-class.output.json +++ b/test/fixture/es6-class.output.json @@ -75,14 +75,21 @@ } } }, - "errors": [], - "name": "Foo", "augments": [ { "title": "augments", "name": "React.Component" } ], + "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "Foo", "kind": "class", "members": { "instance": [], @@ -173,7 +180,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "Bar", "kind": "class", "members": { @@ -265,9 +280,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "str", "lineNumber": 2, "type": { @@ -276,6 +294,11 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "constructor", "kind": "function", "memberof": "Bar", @@ -384,7 +407,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "bar", "memberof": "Bar", "scope": "instance", diff --git a/test/fixture/es6-class.output.md.json b/test/fixture/es6-class.output.md.json index 3ea160e54..be9e2c03f 100644 --- a/test/fixture/es6-class.output.md.json +++ b/test/fixture/es6-class.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "Foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", @@ -85,16 +76,7 @@ "type": "text", "value": "Bar" } - ], - "data": { - "id": "bar", - "htmlAttributes": { - "id": "bar" - }, - "hProperties": { - "id": "bar" - } - } + ] }, { "type": "paragraph", @@ -139,16 +121,7 @@ "type": "text", "value": "constructor" } - ], - "data": { - "id": "constructor", - "htmlAttributes": { - "id": "constructor" - }, - "hProperties": { - "id": "constructor" - } - } + ] }, { "type": "paragraph", @@ -246,16 +219,7 @@ "type": "text", "value": "bar" } - ], - "data": { - "id": "bar-1", - "htmlAttributes": { - "id": "bar-1" - }, - "hProperties": { - "id": "bar-1" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/es6-default2.output.json b/test/fixture/es6-default2.output.json index 43a0cc58f..f75e389b3 100644 --- a/test/fixture/es6-default2.output.json +++ b/test/fixture/es6-default2.output.json @@ -30,10 +30,9 @@ } } }, + "augments": [], "errors": [], - "access": "public", - "name": "es6-default2.input", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -41,6 +40,14 @@ "lineNumber": 4 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "access": "public", + "name": "es6-default2.input", + "kind": "function", "members": { "instance": [], "static": [], diff --git a/test/fixture/es6-default2.output.md.json b/test/fixture/es6-default2.output.md.json index a4facdbc8..3e6561ebd 100644 --- a/test/fixture/es6-default2.output.md.json +++ b/test/fixture/es6-default2.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "es6-default2.input" } - ], - "data": { - "id": "es6-default2input", - "htmlAttributes": { - "id": "es6-default2input" - }, - "hProperties": { - "id": "es6-default2input" - } - } + ] }, { "type": "strong", diff --git a/test/fixture/es6-import.output.json b/test/fixture/es6-import.output.json index 4c3b25624..c1126f032 100644 --- a/test/fixture/es6-import.output.json +++ b/test/fixture/es6-import.output.json @@ -85,7 +85,17 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [ + { + "title": "param", + "name": "a", + "lineNumber": 9 + } + ], + "properties": [], "returns": [ { "description": { @@ -140,21 +150,18 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "multiplyTwice", "kind": "function", - "params": [ - { - "title": "param", - "name": "a", - "lineNumber": 9 - } - ], "members": { "instance": [], "static": [], @@ -244,7 +251,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "es6-ext", "members": { "instance": [], @@ -344,7 +359,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -399,12 +418,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple.input", "kind": "function", "members": { diff --git a/test/fixture/es6-import.output.md.json b/test/fixture/es6-import.output.md.json index 9ae20c52b..a07e50523 100644 --- a/test/fixture/es6-import.output.md.json +++ b/test/fixture/es6-import.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "multiplyTwice" } - ], - "data": { - "id": "multiplytwice", - "htmlAttributes": { - "id": "multiplytwice" - }, - "hProperties": { - "id": "multiplytwice" - } - } + ] }, { "type": "paragraph", @@ -168,16 +159,7 @@ "type": "text", "value": "es6-ext" } - ], - "data": { - "id": "es6-ext", - "htmlAttributes": { - "id": "es6-ext" - }, - "hProperties": { - "id": "es6-ext" - } - } + ] }, { "type": "paragraph", @@ -222,16 +204,7 @@ "type": "text", "value": "simple.input" } - ], - "data": { - "id": "simpleinput", - "htmlAttributes": { - "id": "simpleinput" - }, - "hProperties": { - "id": "simpleinput" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/es6.output-toc.md b/test/fixture/es6.output-toc.md index 6a3d7ffa7..95a3c2c68 100644 --- a/test/fixture/es6.output-toc.md +++ b/test/fixture/es6.output-toc.md @@ -7,7 +7,7 @@ have any parameter descriptions. **Parameters** -- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`) +- `$0` **any** (optional, default `{}`) - `$0.phoneNumbers` (optional, default `[]`) - `$0.emailAddresses` (optional, default `[]`) - `$0.params` **...any** @@ -18,7 +18,7 @@ Similar, but with an array **Parameters** -- `$0` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** +- `$0` **any** - `$0.a` - `$0.b` - `$0.c` diff --git a/test/fixture/es6.output.json b/test/fixture/es6.output.json index 62862566d..b4d8eafae 100644 --- a/test/fixture/es6.output.json +++ b/test/fixture/es6.output.json @@ -79,16 +79,15 @@ } } }, + "augments": [], "errors": [], - "name": "destructure", - "kind": "function", + "examples": [], "params": [ { "title": "param", "name": "$0", "type": { - "type": "NameExpression", - "name": "Object" + "type": "AllLiteral" }, "default": "{}", "properties": [ @@ -113,6 +112,13 @@ ] } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "destructure", + "kind": "function", "members": { "instance": [], "static": [], @@ -208,21 +214,19 @@ } } }, + "augments": [], "errors": [], "examples": [ { "description": "destructure([1, 2, 3])" } ], - "name": "destructure", - "kind": "function", "params": [ { "title": "param", "name": "$0", "type": { - "type": "NameExpression", - "name": "Array" + "type": "AllLiteral" }, "properties": [ { @@ -243,6 +247,13 @@ ] } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "destructure", + "kind": "function", "members": { "instance": [], "static": [], @@ -361,9 +372,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "a", "lineNumber": 2, "description": { @@ -438,6 +452,7 @@ "lineNumber": 21 } ], + "properties": [], "returns": [ { "description": { @@ -492,12 +507,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "multiply", "kind": "function", "members": { @@ -589,7 +608,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "Sink", "kind": "class", "members": { @@ -670,7 +697,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "staticProp", "kind": "member", "memberof": "Sink", @@ -769,7 +804,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "empty", "kind": "function", "memberof": "Sink", @@ -872,7 +915,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "aGetter", "kind": "member", "memberof": "Sink", @@ -941,9 +992,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "height", "lineNumber": 1, "description": { @@ -1004,6 +1058,7 @@ } }, { + "title": "param", "name": "width", "lineNumber": 2, "description": { @@ -1064,6 +1119,11 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "constructor", "kind": "function", "memberof": "Sink", @@ -1164,7 +1224,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "hello", "kind": "function", "memberof": "Sink", @@ -1284,7 +1352,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -1339,12 +1411,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Basket" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "makeABasket", "kind": "function", "members": { @@ -1534,7 +1610,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -1589,12 +1669,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Sink" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "makeASink", "kind": "function", "members": { @@ -1686,9 +1770,9 @@ } } }, + "augments": [], "errors": [], - "name": "functionWithRest", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -1699,6 +1783,13 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "functionWithRest", + "kind": "function", "members": { "instance": [], "static": [], @@ -1788,9 +1879,9 @@ } } }, + "augments": [], "errors": [], - "name": "functionWithRestAndType", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -1805,6 +1896,13 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "functionWithRestAndType", + "kind": "function", "members": { "instance": [], "static": [], @@ -1894,7 +1992,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { @@ -1996,7 +2102,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -2051,12 +2161,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "es6.input", "kind": "function", "members": { @@ -2148,9 +2262,9 @@ } } }, + "augments": [], "errors": [], - "name": "veryImportantTransform", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -2158,6 +2272,13 @@ "default": "'bar'" } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "veryImportantTransform", + "kind": "function", "members": { "instance": [], "static": [], @@ -2253,7 +2374,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "access": "protected", "name": "iAmProtected", "kind": "function", @@ -2352,7 +2481,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "access": "public", "name": "iAmPublic", "kind": "function", @@ -2445,7 +2582,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "execute", "members": { "instance": [], @@ -2535,9 +2680,9 @@ } } }, + "augments": [], "errors": [], - "name": "isArrayEqualWith", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -2609,14 +2754,21 @@ } } ], + "properties": [], "returns": [ { + "title": "returns", "type": { "type": "NameExpression", "name": "boolean" } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "isArrayEqualWith", + "kind": "function", "members": { "instance": [], "static": [], diff --git a/test/fixture/es6.output.md b/test/fixture/es6.output.md index 3aeec16ce..985716788 100644 --- a/test/fixture/es6.output.md +++ b/test/fixture/es6.output.md @@ -30,7 +30,7 @@ have any parameter descriptions. **Parameters** -- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`) +- `$0` **any** (optional, default `{}`) - `$0.phoneNumbers` (optional, default `[]`) - `$0.emailAddresses` (optional, default `[]`) - `$0.params` **...any** @@ -41,7 +41,7 @@ Similar, but with an array **Parameters** -- `$0` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** +- `$0` **any** - `$0.a` - `$0.b` - `$0.c` diff --git a/test/fixture/es6.output.md.json b/test/fixture/es6.output.md.json index e2e2b8155..7826d97d5 100644 --- a/test/fixture/es6.output.md.json +++ b/test/fixture/es6.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "destructure" } - ], - "data": { - "id": "destructure", - "htmlAttributes": { - "id": "destructure" - }, - "hProperties": { - "id": "destructure" - } - } + ] }, { "type": "paragraph", @@ -94,15 +85,8 @@ "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] + "type": "text", + "value": "any" } ] }, @@ -260,16 +244,7 @@ "type": "text", "value": "destructure" } - ], - "data": { - "id": "destructure-1", - "htmlAttributes": { - "id": "destructure-1" - }, - "hProperties": { - "id": "destructure-1" - } - } + ] }, { "type": "paragraph", @@ -337,15 +312,8 @@ "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] + "type": "text", + "value": "any" } ] }, @@ -453,16 +421,7 @@ "type": "text", "value": "multiply" } - ], - "data": { - "id": "multiply", - "htmlAttributes": { - "id": "multiply" - }, - "hProperties": { - "id": "multiply" - } - } + ] }, { "type": "paragraph", @@ -700,16 +659,7 @@ "type": "text", "value": "Sink" } - ], - "data": { - "id": "sink", - "htmlAttributes": { - "id": "sink" - }, - "hProperties": { - "id": "sink" - } - } + ] }, { "type": "paragraph", @@ -754,16 +704,7 @@ "type": "text", "value": "staticProp" } - ], - "data": { - "id": "staticprop", - "htmlAttributes": { - "id": "staticprop" - }, - "hProperties": { - "id": "staticprop" - } - } + ] }, { "type": "paragraph", @@ -808,16 +749,7 @@ "type": "text", "value": "empty" } - ], - "data": { - "id": "empty", - "htmlAttributes": { - "id": "empty" - }, - "hProperties": { - "id": "empty" - } - } + ] }, { "type": "paragraph", @@ -862,16 +794,7 @@ "type": "text", "value": "aGetter" } - ], - "data": { - "id": "agetter", - "htmlAttributes": { - "id": "agetter" - }, - "hProperties": { - "id": "agetter" - } - } + ] }, { "type": "paragraph", @@ -920,16 +843,7 @@ "type": "text", "value": "constructor" } - ], - "data": { - "id": "constructor", - "htmlAttributes": { - "id": "constructor" - }, - "hProperties": { - "id": "constructor" - } - } + ] }, { "type": "strong", @@ -1100,16 +1014,7 @@ "type": "text", "value": "hello" } - ], - "data": { - "id": "hello", - "htmlAttributes": { - "id": "hello" - }, - "hProperties": { - "id": "hello" - } - } + ] }, { "type": "paragraph", @@ -1154,16 +1059,7 @@ "type": "text", "value": "makeABasket" } - ], - "data": { - "id": "makeabasket", - "htmlAttributes": { - "id": "makeabasket" - }, - "hProperties": { - "id": "makeabasket" - } - } + ] }, { "type": "paragraph", @@ -1265,16 +1161,7 @@ "type": "text", "value": "makeASink" } - ], - "data": { - "id": "makeasink", - "htmlAttributes": { - "id": "makeasink" - }, - "hProperties": { - "id": "makeasink" - } - } + ] }, { "type": "paragraph", @@ -1471,16 +1358,7 @@ "type": "text", "value": "functionWithRest" } - ], - "data": { - "id": "functionwithrest", - "htmlAttributes": { - "id": "functionwithrest" - }, - "hProperties": { - "id": "functionwithrest" - } - } + ] }, { "type": "paragraph", @@ -1575,16 +1453,7 @@ "type": "text", "value": "functionWithRestAndType" } - ], - "data": { - "id": "functionwithrestandtype", - "htmlAttributes": { - "id": "functionwithrestandtype" - }, - "hProperties": { - "id": "functionwithrestandtype" - } - } + ] }, { "type": "paragraph", @@ -1686,16 +1555,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", @@ -1740,16 +1600,7 @@ "type": "text", "value": "es6.input" } - ], - "data": { - "id": "es6input", - "htmlAttributes": { - "id": "es6input" - }, - "hProperties": { - "id": "es6input" - } - } + ] }, { "type": "paragraph", @@ -1858,16 +1709,7 @@ "type": "text", "value": "veryImportantTransform" } - ], - "data": { - "id": "veryimportanttransform", - "htmlAttributes": { - "id": "veryimportanttransform" - }, - "hProperties": { - "id": "veryimportanttransform" - } - } + ] }, { "type": "paragraph", @@ -1966,16 +1808,7 @@ "type": "text", "value": "iAmProtected" } - ], - "data": { - "id": "iamprotected", - "htmlAttributes": { - "id": "iamprotected" - }, - "hProperties": { - "id": "iamprotected" - } - } + ] }, { "type": "paragraph", @@ -2020,16 +1853,7 @@ "type": "text", "value": "iAmPublic" } - ], - "data": { - "id": "iampublic", - "htmlAttributes": { - "id": "iampublic" - }, - "hProperties": { - "id": "iampublic" - } - } + ] }, { "type": "paragraph", @@ -2074,16 +1898,7 @@ "type": "text", "value": "execute" } - ], - "data": { - "id": "execute", - "htmlAttributes": { - "id": "execute" - }, - "hProperties": { - "id": "execute" - } - } + ] }, { "type": "paragraph", @@ -2128,16 +1943,7 @@ "type": "text", "value": "isArrayEqualWith" } - ], - "data": { - "id": "isarrayequalwith", - "htmlAttributes": { - "id": "isarrayequalwith" - }, - "hProperties": { - "id": "isarrayequalwith" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/event.output.json b/test/fixture/event.output.json index ae349584c..e34cd3413 100644 --- a/test/fixture/event.output.json +++ b/test/fixture/event.output.json @@ -110,11 +110,13 @@ } } }, + "augments": [], "errors": [], - "kind": "event", - "name": "Map#mousemove", + "examples": [], + "params": [], "properties": [ { + "title": "property", "name": "point", "lineNumber": 5, "description": { @@ -175,6 +177,7 @@ } }, { + "title": "property", "name": "originalEvent", "lineNumber": 6, "description": { @@ -235,6 +238,12 @@ } } ], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "event", + "name": "Map#mousemove", "members": { "instance": [], "static": [], diff --git a/test/fixture/event.output.md.json b/test/fixture/event.output.md.json index 5e43d48dc..4d7dc7416 100644 --- a/test/fixture/event.output.md.json +++ b/test/fixture/event.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "Map#mousemove" } - ], - "data": { - "id": "mapmousemove", - "htmlAttributes": { - "id": "mapmousemove" - }, - "hProperties": { - "id": "mapmousemove" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/example-caption.output.json b/test/fixture/example-caption.output.json index 7fb36daf6..fba5a26bd 100644 --- a/test/fixture/example-caption.output.json +++ b/test/fixture/example-caption.output.json @@ -91,10 +91,12 @@ } } }, + "augments": [], "errors": [], - "returns": [ + "examples": [ { - "description": { + "description": "foo(1);", + "caption": { "type": "root", "children": [ { @@ -102,7 +104,7 @@ "children": [ { "type": "text", - "value": "numberone", + "value": "demonstrates how to run foo", "position": { "start": { "line": 1, @@ -111,8 +113,8 @@ }, "end": { "line": 1, - "column": 10, - "offset": 9 + "column": 28, + "offset": 27 }, "indent": [] } @@ -126,8 +128,8 @@ }, "end": { "line": 1, - "column": 10, - "offset": 9 + "column": 28, + "offset": 27 }, "indent": [] } @@ -141,21 +143,18 @@ }, "end": { "line": 1, - "column": 10, - "offset": 9 + "column": 28, + "offset": 27 } } - }, - "type": { - "type": "NameExpression", - "name": "Number" } } ], - "examples": [ + "params": [], + "properties": [], + "returns": [ { - "description": "foo(1);", - "caption": { + "description": { "type": "root", "children": [ { @@ -163,7 +162,7 @@ "children": [ { "type": "text", - "value": "demonstrates how to run foo", + "value": "numberone", "position": { "start": { "line": 1, @@ -172,8 +171,8 @@ }, "end": { "line": 1, - "column": 28, - "offset": 27 + "column": 10, + "offset": 9 }, "indent": [] } @@ -187,8 +186,8 @@ }, "end": { "line": 1, - "column": 28, - "offset": 27 + "column": 10, + "offset": 9 }, "indent": [] } @@ -202,13 +201,21 @@ }, "end": { "line": 1, - "column": 28, - "offset": 27 + "column": 10, + "offset": 9 } } + }, + "title": "returns", + "type": { + "type": "NameExpression", + "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { diff --git a/test/fixture/example-caption.output.md.json b/test/fixture/example-caption.output.md.json index 50a27aad1..fa77489fc 100644 --- a/test/fixture/example-caption.output.md.json +++ b/test/fixture/example-caption.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/external.output.json b/test/fixture/external.output.json index c8e02a0b7..b7f770108 100644 --- a/test/fixture/external.output.json +++ b/test/fixture/external.output.json @@ -109,7 +109,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { diff --git a/test/fixture/external.output.md.json b/test/fixture/external.output.md.json index e85a11a76..fcd4812e8 100644 --- a/test/fixture/external.output.md.json +++ b/test/fixture/external.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/factory.output.json b/test/fixture/factory.output.json index 7e7078904..1b16eea16 100644 --- a/test/fixture/factory.output.json +++ b/test/fixture/factory.output.json @@ -85,7 +85,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -140,12 +144,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "area" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "area", "kind": "function", "members": { @@ -194,9 +202,9 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "area", + "examples": [], "params": [ { "title": "param", @@ -204,6 +212,13 @@ "lineNumber": 10 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "area", "members": { "instance": [], "static": [], @@ -300,14 +315,14 @@ } } }, + "augments": [], "errors": [ { "message": "@memberof reference to chart not found", "commentLineNumber": 0 } ], - "kind": "function", - "name": "data", + "examples": [], "params": [ { "title": "param", @@ -315,6 +330,13 @@ "lineNumber": 17 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "function", + "name": "data", "memberof": "chart", "scope": "static", "members": { diff --git a/test/fixture/factory.output.md.json b/test/fixture/factory.output.md.json index 293fdb447..a4ac3c232 100644 --- a/test/fixture/factory.output.md.json +++ b/test/fixture/factory.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "area" } - ], - "data": { - "id": "area", - "htmlAttributes": { - "id": "area" - }, - "hProperties": { - "id": "area" - } - } + ] }, { "type": "paragraph", @@ -131,16 +122,7 @@ "type": "text", "value": "area" } - ], - "data": { - "id": "area-1", - "htmlAttributes": { - "id": "area-1" - }, - "hProperties": { - "id": "area-1" - } - } + ] }, { "type": "strong", @@ -187,16 +169,7 @@ "type": "text", "value": "data" } - ], - "data": { - "id": "data", - "htmlAttributes": { - "id": "data" - }, - "hProperties": { - "id": "data" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/html/nested.config-output.html b/test/fixture/html/nested.config-output.html index 626338271..ac63e5cb2 100644 --- a/test/fixture/html/nested.config-output.html +++ b/test/fixture/html/nested.config-output.html @@ -2,7 +2,7 @@ - | Documentation + documentation 4.0.0-beta.18 | Documentation @@ -13,8 +13,8 @@
-

-
+

documentation

+
4.0.0-beta.18
+
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ +
Static Members
@@ -324,6 +339,13 @@

isClass(other: Object, also: any): boolean
+

+ Extends + + + +

+ @@ -355,6 +377,11 @@

+
Properties
+
+ +
+ @@ -367,8 +394,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -399,6 +434,13 @@

isWeird(other: Weird): boolean
+

+ Extends + + + +

+ @@ -422,6 +464,11 @@

+
Properties
+
+ +
+ @@ -434,8 +481,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -465,6 +520,13 @@

isBuffer(buf: (Buffer | string), size: number?): boolean
+

+ Extends + + + +

+ @@ -498,6 +560,11 @@

+
Properties
+
+ +
+ @@ -510,8 +577,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -541,6 +616,13 @@

isArrayOfBuffers(buffers: Array<Buffer>): number
+

+ Extends + + + +

+ @@ -565,6 +647,11 @@

+
Properties
+
+ +
+ @@ -577,6 +664,11 @@

+
Throws
+
    + +
+
Example
@@ -615,6 +707,13 @@

MAGIC_NUMBER
+

+ Extends + + + +

+ @@ -623,14 +722,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -668,6 +787,13 @@

getFoo(): Number
+

+ Extends + + + +

+ @@ -676,8 +802,18 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ @@ -690,6 +826,11 @@

+
Throws
+
    + +
+
Example
@@ -728,6 +869,13 @@

withOptions(options: Object, otherOptions: number?)
+

+ Extends + + + +

+ @@ -787,12 +935,27 @@

+
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -830,6 +993,13 @@

event
+

+ Extends + + + +

+ @@ -838,14 +1008,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -881,8 +1071,15 @@

a typedef with nested properties

-
CustomError
+
CustomError(other: any, also: any)
+ +

+ Extends + + + +

@@ -892,6 +1089,27 @@

+
Parameters
+
+ +
+
+ other (any) + +
+ +
+ +
+
+ also (any) + +
+ +
+ +
+
Properties
@@ -922,10 +1140,20 @@

+ + +
Throws
+
    + +
+ +
Example
+ + @@ -958,6 +1186,13 @@

bar(): Klass
+

+ Extends + + + +

+ @@ -966,8 +1201,18 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ @@ -980,8 +1225,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -1012,6 +1265,13 @@

bar(toys: ...Number): undefined
+

+ Extends + + + +

+ @@ -1035,6 +1295,11 @@

+
Properties
+
+ +
+ @@ -1047,8 +1312,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -1081,6 +1354,13 @@

bar(): undefined
+

+ Extends + + + +

+ @@ -1089,8 +1369,18 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ @@ -1103,8 +1393,16 @@

+
Throws
+
    + +
+ +
Example
+ + @@ -1135,6 +1433,13 @@

new Foo()
+

+ Extends + + + +

+ @@ -1143,14 +1448,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -1176,6 +1501,13 @@

bar
+

+ Extends + + + +

+ @@ -1184,14 +1516,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -1232,6 +1584,13 @@

customStreams
+

+ Extends + + + +

+ @@ -1240,14 +1599,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ +
Static Members
@@ -1271,6 +1650,13 @@

new passthrough()
+

+ Extends + + + +

+ @@ -1279,14 +1665,34 @@

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + diff --git a/test/fixture/html/nested.output.files b/test/fixture/html/nested.output.files index 4b61d7833..0e7da8b2b 100644 --- a/test/fixture/html/nested.output.files +++ b/test/fixture/html/nested.output.files @@ -2,7 +2,7 @@ - | Documentation + documentation 4.0.0-beta.18 | Documentation @@ -13,8 +13,8 @@
-

-
+

documentation

+
4.0.0-beta.18
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ +
Static Members
@@ -286,6 +301,13 @@ This is a [link to something that does not exist]DoesNotisClass(other: Object, also: any): boolean
+

+ Extends + + + +

+ @@ -317,6 +339,11 @@ This is a [link to something that does not exist]DoesNotProperties
+
+ +
+ @@ -329,8 +356,16 @@ This is a [link to something that does not exist]DoesNotThrows

+
    + +
+ +
Example
+ + @@ -361,6 +396,13 @@ the referenced class type

isWeird(other: Weird): boolean
+

+ Extends + + + +

+ @@ -384,6 +426,11 @@ the referenced class type

+
Properties
+
+ +
+ @@ -396,8 +443,16 @@ the referenced class type

+
Throws
+
    + +
+ +
Example
+ + @@ -427,6 +482,13 @@ the referenced class type

isBuffer(buf: (Buffer | string), size: number?): boolean
+

+ Extends + + + +

+ @@ -460,6 +522,11 @@ the referenced class type

+
Properties
+
+ +
+ @@ -472,8 +539,16 @@ the referenced class type

+
Throws
+
    + +
+ +
Example
+ + @@ -503,6 +578,13 @@ the referenced class type

isArrayOfBuffers(buffers: Array<Buffer>): number
+

+ Extends + + + +

+ @@ -527,6 +609,11 @@ the referenced class type

+
Properties
+
+ +
+ @@ -539,6 +626,11 @@ the referenced class type

+
Throws
+
    + +
+
Example
@@ -577,6 +669,13 @@ k.isArrayOfBuffers();
MAGIC_NUMBER
+

+ Extends + + + +

+ @@ -585,14 +684,34 @@ k.isArrayOfBuffers(); +
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -630,6 +749,13 @@ k.isArrayOfBuffers();
getFoo(): Number
+

+ Extends + + + +

+ @@ -638,8 +764,18 @@ k.isArrayOfBuffers(); +
Parameters
+
+ +
+ +
Properties
+
+ +
+ @@ -652,6 +788,11 @@ k.isArrayOfBuffers(); +
Throws
+
    + +
+
Example
@@ -690,6 +831,13 @@ k.isArrayOfBuffers();
withOptions(options: Object, otherOptions: number?)
+

+ Extends + + + +

+ @@ -749,12 +897,27 @@ k.isArrayOfBuffers(); +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -792,6 +955,13 @@ k.isArrayOfBuffers();
event
+

+ Extends + + + +

+ @@ -800,14 +970,34 @@ k.isArrayOfBuffers(); +
Parameters
+
+ +
+ +
Properties
+
+ +
+ + + +
Throws
+
    + +
+ +
Example
+ + @@ -843,8 +1033,15 @@ k.isArrayOfBuffers();

a typedef with nested properties

-
CustomError
+
CustomError(other: any, also: any)
+ +

+ Extends + + + +

@@ -854,6 +1051,27 @@ k.isArrayOfBuffers(); +
Parameters
+
+ +
+
+ other (any) + +
+ +
+ +
+
+ also (any) + +
+ +
+ +
+
Properties
@@ -884,10 +1102,20 @@ k.isArrayOfBuffers(); + + +
Throws
+
    + +
+ +
Example
+ + @@ -920,6 +1148,13 @@ like a klass

bar(): Klass
+

+ Extends + + + +

+ @@ -928,8 +1163,18 @@ like a klass

+
Parameters
+
+ +
+ +
Properties
+
+ +
+ @@ -942,8 +1187,16 @@ like a klass

+
Throws
+
    + +
+ +
Example
+ + @@ -974,6 +1227,13 @@ like a klass

bar(toys: ...Number): undefined
+

+ Extends + + + +

+ @@ -997,6 +1257,11 @@ like a klass

+
Properties
+
+ +
+ @@ -1009,8 +1274,16 @@ like a klass

+
Throws
+
    + +
+ +
Example
+ + @@ -1043,6 +1316,13 @@ like a klass. This needs a undefined
+

+ Extends + + + +

+ @@ -1051,8 +1331,18 @@ like a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a + +### Table of Contents + +- [meta.input](#metainput) + +## meta.input + +This function returns the number one. + +Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone + +**Meta** + +- **version**: 1.0.0 +- **since**: 2.0.0 +- **copyright**: Tom MacWright + +- **license**: BSD diff --git a/test/fixture/sync/multiexample.output.md.json b/test/fixture/meta.output.md.json similarity index 62% rename from test/fixture/sync/multiexample.output.md.json rename to test/fixture/meta.output.md.json index 642b881ec..451588533 100644 --- a/test/fixture/sync/multiexample.output.md.json +++ b/test/fixture/meta.output.md.json @@ -11,34 +11,7 @@ "children": [ { "type": "text", - "value": "multiexample.input" - } - ], - "data": { - "id": "multiexampleinput", - "htmlAttributes": { - "id": "multiexampleinput" - }, - "hProperties": { - "id": "multiexampleinput" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Extends " - }, - { - "type": "text", - "value": "Foo, Bar" - } - ] + "value": "meta.input" } ] }, @@ -78,23 +51,77 @@ } }, { - "type": "strong", + "type": "paragraph", "children": [ { "type": "text", - "value": "Examples" + "value": "Returns " + }, + { + "type": "strong", + "children": [ + { + "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", + "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", + "type": "link", + "children": [ + { + "type": "text", + "value": "number" + } + ] + } + ] + }, + { + "type": "text", + "value": " " + }, + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "numberone", + "position": { + "start": { + "line": 1, + "column": 1, + "offset": 0 + }, + "end": { + "line": 1, + "column": 10, + "offset": 9 + }, + "indent": [] + } + } + ], + "position": { + "start": { + "line": 1, + "column": 1, + "offset": 0 + }, + "end": { + "line": 1, + "column": 10, + "offset": 9 + }, + "indent": [] + } } ] }, { - "lang": "javascript", - "type": "code", - "value": "foo(1);" - }, - { - "lang": "javascript", - "type": "code", - "value": "foo(2);" + "type": "strong", + "children": [ + { + "type": "text", + "value": "Meta" + } + ] }, { "ordered": false, @@ -106,64 +133,49 @@ { "type": "paragraph", "children": [ - { - "type": "text", - "value": "Throws " - }, { "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", - "type": "link", - "children": [ - { - "type": "text", - "value": "Error" - } - ] + "type": "text", + "value": "version" } ] }, { "type": "text", - "value": " " + "value": ": " }, { - "type": "paragraph", + "type": "text", + "value": "1.0.0" + } + ] + } + ] + }, + { + "type": "listItem", + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "strong", "children": [ { "type": "text", - "value": "if you give it something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } + "value": "since" } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } + ] + }, + { + "type": "text", + "value": ": " + }, + { + "type": "text", + "value": "2.0.0" } ] } @@ -175,36 +187,43 @@ { "type": "paragraph", "children": [ - { - "type": "text", - "value": "Throws " - }, { "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError", - "type": "link", - "children": [ - { - "type": "text", - "value": "TypeError" - } - ] + "type": "text", + "value": "copyright" } ] }, { "type": "text", - "value": " " + "value": ": " }, { - "type": "paragraph", + "type": "root", "children": [ { - "type": "text", - "value": "if you give it something else", + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "Tom MacWright", + "position": { + "start": { + "line": 1, + "column": 1, + "offset": 0 + }, + "end": { + "line": 1, + "column": 14, + "offset": 13 + }, + "indent": [] + } + } + ], "position": { "start": { "line": 1, @@ -213,8 +232,8 @@ }, "end": { "line": 1, - "column": 30, - "offset": 29 + "column": 14, + "offset": 13 }, "indent": [] } @@ -228,79 +247,41 @@ }, "end": { "line": 1, - "column": 30, - "offset": 29 - }, - "indent": [] + "column": 14, + "offset": 13 + } } } ] } ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " }, { - "type": "strong", + "type": "listItem", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", + "type": "paragraph", "children": [ + { + "type": "strong", + "children": [ + { + "type": "text", + "value": "license" + } + ] + }, + { + "type": "text", + "value": ": " + }, { "type": "text", - "value": "Number" + "value": "BSD" } ] } ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "numberone", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } } ] } diff --git a/test/fixture/multisignature.output.json b/test/fixture/multisignature.output.json index e5f568279..aa98ebe77 100644 --- a/test/fixture/multisignature.output.json +++ b/test/fixture/multisignature.output.json @@ -85,7 +85,17 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [ + { + "title": "param", + "name": "time", + "lineNumber": 13 + } + ], + "properties": [], "returns": [ { "description": { @@ -140,21 +150,18 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Date" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "getTheTime", "kind": "function", - "params": [ - { - "title": "param", - "name": "time", - "lineNumber": 13 - } - ], "members": { "instance": [], "static": [], @@ -263,9 +270,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "time", "lineNumber": 2, "description": { @@ -326,6 +336,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -380,11 +391,15 @@ } } }, + "title": "returns", "type": { "type": "UndefinedLiteral" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "getTheTime", "kind": "function", "members": { diff --git a/test/fixture/multisignature.output.md.json b/test/fixture/multisignature.output.md.json index a165f7aa8..a6c7ccbc2 100644 --- a/test/fixture/multisignature.output.md.json +++ b/test/fixture/multisignature.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "getTheTime" } - ], - "data": { - "id": "getthetime", - "htmlAttributes": { - "id": "getthetime" - }, - "hProperties": { - "id": "getthetime" - } - } + ] }, { "type": "paragraph", @@ -168,16 +159,7 @@ "type": "text", "value": "getTheTime" } - ], - "data": { - "id": "getthetime-1", - "htmlAttributes": { - "id": "getthetime-1" - }, - "hProperties": { - "id": "getthetime-1" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/nearby_params.output.json b/test/fixture/nearby_params.output.json index 47597bfc9..9c910f9b3 100644 --- a/test/fixture/nearby_params.output.json +++ b/test/fixture/nearby_params.output.json @@ -140,11 +140,12 @@ } } }, + "augments": [], "errors": [], - "kind": "function", - "name": "sessions.create", + "examples": [], "params": [ { + "title": "param", "name": "credentials", "lineNumber": 3, "type": { @@ -153,6 +154,7 @@ }, "properties": [ { + "title": "param", "name": "credentials.name", "lineNumber": 4, "description": { @@ -281,6 +283,7 @@ } }, { + "title": "param", "name": "credentials.password", "lineNumber": 5, "description": { @@ -343,6 +346,7 @@ ] }, { + "title": "param", "name": "callback", "lineNumber": 6, "description": { @@ -440,6 +444,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -494,12 +499,18 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Promise" } } ], + "sees": [], + "throws": [], + "todos": [], + "kind": "function", + "name": "sessions.create", "members": { "instance": [], "static": [], diff --git a/test/fixture/nearby_params.output.md.json b/test/fixture/nearby_params.output.md.json index 6ae645e8a..72fa32537 100644 --- a/test/fixture/nearby_params.output.md.json +++ b/test/fixture/nearby_params.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "sessions.create" } - ], - "data": { - "id": "sessionscreate", - "htmlAttributes": { - "id": "sessionscreate" - }, - "hProperties": { - "id": "sessionscreate" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/nest_params.output.json b/test/fixture/nest_params.output.json index 5d02dca64..d45d2b42d 100644 --- a/test/fixture/nest_params.output.json +++ b/test/fixture/nest_params.output.json @@ -78,9 +78,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "employees", "lineNumber": 1, "description": { @@ -150,6 +153,7 @@ }, "properties": [ { + "title": "param", "name": "employees[].name", "lineNumber": 2, "description": { @@ -210,6 +214,7 @@ } }, { + "title": "param", "name": "employees[].department", "lineNumber": 3, "description": { @@ -272,6 +277,7 @@ ] }, { + "title": "param", "name": "type", "lineNumber": 4, "description": { @@ -336,6 +342,11 @@ "default": "minion" } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { @@ -462,10 +473,12 @@ } } }, + "augments": [], "errors": [], - "name": "foo", + "examples": [], "params": [ { + "title": "param", "name": "options", "lineNumber": 2, "description": { @@ -526,6 +539,7 @@ }, "properties": [ { + "title": "param", "name": "options.much", "lineNumber": 3, "description": { @@ -588,6 +602,7 @@ ] }, { + "title": "param", "name": "bar", "lineNumber": 4, "description": { @@ -650,6 +665,7 @@ ], "properties": [ { + "title": "property", "name": "theTime", "lineNumber": 5, "description": { @@ -710,6 +726,7 @@ }, "properties": [ { + "title": "property", "name": "theTime.hours", "lineNumber": 6, "type": { @@ -718,6 +735,7 @@ } }, { + "title": "property", "name": "theTime.minutes", "lineNumber": 7, "type": { @@ -726,6 +744,7 @@ } }, { + "title": "property", "name": "theTime.seconds", "lineNumber": 8, "type": { @@ -790,12 +809,17 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Object" } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "foo", "members": { "instance": [], "static": [], diff --git a/test/fixture/nest_params.output.md.json b/test/fixture/nest_params.output.md.json index 908d2e152..56ea626be 100644 --- a/test/fixture/nest_params.output.md.json +++ b/test/fixture/nest_params.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "strong", @@ -385,16 +376,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo-1", - "htmlAttributes": { - "id": "foo-1" - }, - "hProperties": { - "id": "foo-1" - } - } + ] }, { "type": "strong", diff --git a/test/fixture/newline-in-description.output.json b/test/fixture/newline-in-description.output.json index ecdde1cca..ea76bdb60 100644 --- a/test/fixture/newline-in-description.output.json +++ b/test/fixture/newline-in-description.output.json @@ -86,13 +86,16 @@ } } }, + "augments": [], "errors": [ { "message": "could not determine @name for hierarchy" } ], + "examples": [], "params": [ { + "title": "param", "name": "a", "lineNumber": 2, "description": { @@ -159,14 +162,17 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "members": { "instance": [], "static": [], "events": [] }, - "path": [ - {} - ], - "namespace": "undefined" + "path": [], + "namespace": "" } ] \ No newline at end of file diff --git a/test/fixture/newline-in-description.output.md.json b/test/fixture/newline-in-description.output.md.json index a69c51af9..8d79efda6 100644 --- a/test/fixture/newline-in-description.output.md.json +++ b/test/fixture/newline-in-description.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "" } - ], - "data": { - "id": "", - "htmlAttributes": { - "id": "" - }, - "hProperties": { - "id": "" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/no-name.output.json b/test/fixture/no-name.output.json index 4a816852c..5bbbeaefb 100644 --- a/test/fixture/no-name.output.json +++ b/test/fixture/no-name.output.json @@ -86,13 +86,16 @@ } } }, + "augments": [], "errors": [ { "message": "could not determine @name for hierarchy" } ], + "examples": [], "params": [ { + "title": "param", "name": "bar", "lineNumber": 2, "type": { @@ -101,14 +104,17 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "members": { "instance": [], "static": [], "events": [] }, - "path": [ - {} - ], - "namespace": "undefined" + "path": [], + "namespace": "" } ] \ No newline at end of file diff --git a/test/fixture/no-name.output.md.json b/test/fixture/no-name.output.md.json index d99370230..fb1772a02 100644 --- a/test/fixture/no-name.output.md.json +++ b/test/fixture/no-name.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "" } - ], - "data": { - "id": "", - "htmlAttributes": { - "id": "" - }, - "hProperties": { - "id": "" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/optional-record-field-type.output.json b/test/fixture/optional-record-field-type.output.json index 44f07d020..b39cb57d2 100644 --- a/test/fixture/optional-record-field-type.output.json +++ b/test/fixture/optional-record-field-type.output.json @@ -24,9 +24,10 @@ } } }, + "augments": [], "errors": [], - "name": "Record", - "kind": "typedef", + "examples": [], + "params": [], "properties": [ { "title": "property", @@ -50,6 +51,12 @@ } } ], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "Record", + "kind": "typedef", "type": { "type": "RecordType", "fields": [ diff --git a/test/fixture/optional-record-field-type.output.md.json b/test/fixture/optional-record-field-type.output.md.json index a5526b9db..bb20925b8 100644 --- a/test/fixture/optional-record-field-type.output.md.json +++ b/test/fixture/optional-record-field-type.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "Record" } - ], - "data": { - "id": "record", - "htmlAttributes": { - "id": "record" - }, - "hProperties": { - "id": "record" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/params.output.json b/test/fixture/params.output.json index 5b286ea03..ec85f63aa 100644 --- a/test/fixture/params.output.json +++ b/test/fixture/params.output.json @@ -86,9 +86,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "b", "lineNumber": 2, "description": { @@ -162,8 +165,7 @@ "title": "param", "name": "$3", "type": { - "type": "NameExpression", - "name": "Object" + "type": "AllLiteral" }, "properties": [ { @@ -184,6 +186,11 @@ ] } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "addThem", "kind": "function", "members": { @@ -286,17 +293,19 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { "title": "param", "name": "$0", "type": { - "type": "NameExpression", - "name": "Object" + "type": "AllLiteral" }, "properties": [ { + "title": "param", "name": "$0.fishes", "lineNumber": 2, "description": { @@ -364,6 +373,11 @@ ] } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "fishesAndFoxes", "kind": "function", "members": { @@ -466,9 +480,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "x", "lineNumber": 2, "type": { @@ -481,6 +498,11 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "withDefault", "kind": "function", "members": { @@ -572,7 +594,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "Foo", "kind": "class", "members": { @@ -664,9 +694,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "x", "lineNumber": 2, "description": { @@ -727,6 +760,11 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "method", "kind": "function", "memberof": "Foo", @@ -937,11 +975,16 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "Address6", + "examples": [ + { + "description": "var address = new Address6('2001::/32');" + } + ], "params": [ { + "title": "param", "name": "address", "lineNumber": 5, "description": { @@ -1002,6 +1045,7 @@ } }, { + "title": "param", "name": "groups", "lineNumber": 6, "description": { @@ -1066,6 +1110,7 @@ "default": "8" }, { + "title": "param", "name": "third", "lineNumber": 7, "description": { @@ -1130,6 +1175,7 @@ } }, { + "title": "param", "name": "foo", "lineNumber": 8, "description": { @@ -1194,11 +1240,13 @@ "default": "[1]" } ], - "examples": [ - { - "description": "var address = new Address6('2001::/32');" - } - ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "Address6", "members": { "instance": [], "static": [], @@ -1403,11 +1451,12 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "GeoJSONSource", + "examples": [], "params": [ { + "title": "param", "name": "options", "lineNumber": 5, "description": { @@ -1471,6 +1520,7 @@ }, "properties": [ { + "title": "param", "name": "options.data", "lineNumber": 6, "description": { @@ -1544,6 +1594,7 @@ } }, { + "title": "param", "name": "options.maxzoom", "lineNumber": 8, "description": { @@ -1608,6 +1659,7 @@ "default": "14" }, { + "title": "param", "name": "options.buffer", "lineNumber": 9, "description": { @@ -1671,6 +1723,7 @@ } }, { + "title": "param", "name": "options.tolerance", "lineNumber": 10, "description": { @@ -1736,6 +1789,13 @@ ] } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "GeoJSONSource", "members": { "instance": [], "static": [], @@ -1849,9 +1909,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "x", "lineNumber": 4, "description": { @@ -1916,6 +1979,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -1970,12 +2034,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "myfunc", "kind": "constant", "members": { @@ -2079,9 +2147,12 @@ } } }, + "augments": [], "errors": [], + "examples": [], "params": [ { + "title": "param", "name": "address", "lineNumber": 4, "description": { @@ -2138,6 +2209,11 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "kind": "function", "members": { diff --git a/test/fixture/params.output.md b/test/fixture/params.output.md index eb13ec7c8..e0395b3fb 100644 --- a/test/fixture/params.output.md +++ b/test/fixture/params.output.md @@ -21,7 +21,7 @@ This function returns the number one. - `b` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the second param - `a` - `c` -- `$3` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** +- `$3` **any** - `$3.d` - `$3.e` - `$3.f` @@ -32,7 +32,7 @@ This method has partially inferred params **Parameters** -- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** +- `$0` **any** - `$0.fishes` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** number of kinds of fish - `$0.foxes` diff --git a/test/fixture/params.output.md.json b/test/fixture/params.output.md.json index 3bee700c1..36439eb13 100644 --- a/test/fixture/params.output.md.json +++ b/test/fixture/params.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "addThem" } - ], - "data": { - "id": "addthem", - "htmlAttributes": { - "id": "addthem" - }, - "hProperties": { - "id": "addthem" - } - } + ] }, { "type": "paragraph", @@ -207,15 +198,8 @@ "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] + "type": "text", + "value": "any" } ] }, @@ -309,16 +293,7 @@ "type": "text", "value": "fishesAndFoxes" } - ], - "data": { - "id": "fishesandfoxes", - "htmlAttributes": { - "id": "fishesandfoxes" - }, - "hProperties": { - "id": "fishesandfoxes" - } - } + ] }, { "type": "paragraph", @@ -386,15 +361,8 @@ "type": "strong", "children": [ { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] + "type": "text", + "value": "any" } ] }, @@ -517,16 +485,7 @@ "type": "text", "value": "withDefault" } - ], - "data": { - "id": "withdefault", - "htmlAttributes": { - "id": "withdefault" - }, - "hProperties": { - "id": "withdefault" - } - } + ] }, { "type": "paragraph", @@ -632,16 +591,7 @@ "type": "text", "value": "Foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", @@ -686,16 +636,7 @@ "type": "text", "value": "method" } - ], - "data": { - "id": "method", - "htmlAttributes": { - "id": "method" - }, - "hProperties": { - "id": "method" - } - } + ] }, { "type": "paragraph", @@ -828,16 +769,7 @@ "type": "text", "value": "Address6" } - ], - "data": { - "id": "address6", - "htmlAttributes": { - "id": "address6" - }, - "hProperties": { - "id": "address6" - } - } + ] }, { "type": "paragraph", @@ -1284,16 +1216,7 @@ "type": "text", "value": "GeoJSONSource" } - ], - "data": { - "id": "geojsonsource", - "htmlAttributes": { - "id": "geojsonsource" - }, - "hProperties": { - "id": "geojsonsource" - } - } + ] }, { "type": "paragraph", @@ -1819,16 +1742,7 @@ "type": "text", "value": "myfunc" } - ], - "data": { - "id": "myfunc", - "htmlAttributes": { - "id": "myfunc" - }, - "hProperties": { - "id": "myfunc" - } - } + ] }, { "type": "paragraph", @@ -2037,16 +1951,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo-1", - "htmlAttributes": { - "id": "foo-1" - }, - "hProperties": { - "id": "foo-1" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/polyglot/blend.json b/test/fixture/polyglot/blend.json index 2e25729bf..2f77adbc8 100644 --- a/test/fixture/polyglot/blend.json +++ b/test/fixture/polyglot/blend.json @@ -102,9 +102,11 @@ }, "file": "[path]" }, - "name": "hexToUInt32Color", + "augments": [], + "examples": [], "params": [ { + "title": "param", "name": "hex", "lineNumber": 3, "type": { @@ -113,6 +115,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -167,12 +170,17 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "hexToUInt32Color", "members": { "instance": [], "static": [], diff --git a/test/fixture/react-jsx.output.json b/test/fixture/react-jsx.output.json index 14a9f2f9e..298cf5575 100644 --- a/test/fixture/react-jsx.output.json +++ b/test/fixture/react-jsx.output.json @@ -75,7 +75,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "apples", "kind": "function", "members": { diff --git a/test/fixture/react-jsx.output.md.json b/test/fixture/react-jsx.output.md.json index 5e8d48714..7ebe87a39 100644 --- a/test/fixture/react-jsx.output.md.json +++ b/test/fixture/react-jsx.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "apples" } - ], - "data": { - "id": "apples", - "htmlAttributes": { - "id": "apples" - }, - "hProperties": { - "id": "apples" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/simple-hashbang.output.json b/test/fixture/simple-hashbang.output.json index a0d7f0904..453b89139 100644 --- a/test/fixture/simple-hashbang.output.json +++ b/test/fixture/simple-hashbang.output.json @@ -85,7 +85,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -140,12 +144,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple-hashbang.input", "kind": "function", "members": { diff --git a/test/fixture/simple-hashbang.output.md.json b/test/fixture/simple-hashbang.output.md.json index caabc796e..eea85db79 100644 --- a/test/fixture/simple-hashbang.output.md.json +++ b/test/fixture/simple-hashbang.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "simple-hashbang.input" } - ], - "data": { - "id": "simple-hashbanginput", - "htmlAttributes": { - "id": "simple-hashbanginput" - }, - "hProperties": { - "id": "simple-hashbanginput" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/simple-two.output.json b/test/fixture/simple-two.output.json index 3f98a4adb..9036ad0da 100644 --- a/test/fixture/simple-two.output.json +++ b/test/fixture/simple-two.output.json @@ -100,9 +100,16 @@ } } }, + "augments": [], "errors": [], + "examples": [ + { + "description": "var result = returnTwo(4);\n// result is 6" + } + ], "params": [ { + "title": "param", "name": "a", "lineNumber": 3, "description": { @@ -163,6 +170,7 @@ } } ], + "properties": [], "returns": [ { "description": { @@ -217,17 +225,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "Number" } } ], - "examples": [ - { - "description": "var result = returnTwo(4);\n// result is 6" - } - ], + "sees": [], + "throws": [], + "todos": [], "name": "returnTwo", "kind": "function", "members": { diff --git a/test/fixture/simple-two.output.md.json b/test/fixture/simple-two.output.md.json index 71f9b4873..87999cf26 100644 --- a/test/fixture/simple-two.output.md.json +++ b/test/fixture/simple-two.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "returnTwo" } - ], - "data": { - "id": "returntwo", - "htmlAttributes": { - "id": "returntwo" - }, - "hProperties": { - "id": "returntwo" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/simple.output.github.json b/test/fixture/simple.output.github.json index 9afbbc824..14359fd38 100644 --- a/test/fixture/simple.output.github.json +++ b/test/fixture/simple.output.github.json @@ -84,10 +84,13 @@ "column": 2 } }, - "github": "[github]", - "path": "test/fixture/simple.input.js" + "github": "[github]" }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -142,12 +145,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple.input", "kind": "function", "members": { diff --git a/test/fixture/simple.output.github.md b/test/fixture/simple.output.github.md index 43aadcbc9..dd84d129c 100644 --- a/test/fixture/simple.output.github.md +++ b/test/fixture/simple.output.github.md @@ -2,7 +2,7 @@ ## simple.input -[test/fixture/simple.input.js:5-8]([github] "Source code on GitHub") +[undefined:5-8](<> "Source code on GitHub") This function returns the number one. diff --git a/test/fixture/simple.output.json b/test/fixture/simple.output.json index 0867306b0..5637943ad 100644 --- a/test/fixture/simple.output.json +++ b/test/fixture/simple.output.json @@ -85,7 +85,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -140,12 +144,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple.input", "kind": "function", "members": { diff --git a/test/fixture/simple.output.md.json b/test/fixture/simple.output.md.json index 3413addb6..6ef343f9a 100644 --- a/test/fixture/simple.output.md.json +++ b/test/fixture/simple.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "simple.input" } - ], - "data": { - "id": "simpleinput", - "htmlAttributes": { - "id": "simpleinput" - }, - "hProperties": { - "id": "simpleinput" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/sort-order-alpha.output.json b/test/fixture/sort-order-alpha.output.json index 028a006f2..f4e2faf10 100644 --- a/test/fixture/sort-order-alpha.output.json +++ b/test/fixture/sort-order-alpha.output.json @@ -24,7 +24,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "a", "kind": "function", "members": { @@ -65,7 +73,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "b", "kind": "function", "members": { @@ -106,7 +122,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "C", "kind": "class", "members": { @@ -116,28 +140,36 @@ "tags": [], "loc": { "start": { - "line": 17, + "line": 11, "column": 2 }, "end": { - "line": 17, + "line": 11, "column": 8 } }, "context": { "loc": { "start": { - "line": 18, + "line": 12, "column": 2 }, "end": { - "line": 18, + "line": 12, "column": 8 } } }, + "augments": [], "errors": [], - "name": "A", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "b", "kind": "function", "memberof": "C", "scope": "instance", @@ -152,40 +184,48 @@ "kind": "class" }, { - "name": "A", + "name": "b", "kind": "function", "scope": "instance" } ], - "namespace": "C#A" + "namespace": "C#b" }, { "description": "", "tags": [], "loc": { "start": { - "line": 15, + "line": 13, "column": 2 }, "end": { - "line": 15, + "line": 13, "column": 8 } }, "context": { "loc": { "start": { - "line": 16, + "line": 14, "column": 2 }, "end": { - "line": 16, + "line": 14, "column": 8 } } }, + "augments": [], "errors": [], - "name": "a", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "B", "kind": "function", "memberof": "C", "scope": "instance", @@ -200,40 +240,48 @@ "kind": "class" }, { - "name": "a", + "name": "B", "kind": "function", "scope": "instance" } ], - "namespace": "C#a" + "namespace": "C#B" }, { "description": "", "tags": [], "loc": { "start": { - "line": 13, + "line": 15, "column": 2 }, "end": { - "line": 13, + "line": 15, "column": 8 } }, "context": { "loc": { "start": { - "line": 14, + "line": 16, "column": 2 }, "end": { - "line": 14, + "line": 16, "column": 8 } } }, + "augments": [], "errors": [], - "name": "B", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "a", "kind": "function", "memberof": "C", "scope": "instance", @@ -248,40 +296,48 @@ "kind": "class" }, { - "name": "B", + "name": "a", "kind": "function", "scope": "instance" } ], - "namespace": "C#B" + "namespace": "C#a" }, { "description": "", "tags": [], "loc": { "start": { - "line": 11, + "line": 17, "column": 2 }, "end": { - "line": 11, + "line": 17, "column": 8 } }, "context": { "loc": { "start": { - "line": 12, + "line": 18, "column": 2 }, "end": { - "line": 12, + "line": 18, "column": 8 } } }, + "augments": [], "errors": [], - "name": "b", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "A", "kind": "function", "memberof": "C", "scope": "instance", @@ -296,12 +352,12 @@ "kind": "class" }, { - "name": "b", + "name": "A", "kind": "function", "scope": "instance" } ], - "namespace": "C#b" + "namespace": "C#A" } ], "static": [], @@ -340,7 +396,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "D", "kind": "class", "members": { @@ -350,28 +414,36 @@ "tags": [], "loc": { "start": { - "line": 29, + "line": 23, "column": 2 }, "end": { - "line": 29, + "line": 23, "column": 8 } }, "context": { "loc": { "start": { - "line": 30, + "line": 24, "column": 2 }, "end": { - "line": 30, + "line": 24, "column": 8 } } }, + "augments": [], "errors": [], - "name": "A", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "b", "kind": "function", "memberof": "D", "scope": "instance", @@ -386,40 +458,48 @@ "kind": "class" }, { - "name": "A", + "name": "b", "kind": "function", "scope": "instance" } ], - "namespace": "D#A" + "namespace": "D#b" }, { "description": "", "tags": [], "loc": { "start": { - "line": 27, + "line": 25, "column": 2 }, "end": { - "line": 27, + "line": 25, "column": 8 } }, "context": { "loc": { "start": { - "line": 28, + "line": 26, "column": 2 }, "end": { - "line": 28, + "line": 26, "column": 8 } } }, + "augments": [], "errors": [], - "name": "a", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "B", "kind": "function", "memberof": "D", "scope": "instance", @@ -434,40 +514,48 @@ "kind": "class" }, { - "name": "a", + "name": "B", "kind": "function", "scope": "instance" } ], - "namespace": "D#a" + "namespace": "D#B" }, { "description": "", "tags": [], "loc": { "start": { - "line": 25, + "line": 27, "column": 2 }, "end": { - "line": 25, + "line": 27, "column": 8 } }, "context": { "loc": { "start": { - "line": 26, + "line": 28, "column": 2 }, "end": { - "line": 26, + "line": 28, "column": 8 } } }, + "augments": [], "errors": [], - "name": "B", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "a", "kind": "function", "memberof": "D", "scope": "instance", @@ -482,40 +570,48 @@ "kind": "class" }, { - "name": "B", + "name": "a", "kind": "function", "scope": "instance" } ], - "namespace": "D#B" + "namespace": "D#a" }, { "description": "", "tags": [], "loc": { "start": { - "line": 23, + "line": 29, "column": 2 }, "end": { - "line": 23, + "line": 29, "column": 8 } }, "context": { "loc": { "start": { - "line": 24, + "line": 30, "column": 2 }, "end": { - "line": 24, + "line": 30, "column": 8 } } }, + "augments": [], "errors": [], - "name": "b", + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "name": "A", "kind": "function", "memberof": "D", "scope": "instance", @@ -530,12 +626,12 @@ "kind": "class" }, { - "name": "b", + "name": "A", "kind": "function", "scope": "instance" } ], - "namespace": "D#b" + "namespace": "D#A" } ], "static": [], diff --git a/test/fixture/sort-order-alpha.output.md b/test/fixture/sort-order-alpha.output.md index e89a98eb7..4b6e8d21c 100644 --- a/test/fixture/sort-order-alpha.output.md +++ b/test/fixture/sort-order-alpha.output.md @@ -5,15 +5,15 @@ - [a](#a) - [b](#b) - [C](#c) - - [A](#a-1) - - [a](#a-2) - - [B](#b-1) - - [b](#b-2) + - [b](#b-1) + - [B](#b-2) + - [a](#a-1) + - [A](#a-2) - [D](#d) - - [A](#a-3) - - [a](#a-4) - - [B](#b-3) - - [b](#b-4) + - [b](#b-3) + - [B](#b-4) + - [a](#a-3) + - [A](#a-4) ## a @@ -21,20 +21,20 @@ ## C -### A - -### a +### b ### B -### b - -## D +### a ### A -### a +## D + +### b ### B -### b +### a + +### A diff --git a/test/fixture/sort-order-alpha.output.md.json b/test/fixture/sort-order-alpha.output.md.json index 17ca468bb..31d018194 100644 --- a/test/fixture/sort-order-alpha.output.md.json +++ b/test/fixture/sort-order-alpha.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "a" } - ], - "data": { - "id": "a", - "htmlAttributes": { - "id": "a" - }, - "hProperties": { - "id": "a" - } - } + ] }, { "depth": 2, @@ -32,16 +23,7 @@ "type": "text", "value": "b" } - ], - "data": { - "id": "b", - "htmlAttributes": { - "id": "b" - }, - "hProperties": { - "id": "b" - } - } + ] }, { "depth": 2, @@ -51,16 +33,7 @@ "type": "text", "value": "C" } - ], - "data": { - "id": "c", - "htmlAttributes": { - "id": "c" - }, - "hProperties": { - "id": "c" - } - } + ] }, { "depth": 3, @@ -68,18 +41,9 @@ "children": [ { "type": "text", - "value": "A" - } - ], - "data": { - "id": "a-1", - "htmlAttributes": { - "id": "a-1" - }, - "hProperties": { - "id": "a-1" + "value": "b" } - } + ] }, { "depth": 3, @@ -87,18 +51,9 @@ "children": [ { "type": "text", - "value": "a" - } - ], - "data": { - "id": "a-2", - "htmlAttributes": { - "id": "a-2" - }, - "hProperties": { - "id": "a-2" + "value": "B" } - } + ] }, { "depth": 3, @@ -106,18 +61,9 @@ "children": [ { "type": "text", - "value": "B" - } - ], - "data": { - "id": "b-1", - "htmlAttributes": { - "id": "b-1" - }, - "hProperties": { - "id": "b-1" + "value": "a" } - } + ] }, { "depth": 3, @@ -125,18 +71,9 @@ "children": [ { "type": "text", - "value": "b" - } - ], - "data": { - "id": "b-2", - "htmlAttributes": { - "id": "b-2" - }, - "hProperties": { - "id": "b-2" + "value": "A" } - } + ] }, { "depth": 2, @@ -146,16 +83,7 @@ "type": "text", "value": "D" } - ], - "data": { - "id": "d", - "htmlAttributes": { - "id": "d" - }, - "hProperties": { - "id": "d" - } - } + ] }, { "depth": 3, @@ -163,18 +91,9 @@ "children": [ { "type": "text", - "value": "A" - } - ], - "data": { - "id": "a-3", - "htmlAttributes": { - "id": "a-3" - }, - "hProperties": { - "id": "a-3" + "value": "b" } - } + ] }, { "depth": 3, @@ -182,18 +101,9 @@ "children": [ { "type": "text", - "value": "a" - } - ], - "data": { - "id": "a-4", - "htmlAttributes": { - "id": "a-4" - }, - "hProperties": { - "id": "a-4" + "value": "B" } - } + ] }, { "depth": 3, @@ -201,18 +111,9 @@ "children": [ { "type": "text", - "value": "B" - } - ], - "data": { - "id": "b-3", - "htmlAttributes": { - "id": "b-3" - }, - "hProperties": { - "id": "b-3" + "value": "a" } - } + ] }, { "depth": 3, @@ -220,18 +121,9 @@ "children": [ { "type": "text", - "value": "b" - } - ], - "data": { - "id": "b-4", - "htmlAttributes": { - "id": "b-4" - }, - "hProperties": { - "id": "b-4" + "value": "A" } - } + ] } ] } \ No newline at end of file diff --git a/test/fixture/sorting/output.json b/test/fixture/sorting/output.json index 253946fe2..705f499b8 100644 --- a/test/fixture/sorting/output.json +++ b/test/fixture/sorting/output.json @@ -76,6 +76,14 @@ }, "file": "[path]" }, + "augments": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "bananas", "kind": "function", "members": { @@ -168,6 +176,14 @@ }, "file": "[path]" }, + "augments": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "carrots", "kind": "function", "members": { @@ -260,6 +276,14 @@ }, "file": "[path]" }, + "augments": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "apples", "kind": "function", "members": { diff --git a/test/fixture/string-literal-key.output.json b/test/fixture/string-literal-key.output.json index 7852b17b9..f159e0ba9 100644 --- a/test/fixture/string-literal-key.output.json +++ b/test/fixture/string-literal-key.output.json @@ -31,7 +31,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "alias": "MyContainerObject", "name": "MyContainerObject", "kind": "constant", @@ -124,7 +132,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "foo", "members": { "instance": [], diff --git a/test/fixture/string-literal-key.output.md.json b/test/fixture/string-literal-key.output.md.json index ad9763e10..c0bd30afe 100644 --- a/test/fixture/string-literal-key.output.md.json +++ b/test/fixture/string-literal-key.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "MyContainerObject" } - ], - "data": { - "id": "mycontainerobject", - "htmlAttributes": { - "id": "mycontainerobject" - }, - "hProperties": { - "id": "mycontainerobject" - } - } + ] }, { "depth": 2, @@ -32,16 +23,7 @@ "type": "text", "value": "foo" } - ], - "data": { - "id": "foo", - "htmlAttributes": { - "id": "foo" - }, - "hProperties": { - "id": "foo" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/sync/alias.input.js b/test/fixture/sync/alias.input.js deleted file mode 100644 index 61bd4d81f..000000000 --- a/test/fixture/sync/alias.input.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This is a method that has an alias tag: so it should - * be referred to as nixon, but should still have inference. - * @alias nixon - */ -function dewey(a: number): number { - return a; -} diff --git a/test/fixture/sync/alias.output.json b/test/fixture/sync/alias.output.json deleted file mode 100644 index 1087e5b3f..000000000 --- a/test/fixture/sync/alias.output.json +++ /dev/null @@ -1,125 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This is a method that has an alias tag: so it should\nbe referred to as nixon, but should still have inference.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 58, - "offset": 110 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 58, - "offset": 110 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 58, - "offset": 110 - } - } - }, - "tags": [ - { - "title": "alias", - "description": null, - "lineNumber": 3, - "name": "nixon" - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 1 - } - } - }, - "errors": [], - "alias": "nixon", - "name": "nixon", - "kind": "function", - "params": [ - { - "title": "param", - "name": "a", - "lineNumber": 6, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "returns": [ - { - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "nixon", - "kind": "function" - } - ], - "namespace": "nixon" - } -] \ No newline at end of file diff --git a/test/fixture/sync/alias.output.md b/test/fixture/sync/alias.output.md deleted file mode 100644 index a79e8dd2a..000000000 --- a/test/fixture/sync/alias.output.md +++ /dev/null @@ -1,16 +0,0 @@ - - -### Table of Contents - -- [nixon](#nixon) - -## nixon - -This is a method that has an alias tag: so it should -be referred to as nixon, but should still have inference. - -**Parameters** - -- `a` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** - -Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** diff --git a/test/fixture/sync/alias.output.md.json b/test/fixture/sync/alias.output.md.json deleted file mode 100644 index 83aac1158..000000000 --- a/test/fixture/sync/alias.output.md.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "nixon" - } - ], - "data": { - "id": "nixon", - "htmlAttributes": { - "id": "nixon" - }, - "hProperties": { - "id": "nixon" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This is a method that has an alias tag: so it should\nbe referred to as nixon, but should still have inference.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 58, - "offset": 110 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 58, - "offset": 110 - }, - "indent": [ - 1 - ] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "a" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/empty-example.input.js b/test/fixture/sync/empty-example.input.js deleted file mode 100644 index e0922f4ea..000000000 --- a/test/fixture/sync/empty-example.input.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This function returns the number plus two. - * - * @example - */ -function returnTwo() { - return a + 2; -} diff --git a/test/fixture/sync/empty-example.output.json b/test/fixture/sync/empty-example.output.json deleted file mode 100644 index 787b35174..000000000 --- a/test/fixture/sync/empty-example.output.json +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number plus two.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - } - } - }, - "tags": [ - { - "title": "example", - "description": "", - "lineNumber": 3 - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 1 - } - } - }, - "errors": [ - { - "message": "@example without code", - "commentLineNumber": 3 - } - ], - "name": "returnTwo", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "returnTwo", - "kind": "function" - } - ], - "namespace": "returnTwo" - } -] \ No newline at end of file diff --git a/test/fixture/sync/empty-example.output.md b/test/fixture/sync/empty-example.output.md deleted file mode 100644 index c5495a091..000000000 --- a/test/fixture/sync/empty-example.output.md +++ /dev/null @@ -1,9 +0,0 @@ - - -### Table of Contents - -- [returnTwo](#returntwo) - -## returnTwo - -This function returns the number plus two. diff --git a/test/fixture/sync/empty-example.output.md.json b/test/fixture/sync/empty-example.output.md.json deleted file mode 100644 index 1e6973fe4..000000000 --- a/test/fixture/sync/empty-example.output.md.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "returnTwo" - } - ], - "data": { - "id": "returntwo", - "htmlAttributes": { - "id": "returntwo" - }, - "hProperties": { - "id": "returntwo" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number plus two.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/flow-types.input.js b/test/fixture/sync/flow-types.input.js deleted file mode 100644 index bd2e93a8f..000000000 --- a/test/fixture/sync/flow-types.input.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * This function returns the number one. - */ -function addThem(a: Point, b: string, c: ?boolean, d: Array, e: Object, f: Named): number { - return a + b + c + d + e; -} - -/** - * A 2D point. - * - * @property {number} x this is a prop - */ -type Point = { - x: number, - y: number, - rgb: { - hex: string - }, - props: { - radius: { - x: number - } - } -}; - -/** - * A type with entirely derived properties - */ -type Two = { - x: number, - y: number, - z: ?number -}; - -/** - * Just an alias for an array of strings - */ -type T = Array; - -/** - * Very Important Transform - */ -function veryImportantTransform( - input: Array, - options: Object = {} -): string { - return "42"; -} - - -/** - * Function with optional parameter. - */ -function optionalFunc(x: number = 42) {} - -/** - * Function with object parameter. - */ -function objectParamFn(x: { a: number }) {} - -/** hi */ -function objectParamFn(x: (y:Foo) => Bar) {} - -/** My type */ -export type T = number; - -/** - * Define my object API - */ -export type SomeObjectAPI = { - method: (param: string) => boolean -} diff --git a/test/fixture/sync/flow-types.output.json b/test/fixture/sync/flow-types.output.json deleted file mode 100644 index 837ccd756..000000000 --- a/test/fixture/sync/flow-types.output.json +++ /dev/null @@ -1,1436 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number one.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - "errors": [], - "name": "addThem", - "kind": "function", - "params": [ - { - "title": "param", - "name": "a", - "lineNumber": 4, - "type": { - "type": "NameExpression", - "name": "Point" - } - }, - { - "title": "param", - "name": "b", - "lineNumber": 4, - "type": { - "type": "NameExpression", - "name": "string" - } - }, - { - "title": "param", - "name": "c", - "lineNumber": 4, - "type": { - "type": "NullableType", - "expression": { - "type": "NameExpression", - "name": "boolean" - } - } - }, - { - "title": "param", - "name": "d", - "lineNumber": 4, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "number" - } - ] - } - }, - { - "title": "param", - "name": "e", - "lineNumber": 4, - "type": { - "type": "NameExpression", - "name": "Object" - } - }, - { - "title": "param", - "name": "f", - "lineNumber": 4, - "type": { - "type": "NameExpression", - "name": "Named" - } - } - ], - "returns": [ - { - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "addThem", - "kind": "function" - } - ], - "namespace": "addThem" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A 2D point.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - } - } - }, - "tags": [ - { - "title": "property", - "description": "this is a prop", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "number" - }, - "name": "x" - } - ], - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 12, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 24, - "column": 2 - } - } - }, - "errors": [], - "properties": [ - { - "name": "x", - "lineNumber": 3, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a prop", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - "type": { - "type": "NameExpression", - "name": "number" - } - }, - { - "title": "property", - "name": "y", - "lineNumber": 15, - "type": { - "type": "NameExpression", - "name": "number" - } - }, - { - "title": "property", - "name": "rgb", - "lineNumber": 16, - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "hex", - "value": { - "type": "NameExpression", - "name": "string" - } - } - ] - }, - "properties": [ - { - "title": "property", - "name": "rgb.hex", - "lineNumber": 17, - "type": { - "type": "NameExpression", - "name": "string" - } - } - ] - }, - { - "title": "property", - "name": "props", - "lineNumber": 19, - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "radius", - "value": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "x", - "value": { - "type": "NameExpression", - "name": "number" - } - } - ] - } - } - ] - }, - "properties": [ - { - "title": "property", - "name": "props.radius", - "lineNumber": 20, - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "x", - "value": { - "type": "NameExpression", - "name": "number" - } - } - ] - }, - "properties": [ - { - "title": "property", - "name": "props.radius.x", - "lineNumber": 21, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ] - } - ] - } - ], - "name": "Point", - "kind": "typedef", - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "x", - "value": { - "type": "NameExpression", - "name": "number" - } - }, - { - "type": "FieldType", - "key": "y", - "value": { - "type": "NameExpression", - "name": "number" - } - }, - { - "type": "FieldType", - "key": "rgb", - "value": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "hex", - "value": { - "type": "NameExpression", - "name": "string" - } - } - ] - } - }, - { - "type": "FieldType", - "key": "props", - "value": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "radius", - "value": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "x", - "value": { - "type": "NameExpression", - "name": "number" - } - } - ] - } - } - ] - } - } - ] - }, - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "Point", - "kind": "typedef" - } - ], - "namespace": "Point" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A type with entirely derived properties", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 40, - "offset": 39 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 40, - "offset": 39 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 40, - "offset": 39 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 26, - "column": 0 - }, - "end": { - "line": 28, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 29, - "column": 0 - }, - "end": { - "line": 33, - "column": 2 - } - } - }, - "errors": [], - "name": "Two", - "kind": "typedef", - "properties": [ - { - "title": "property", - "name": "x", - "lineNumber": 30, - "type": { - "type": "NameExpression", - "name": "number" - } - }, - { - "title": "property", - "name": "y", - "lineNumber": 31, - "type": { - "type": "NameExpression", - "name": "number" - } - }, - { - "title": "property", - "name": "z", - "lineNumber": 32, - "type": { - "type": "NullableType", - "expression": { - "type": "NameExpression", - "name": "number" - } - } - } - ], - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "x", - "value": { - "type": "NameExpression", - "name": "number" - } - }, - { - "type": "FieldType", - "key": "y", - "value": { - "type": "NameExpression", - "name": "number" - } - }, - { - "type": "FieldType", - "key": "z", - "value": { - "type": "NullableType", - "expression": { - "type": "NameExpression", - "name": "number" - } - } - } - ] - }, - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "Two", - "kind": "typedef" - } - ], - "namespace": "Two" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Just an alias for an array of strings", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 35, - "column": 0 - }, - "end": { - "line": 37, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 38, - "column": 0 - }, - "end": { - "line": 38, - "column": 23 - } - } - }, - "errors": [], - "name": "T", - "kind": "typedef", - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "string" - } - ] - }, - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "T", - "kind": "typedef" - } - ], - "namespace": "T" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "My type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 64, - "column": 0 - }, - "end": { - "line": 64, - "column": 14 - } - }, - "context": { - "loc": { - "start": { - "line": 65, - "column": 0 - }, - "end": { - "line": 65, - "column": 23 - } - } - }, - "errors": [], - "name": "T", - "kind": "typedef", - "type": { - "type": "NameExpression", - "name": "number" - }, - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "T", - "kind": "typedef" - } - ], - "namespace": "T" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Very Important Transform", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 40, - "column": 0 - }, - "end": { - "line": 42, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 43, - "column": 0 - }, - "end": { - "line": 48, - "column": 1 - } - } - }, - "errors": [], - "name": "veryImportantTransform", - "kind": "function", - "params": [ - { - "title": "param", - "name": "input", - "lineNumber": 44, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "string" - } - ] - } - }, - { - "title": "param", - "name": "options", - "default": "{}", - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Object" - } - } - } - ], - "returns": [ - { - "type": { - "type": "NameExpression", - "name": "string" - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "veryImportantTransform", - "kind": "function" - } - ], - "namespace": "veryImportantTransform" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Function with optional parameter.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 51, - "column": 0 - }, - "end": { - "line": 53, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 54, - "column": 0 - }, - "end": { - "line": 54, - "column": 40 - } - } - }, - "errors": [], - "name": "optionalFunc", - "kind": "function", - "params": [ - { - "title": "param", - "name": "x", - "default": "42", - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "number" - } - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "optionalFunc", - "kind": "function" - } - ], - "namespace": "optionalFunc" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Function with object parameter.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 32, - "offset": 31 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 32, - "offset": 31 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 32, - "offset": 31 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 56, - "column": 0 - }, - "end": { - "line": 58, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 59, - "column": 0 - }, - "end": { - "line": 59, - "column": 43 - } - } - }, - "errors": [], - "name": "objectParamFn", - "kind": "function", - "params": [ - { - "title": "param", - "name": "x", - "lineNumber": 59, - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "a", - "value": { - "type": "NameExpression", - "name": "number" - } - } - ] - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "objectParamFn", - "kind": "function" - } - ], - "namespace": "objectParamFn" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "hi", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 61, - "column": 0 - }, - "end": { - "line": 61, - "column": 9 - } - }, - "context": { - "loc": { - "start": { - "line": 62, - "column": 0 - }, - "end": { - "line": 62, - "column": 44 - } - } - }, - "errors": [], - "name": "objectParamFn", - "kind": "function", - "params": [ - { - "title": "param", - "name": "x", - "lineNumber": 62, - "type": { - "type": "FunctionType", - "params": [ - { - "type": "ParameterType", - "name": "y", - "expression": { - "type": "NameExpression", - "name": "Foo" - } - } - ], - "result": { - "type": "NameExpression", - "name": "Bar" - } - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "objectParamFn", - "kind": "function" - } - ], - "namespace": "objectParamFn" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Define my object API", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - } - } - }, - "tags": [], - "loc": { - "start": { - "line": 67, - "column": 0 - }, - "end": { - "line": 69, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 70, - "column": 0 - }, - "end": { - "line": 72, - "column": 1 - } - } - }, - "errors": [], - "name": "SomeObjectAPI", - "kind": "typedef", - "type": { - "type": "RecordType", - "fields": [ - { - "type": "FieldType", - "key": "method", - "value": { - "type": "FunctionType", - "params": [ - { - "type": "ParameterType", - "name": "param", - "expression": { - "type": "NameExpression", - "name": "string" - } - } - ], - "result": { - "type": "NameExpression", - "name": "boolean" - } - } - } - ] - }, - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "SomeObjectAPI", - "kind": "typedef" - } - ], - "namespace": "SomeObjectAPI" - } -] \ No newline at end of file diff --git a/test/fixture/sync/flow-types.output.md b/test/fixture/sync/flow-types.output.md deleted file mode 100644 index 3bd1e27db..000000000 --- a/test/fixture/sync/flow-types.output.md +++ /dev/null @@ -1,110 +0,0 @@ - - -### Table of Contents - -- [addThem](#addthem) -- [Point](#point) -- [Two](#two) -- [T](#t) -- [T](#t-1) -- [veryImportantTransform](#veryimportanttransform) -- [optionalFunc](#optionalfunc) -- [objectParamFn](#objectparamfn) -- [objectParamFn](#objectparamfn-1) -- [SomeObjectAPI](#someobjectapi) - -## addThem - -This function returns the number one. - -**Parameters** - -- `a` **[Point](#point)** -- `b` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** -- `c` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** -- `d` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** -- `e` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** -- `f` **Named** - -Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** - -## Point - -A 2D point. - -Type: {x: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), y: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), rgb: {hex: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)}, props: {radius: {x: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)}}} - -**Properties** - -- `x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** this is a prop -- `y` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** -- `rgb` **{hex: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)}** - - `rgb.hex` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** -- `props` **{radius: {x: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)}}** - - `props.radius` **{x: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)}** - - `props.radius.x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** - -## Two - -A type with entirely derived properties - -Type: {x: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), y: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), z: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?} - -**Properties** - -- `x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** -- `y` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** -- `z` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** - -## T - -Just an alias for an array of strings - -Type: [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> - -## T - -My type - -Type: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) - -## veryImportantTransform - -Very Important Transform - -**Parameters** - -- `input` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** -- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** (optional, default `{}`) - -Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** - -## optionalFunc - -Function with optional parameter. - -**Parameters** - -- `x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** (optional, default `42`) - -## objectParamFn - -Function with object parameter. - -**Parameters** - -- `x` **{a: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)}** - -## objectParamFn - -hi - -**Parameters** - -- `x` **function (y: Foo): Bar** - -## SomeObjectAPI - -Define my object API - -Type: {method: function (param: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)): [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)} diff --git a/test/fixture/sync/flow-types.output.md.json b/test/fixture/sync/flow-types.output.md.json deleted file mode 100644 index 380be908e..000000000 --- a/test/fixture/sync/flow-types.output.md.json +++ /dev/null @@ -1,2034 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "addThem" - } - ], - "data": { - "id": "addthem", - "htmlAttributes": { - "id": "addthem" - }, - "hProperties": { - "id": "addthem" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number one.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "a" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "#point", - "url": "#point", - "type": "link", - "children": [ - { - "type": "text", - "value": "Point" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "b" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "c" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "boolean" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "d" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "e" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "f" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Named" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "Point" - } - ], - "data": { - "id": "point", - "htmlAttributes": { - "id": "point" - }, - "hProperties": { - "id": "point" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A 2D point.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "x: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": ", " - }, - { - "type": "text", - "value": "y: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": ", " - }, - { - "type": "text", - "value": "rgb: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "hex: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - }, - { - "type": "text", - "value": "}" - }, - { - "type": "text", - "value": ", " - }, - { - "type": "text", - "value": "props: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "radius: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "x: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "}" - }, - { - "type": "text", - "value": "}" - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Properties" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a prop", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "y" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "rgb" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "hex: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "rgb.hex" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "props" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "radius: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "x: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "}" - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "props.radius" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "x: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "props.radius.x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "Two" - } - ], - "data": { - "id": "two", - "htmlAttributes": { - "id": "two" - }, - "hProperties": { - "id": "two" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A type with entirely derived properties", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 40, - "offset": 39 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 40, - "offset": 39 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "x: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": ", " - }, - { - "type": "text", - "value": "y: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": ", " - }, - { - "type": "text", - "value": "z: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "?" - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Properties" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "y" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "z" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "T" - } - ], - "data": { - "id": "t", - "htmlAttributes": { - "id": "t" - }, - "hProperties": { - "id": "t" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Just an alias for an array of strings", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "T" - } - ], - "data": { - "id": "t-1", - "htmlAttributes": { - "id": "t-1" - }, - "hProperties": { - "id": "t-1" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "My type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "veryImportantTransform" - } - ], - "data": { - "id": "veryimportanttransform", - "htmlAttributes": { - "id": "veryimportanttransform" - }, - "hProperties": { - "id": "veryimportanttransform" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Very Important Transform", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "input" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "{}" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "optionalFunc" - } - ], - "data": { - "id": "optionalfunc", - "htmlAttributes": { - "id": "optionalfunc" - }, - "hProperties": { - "id": "optionalfunc" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Function with optional parameter.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "42" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "objectParamFn" - } - ], - "data": { - "id": "objectparamfn", - "htmlAttributes": { - "id": "objectparamfn" - }, - "hProperties": { - "id": "objectparamfn" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Function with object parameter.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 32, - "offset": 31 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 32, - "offset": 31 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "a: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - }, - { - "type": "text", - "value": "}" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "objectParamFn" - } - ], - "data": { - "id": "objectparamfn-1", - "htmlAttributes": { - "id": "objectparamfn-1" - }, - "hProperties": { - "id": "objectparamfn-1" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "hi", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "function (" - }, - { - "type": "text", - "value": "y: " - }, - { - "type": "text", - "value": "Foo" - }, - { - "type": "text", - "value": ")" - }, - { - "type": "text", - "value": ": " - }, - { - "type": "text", - "value": "Bar" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "SomeObjectAPI" - } - ], - "data": { - "id": "someobjectapi", - "htmlAttributes": { - "id": "someobjectapi" - }, - "hProperties": { - "id": "someobjectapi" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Define my object API", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "type": "text", - "value": "{" - }, - { - "type": "text", - "value": "method: " - }, - { - "type": "text", - "value": "function (" - }, - { - "type": "text", - "value": "param: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - }, - { - "type": "text", - "value": ")" - }, - { - "type": "text", - "value": ": " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "boolean" - } - ] - }, - { - "type": "text", - "value": "}" - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/lots-of-options.input.js b/test/fixture/sync/lots-of-options.input.js deleted file mode 100644 index c9f32290e..000000000 --- a/test/fixture/sync/lots-of-options.input.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Global spectra deconvolution - * @param {Array} x - Independent variable - * @param {Array} yIn - Dependent variable - * @param {Object} [options] - Options object - * @param {Object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options - * @param {Number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise - * @param {Number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative - * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true. - * @param {Number} [options.noiseLevel = 3] - Noise threshold in spectrum units - * @param {Boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false) - * @param {Boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables - * @param {Boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors - * to determine the true x,y values of the peak? - * @param {Number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2) - * @param {Boolean} [options.boundaries = false] - Return also the inflection points of the peaks - * @param {Number} [options.derivativeThreshold = 0] - Filters based on the amplitude of the first derivative - * @return {Array} - */ -function gsd(x, yIn, options) { -} - -module.exports = gsd; diff --git a/test/fixture/sync/lots-of-options.output.json b/test/fixture/sync/lots-of-options.output.json deleted file mode 100644 index 96d3f4a99..000000000 --- a/test/fixture/sync/lots-of-options.output.json +++ /dev/null @@ -1,1293 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Global spectra deconvolution", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 29, - "offset": 28 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 29, - "offset": 28 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 29, - "offset": 28 - } - } - }, - "tags": [ - { - "title": "param", - "description": "Independent variable", - "lineNumber": 2, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Number" - } - ] - }, - "name": "x" - }, - { - "title": "param", - "description": "Dependent variable", - "lineNumber": 3, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Number" - } - ] - }, - "name": "yIn" - }, - { - "title": "param", - "description": "Options object", - "lineNumber": 4, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Object" - } - }, - "name": "options" - }, - { - "title": "param", - "description": "Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options", - "lineNumber": 5, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Object" - } - }, - "name": "options.sgOptions" - }, - { - "title": "param", - "description": "Threshold to determine if a given peak should be considered as a noise", - "lineNumber": 6, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "name": "options.minMaxRatio", - "default": "0.00025" - }, - { - "title": "param", - "description": "If `broadRatio` is higher than 0, then all the peaks which second derivative\nsmaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.", - "lineNumber": 7, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "name": "options.broadRatio", - "default": "0.00" - }, - { - "title": "param", - "description": "Noise threshold in spectrum units", - "lineNumber": 9, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "name": "options.noiseLevel", - "default": "3" - }, - { - "title": "param", - "description": "Peaks are local maximum(true) or minimum(false)", - "lineNumber": 10, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "name": "options.maxCriteria", - "default": "true" - }, - { - "title": "param", - "description": "Select the peak intensities from a smoothed version of the independent variables", - "lineNumber": 11, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "name": "options.smoothY", - "default": "true" - }, - { - "title": "param", - "description": "Use a quadratic optimizations with the peak and its 3 closest neighbors\nto determine the true x,y values of the peak?", - "lineNumber": 12, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "name": "options.realTopDetection", - "default": "false" - }, - { - "title": "param", - "description": "Factor to multiply the calculated height (usually 2)", - "lineNumber": 14, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "name": "options.heightFactor", - "default": "0" - }, - { - "title": "param", - "description": "Return also the inflection points of the peaks", - "lineNumber": 15, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "name": "options.boundaries", - "default": "false" - }, - { - "title": "param", - "description": "Filters based on the amplitude of the first derivative", - "lineNumber": 16, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "name": "options.derivativeThreshold", - "default": "0" - }, - { - "title": "return", - "description": null, - "lineNumber": 17, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Object" - } - ] - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 19, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 20, - "column": 0 - }, - "end": { - "line": 21, - "column": 1 - } - } - }, - "errors": [], - "params": [ - { - "name": "x", - "lineNumber": 2, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Independent variable", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - } - } - }, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Number" - } - ] - } - }, - { - "name": "yIn", - "lineNumber": 3, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Dependent variable", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - } - } - }, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Number" - } - ] - } - }, - { - "name": "options", - "lineNumber": 4, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Options object", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Object" - } - }, - "properties": [ - { - "name": "options.sgOptions", - "lineNumber": 5, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Options object for Savitzky-Golay filter. See ", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - }, - { - "type": "link", - "title": null, - "url": "https://github.com/mljs/savitzky-golay-generalized#options", - "children": [ - { - "type": "text", - "value": "https://github.com/mljs/savitzky-golay-generalized#options", - "position": { - "start": { - "line": 1, - "column": 47, - "offset": 46 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 47, - "offset": 46 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Object" - } - } - }, - { - "name": "options.minMaxRatio", - "lineNumber": 6, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Threshold to determine if a given peak should be considered as a noise", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 71, - "offset": 70 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 71, - "offset": 70 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 71, - "offset": 70 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "default": "0.00025" - }, - { - "name": "options.broadRatio", - "lineNumber": 7, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "If ", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "broadRatio", - "position": { - "start": { - "line": 1, - "column": 4, - "offset": 3 - }, - "end": { - "line": 1, - "column": 16, - "offset": 15 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " is higher than 0, then all the peaks which second derivative\nsmaller than ", - "position": { - "start": { - "line": 1, - "column": 16, - "offset": 15 - }, - "end": { - "line": 2, - "column": 14, - "offset": 90 - }, - "indent": [ - 1 - ] - } - }, - { - "type": "inlineCode", - "value": "broadRatio * maxAbsSecondDerivative", - "position": { - "start": { - "line": 2, - "column": 14, - "offset": 90 - }, - "end": { - "line": 2, - "column": 51, - "offset": 127 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " will be marked with the soft mask equal to true.", - "position": { - "start": { - "line": 2, - "column": 51, - "offset": 127 - }, - "end": { - "line": 2, - "column": 100, - "offset": 176 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 100, - "offset": 176 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 100, - "offset": 176 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "default": "0.00" - }, - { - "name": "options.noiseLevel", - "lineNumber": 9, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Noise threshold in spectrum units", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "default": "3" - }, - { - "name": "options.maxCriteria", - "lineNumber": 10, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Peaks are local maximum(true) or minimum(false)", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 48, - "offset": 47 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 48, - "offset": 47 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 48, - "offset": 47 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "default": "true" - }, - { - "name": "options.smoothY", - "lineNumber": 11, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Select the peak intensities from a smoothed version of the independent variables", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 81, - "offset": 80 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 81, - "offset": 80 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 81, - "offset": 80 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "default": "true" - }, - { - "name": "options.realTopDetection", - "lineNumber": 12, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Use a quadratic optimizations with the peak and its 3 closest neighbors\nto determine the true x,y values of the peak?", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 46, - "offset": 117 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 46, - "offset": 117 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 46, - "offset": 117 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "default": "false" - }, - { - "name": "options.heightFactor", - "lineNumber": 14, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Factor to multiply the calculated height (usually 2)", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 53, - "offset": 52 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 53, - "offset": 52 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 53, - "offset": 52 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "default": "0" - }, - { - "name": "options.boundaries", - "lineNumber": 15, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Return also the inflection points of the peaks", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Boolean" - } - }, - "default": "false" - }, - { - "name": "options.derivativeThreshold", - "lineNumber": 16, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Filters based on the amplitude of the first derivative", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 55, - "offset": 54 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 55, - "offset": 54 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 55, - "offset": 54 - } - } - }, - "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "Number" - } - }, - "default": "0" - } - ] - } - ], - "returns": [ - { - "description": { - "type": "root", - "children": [], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 1, - "offset": 0 - } - } - }, - "type": { - "type": "TypeApplication", - "expression": { - "type": "NameExpression", - "name": "Array" - }, - "applications": [ - { - "type": "NameExpression", - "name": "Object" - } - ] - } - } - ], - "name": "gsd", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "gsd", - "kind": "function" - } - ], - "namespace": "gsd" - } -] \ No newline at end of file diff --git a/test/fixture/sync/lots-of-options.output.md b/test/fixture/sync/lots-of-options.output.md deleted file mode 100644 index 11594ccc3..000000000 --- a/test/fixture/sync/lots-of-options.output.md +++ /dev/null @@ -1,29 +0,0 @@ - - -### Table of Contents - -- [gsd](#gsd) - -## gsd - -Global spectra deconvolution - -**Parameters** - -- `x` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** Independent variable -- `yIn` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** Dependent variable -- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Options object - - `options.sgOptions` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Options object for Savitzky-Golay filter. See - - `options.minMaxRatio` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Threshold to determine if a given peak should be considered as a noise (optional, default `0.00025`) - - `options.broadRatio` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** If `broadRatio` is higher than 0, then all the peaks which second derivative - smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true. (optional, default `0.00`) - - `options.noiseLevel` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Noise threshold in spectrum units (optional, default `3`) - - `options.maxCriteria` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Peaks are local maximum(true) or minimum(false) (optional, default `true`) - - `options.smoothY` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Select the peak intensities from a smoothed version of the independent variables (optional, default `true`) - - `options.realTopDetection` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Use a quadratic optimizations with the peak and its 3 closest neighbors - to determine the true x,y values of the peak? (optional, default `false`) - - `options.heightFactor` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Factor to multiply the calculated height (usually 2) (optional, default `0`) - - `options.boundaries` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return also the inflection points of the peaks (optional, default `false`) - - `options.derivativeThreshold` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Filters based on the amplitude of the first derivative (optional, default `0`) - -Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** diff --git a/test/fixture/sync/lots-of-options.output.md.json b/test/fixture/sync/lots-of-options.output.md.json deleted file mode 100644 index b014acdda..000000000 --- a/test/fixture/sync/lots-of-options.output.md.json +++ /dev/null @@ -1,1429 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "gsd" - } - ], - "data": { - "id": "gsd", - "htmlAttributes": { - "id": "gsd" - }, - "hProperties": { - "id": "gsd" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Global spectra deconvolution", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 29, - "offset": 28 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 29, - "offset": 28 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "x" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Independent variable", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - }, - "indent": [] - } - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "yIn" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Dependent variable", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Options object", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.sgOptions" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Options object for Savitzky-Golay filter. See ", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - }, - { - "type": "link", - "title": null, - "url": "https://github.com/mljs/savitzky-golay-generalized#options", - "children": [ - { - "type": "text", - "value": "https://github.com/mljs/savitzky-golay-generalized#options", - "position": { - "start": { - "line": 1, - "column": 47, - "offset": 46 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 47, - "offset": 46 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 105, - "offset": 104 - }, - "indent": [] - } - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.minMaxRatio" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Threshold to determine if a given peak should be considered as a noise", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 71, - "offset": 70 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 71, - "offset": 70 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "0.00025" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.broadRatio" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "If ", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "broadRatio", - "position": { - "start": { - "line": 1, - "column": 4, - "offset": 3 - }, - "end": { - "line": 1, - "column": 16, - "offset": 15 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " is higher than 0, then all the peaks which second derivative\nsmaller than ", - "position": { - "start": { - "line": 1, - "column": 16, - "offset": 15 - }, - "end": { - "line": 2, - "column": 14, - "offset": 90 - }, - "indent": [ - 1 - ] - } - }, - { - "type": "inlineCode", - "value": "broadRatio * maxAbsSecondDerivative", - "position": { - "start": { - "line": 2, - "column": 14, - "offset": 90 - }, - "end": { - "line": 2, - "column": 51, - "offset": 127 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " will be marked with the soft mask equal to true.", - "position": { - "start": { - "line": 2, - "column": 51, - "offset": 127 - }, - "end": { - "line": 2, - "column": 100, - "offset": 176 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 100, - "offset": 176 - }, - "indent": [ - 1 - ] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "0.00" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.noiseLevel" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Noise threshold in spectrum units", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 34, - "offset": 33 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "3" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.maxCriteria" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "Boolean" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Peaks are local maximum(true) or minimum(false)", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 48, - "offset": 47 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 48, - "offset": 47 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "true" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.smoothY" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "Boolean" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Select the peak intensities from a smoothed version of the independent variables", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 81, - "offset": 80 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 81, - "offset": 80 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "true" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.realTopDetection" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "Boolean" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Use a quadratic optimizations with the peak and its 3 closest neighbors\nto determine the true x,y values of the peak?", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 46, - "offset": 117 - }, - "indent": [ - 1 - ] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 2, - "column": 46, - "offset": 117 - }, - "indent": [ - 1 - ] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "false" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.heightFactor" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Factor to multiply the calculated height (usually 2)", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 53, - "offset": 52 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 53, - "offset": 52 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "0" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.boundaries" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", - "type": "link", - "children": [ - { - "type": "text", - "value": "Boolean" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Return also the inflection points of the peaks", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 47, - "offset": 46 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "false" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "options.derivativeThreshold" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - }, - { - "type": "text", - "value": "?" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Filters based on the amplitude of the first derivative", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 55, - "offset": 54 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 55, - "offset": 54 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " (optional, default " - }, - { - "type": "inlineCode", - "value": "0" - }, - { - "type": "text", - "value": ")" - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", - "type": "link", - "children": [ - { - "type": "text", - "value": "Array" - } - ] - }, - { - "type": "text", - "value": "<" - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - }, - { - "type": "text", - "value": ">" - } - ] - }, - { - "type": "text", - "value": " " - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/meta.input.js b/test/fixture/sync/meta.input.js deleted file mode 100644 index 9718fbee9..000000000 --- a/test/fixture/sync/meta.input.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This function has a lot of metadata - * @version 1.2.0 - * @author Jim Jones - * @copyright John Jones - * @since 1962 - * @license Public Domain - */ -function dewey(a) { - return a; -} diff --git a/test/fixture/sync/meta.output.json b/test/fixture/sync/meta.output.json deleted file mode 100644 index cdd66e0fc..000000000 --- a/test/fixture/sync/meta.output.json +++ /dev/null @@ -1,183 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function has a lot of metadata", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 36, - "offset": 35 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 36, - "offset": 35 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 36, - "offset": 35 - } - } - }, - "tags": [ - { - "title": "version", - "description": "1.2.0", - "lineNumber": 2 - }, - { - "title": "author", - "description": "Jim Jones", - "lineNumber": 3 - }, - { - "title": "copyright", - "description": "John Jones", - "lineNumber": 4 - }, - { - "title": "since", - "description": "1962", - "lineNumber": 5 - }, - { - "title": "license", - "description": "Public Domain", - "lineNumber": 6 - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 9, - "column": 0 - }, - "end": { - "line": 11, - "column": 1 - } - } - }, - "errors": [], - "version": "1.2.0", - "author": "Jim Jones", - "copyright": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "John Jones", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - }, - "since": "1962", - "license": "Public Domain", - "name": "dewey", - "kind": "function", - "params": [ - { - "title": "param", - "name": "a", - "lineNumber": 9 - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "dewey", - "kind": "function" - } - ], - "namespace": "dewey" - } -] \ No newline at end of file diff --git a/test/fixture/sync/meta.output.md b/test/fixture/sync/meta.output.md deleted file mode 100644 index 817bb6a52..000000000 --- a/test/fixture/sync/meta.output.md +++ /dev/null @@ -1,21 +0,0 @@ - - -### Table of Contents - -- [dewey](#dewey) - -## dewey - -This function has a lot of metadata - -**Parameters** - -- `a` - -**Meta** - -- **version**: 1.2.0 -- **since**: 1962 -- **copyright**: \[object Object] -- **author**: Jim Jones -- **license**: Public Domain diff --git a/test/fixture/sync/meta.output.md.json b/test/fixture/sync/meta.output.md.json deleted file mode 100644 index 3302e7e02..000000000 --- a/test/fixture/sync/meta.output.md.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "dewey" - } - ], - "data": { - "id": "dewey", - "htmlAttributes": { - "id": "dewey" - }, - "hProperties": { - "id": "dewey" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function has a lot of metadata", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 36, - "offset": 35 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 36, - "offset": 35 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "a" - }, - { - "type": "text", - "value": " " - }, - { - "type": "text", - "value": " " - } - ] - } - ] - } - ] - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Meta" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "version" - } - ] - }, - { - "type": "text", - "value": ": 1.2.0" - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "since" - } - ] - }, - { - "type": "text", - "value": ": 1962" - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "copyright" - } - ] - }, - { - "type": "text", - "value": ": [object Object]" - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "author" - } - ] - }, - { - "type": "text", - "value": ": Jim Jones" - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "license" - } - ] - }, - { - "type": "text", - "value": ": Public Domain" - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/multiexample.input.js b/test/fixture/sync/multiexample.input.js deleted file mode 100644 index 88227f4df..000000000 --- a/test/fixture/sync/multiexample.input.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This function returns the number one. - * @returns {Number} numberone - * @example - * foo(1); - * @example - * foo(2); - * @throws {Error} if you give it something - * @throws {TypeError} if you give it something else - * @augments Foo - * @augments Bar - */ -module.exports = function () { - // this returns 1 - return 1; -}; diff --git a/test/fixture/sync/multiexample.output.json b/test/fixture/sync/multiexample.output.json deleted file mode 100644 index f9ee47492..000000000 --- a/test/fixture/sync/multiexample.output.json +++ /dev/null @@ -1,348 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number one.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 38, - "offset": 37 - } - } - }, - "tags": [ - { - "title": "returns", - "description": "numberone", - "lineNumber": 2, - "type": { - "type": "NameExpression", - "name": "Number" - } - }, - { - "title": "example", - "description": "foo(1);", - "lineNumber": 3 - }, - { - "title": "example", - "description": "foo(2);", - "lineNumber": 5 - }, - { - "title": "throws", - "description": "if you give it something", - "lineNumber": 7, - "type": { - "type": "NameExpression", - "name": "Error" - } - }, - { - "title": "throws", - "description": "if you give it something else", - "lineNumber": 8, - "type": { - "type": "NameExpression", - "name": "TypeError" - } - }, - { - "title": "augments", - "description": null, - "lineNumber": 9, - "type": null, - "name": "Foo" - }, - { - "title": "augments", - "description": null, - "lineNumber": 10, - "type": null, - "name": "Bar" - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 12, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 16, - "column": 2 - } - } - }, - "errors": [], - "returns": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "numberone", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - } - } - }, - "type": { - "type": "NameExpression", - "name": "Number" - } - } - ], - "examples": [ - { - "description": "foo(1);" - }, - { - "description": "foo(2);" - } - ], - "throws": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "if you give it something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - } - } - }, - "type": { - "type": "NameExpression", - "name": "Error" - } - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "if you give it something else", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 30, - "offset": 29 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 30, - "offset": 29 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 30, - "offset": 29 - } - } - }, - "type": { - "type": "NameExpression", - "name": "TypeError" - } - } - ], - "augments": [ - { - "title": "augments", - "description": null, - "lineNumber": 9, - "type": null, - "name": "Foo" - }, - { - "title": "augments", - "description": null, - "lineNumber": 10, - "type": null, - "name": "Bar" - } - ], - "name": "multiexample.input", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "multiexample.input", - "kind": "function" - } - ], - "namespace": "multiexample.input" - } -] \ No newline at end of file diff --git a/test/fixture/sync/multiexample.output.md b/test/fixture/sync/multiexample.output.md deleted file mode 100644 index 01a6fe6db..000000000 --- a/test/fixture/sync/multiexample.output.md +++ /dev/null @@ -1,26 +0,0 @@ - - -### Table of Contents - -- [multiexample.input](#multiexampleinput) - -## multiexample.input - -**Extends Foo, Bar** - -This function returns the number one. - -**Examples** - -```javascript -foo(1); -``` - -```javascript -foo(2); -``` - -- Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** if you give it something -- Throws **[TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)** if you give it something else - -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone diff --git a/test/fixture/sync/rename.input.js b/test/fixture/sync/rename.input.js deleted file mode 100644 index 16599b811..000000000 --- a/test/fixture/sync/rename.input.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Cheesoid! - * @name cheese - */ -function petrol(): string { -} diff --git a/test/fixture/sync/rename.output.json b/test/fixture/sync/rename.output.json deleted file mode 100644 index 102ddfa12..000000000 --- a/test/fixture/sync/rename.output.json +++ /dev/null @@ -1,99 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Cheesoid!", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - } - } - }, - "tags": [ - { - "title": "name", - "description": null, - "lineNumber": 2, - "name": "cheese" - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - "errors": [], - "name": "cheese", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "cheese" - } - ], - "namespace": "cheese" - } -] \ No newline at end of file diff --git a/test/fixture/sync/rename.output.md b/test/fixture/sync/rename.output.md deleted file mode 100644 index 9e9ce7fc2..000000000 --- a/test/fixture/sync/rename.output.md +++ /dev/null @@ -1,9 +0,0 @@ - - -### Table of Contents - -- [cheese](#cheese) - -## cheese - -Cheesoid! diff --git a/test/fixture/sync/rename.output.md.json b/test/fixture/sync/rename.output.md.json deleted file mode 100644 index 5fd911ea9..000000000 --- a/test/fixture/sync/rename.output.md.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "cheese" - } - ], - "data": { - "id": "cheese", - "htmlAttributes": { - "id": "cheese" - }, - "hProperties": { - "id": "cheese" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Cheesoid!", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/throws.input.js b/test/fixture/sync/throws.input.js deleted file mode 100644 index 690c20783..000000000 --- a/test/fixture/sync/throws.input.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This function returns the number plus two. - * - * @param {Number} a the number - * @returns {Number} numbertwo - * @throws {Error} if number is 3 - * @example - * var result = returnTwo(4); - * // result is 6 - */ -function returnTwo(a) { - if (a === 3) throw new Error('cannot be 3'); - // this returns a + 2 - return a + 2; -} diff --git a/test/fixture/sync/throws.output.json b/test/fixture/sync/throws.output.json deleted file mode 100644 index a3657f0d1..000000000 --- a/test/fixture/sync/throws.output.json +++ /dev/null @@ -1,315 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number plus two.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - } - } - }, - "tags": [ - { - "title": "param", - "description": "the number", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "Number" - }, - "name": "a" - }, - { - "title": "returns", - "description": "numbertwo", - "lineNumber": 4, - "type": { - "type": "NameExpression", - "name": "Number" - } - }, - { - "title": "throws", - "description": "if number is 3", - "lineNumber": 5, - "type": { - "type": "NameExpression", - "name": "Error" - } - }, - { - "title": "example", - "description": "var result = returnTwo(4);\n// result is 6", - "lineNumber": 6 - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 10, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 15, - "column": 1 - } - } - }, - "errors": [], - "params": [ - { - "name": "a", - "lineNumber": 3, - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "the number", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - }, - "type": { - "type": "NameExpression", - "name": "Number" - } - } - ], - "returns": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "numbertwo", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - } - } - }, - "type": { - "type": "NameExpression", - "name": "Number" - } - } - ], - "throws": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "if number is 3", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - "type": { - "type": "NameExpression", - "name": "Error" - } - } - ], - "examples": [ - { - "description": "var result = returnTwo(4);\n// result is 6" - } - ], - "name": "returnTwo", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "returnTwo", - "kind": "function" - } - ], - "namespace": "returnTwo" - } -] \ No newline at end of file diff --git a/test/fixture/sync/throws.output.md b/test/fixture/sync/throws.output.md deleted file mode 100644 index 379677656..000000000 --- a/test/fixture/sync/throws.output.md +++ /dev/null @@ -1,24 +0,0 @@ - - -### Table of Contents - -- [returnTwo](#returntwo) - -## returnTwo - -This function returns the number plus two. - -**Parameters** - -- `a` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number - -**Examples** - -```javascript -var result = returnTwo(4); -// result is 6 -``` - -- Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** if number is 3 - -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numbertwo diff --git a/test/fixture/sync/throws.output.md.json b/test/fixture/sync/throws.output.md.json deleted file mode 100644 index 9cfcf897b..000000000 --- a/test/fixture/sync/throws.output.md.json +++ /dev/null @@ -1,304 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "returnTwo" - } - ], - "data": { - "id": "returntwo", - "htmlAttributes": { - "id": "returntwo" - }, - "hProperties": { - "id": "returntwo" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This function returns the number plus two.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 43, - "offset": 42 - }, - "indent": [] - } - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "a" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "the number", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - }, - "indent": [] - } - } - ] - } - ] - } - ] - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Examples" - } - ] - }, - { - "lang": "javascript", - "type": "code", - "value": "var result = returnTwo(4);\n// result is 6" - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Throws " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", - "type": "link", - "children": [ - { - "type": "text", - "value": "Error" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "if number is 3", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ] - } - ] - } - ] - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "Number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "numbertwo", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/trailing-only.input.js b/test/fixture/sync/trailing-only.input.js deleted file mode 100644 index b2571bd84..000000000 --- a/test/fixture/sync/trailing-only.input.js +++ /dev/null @@ -1,7 +0,0 @@ -function fooBaz() { - return 2; -} -/** - * this is a type - * @returns {number} nothing - */ diff --git a/test/fixture/sync/trailing-only.output.json b/test/fixture/sync/trailing-only.output.json deleted file mode 100644 index cb71c4fea..000000000 --- a/test/fixture/sync/trailing-only.output.json +++ /dev/null @@ -1,163 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - "tags": [ - { - "title": "returns", - "description": "nothing", - "lineNumber": 2, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 7, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "errors": [ - { - "message": "could not determine @name for hierarchy" - } - ], - "returns": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "nothing", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - } - } - }, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - {} - ], - "namespace": "undefined" - } -] \ No newline at end of file diff --git a/test/fixture/sync/trailing-only.output.md b/test/fixture/sync/trailing-only.output.md deleted file mode 100644 index 63511b984..000000000 --- a/test/fixture/sync/trailing-only.output.md +++ /dev/null @@ -1,9 +0,0 @@ - - -### Table of Contents - -## - -this is a type - -Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** nothing diff --git a/test/fixture/sync/trailing-only.output.md.json b/test/fixture/sync/trailing-only.output.md.json deleted file mode 100644 index 4e76f746d..000000000 --- a/test/fixture/sync/trailing-only.output.md.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "" - } - ], - "data": { - "id": "", - "htmlAttributes": { - "id": "" - }, - "hProperties": { - "id": "" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "nothing", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 8, - "offset": 7 - }, - "indent": [] - } - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/trailing.input.js b/test/fixture/sync/trailing.input.js deleted file mode 100644 index 5e11b97c0..000000000 --- a/test/fixture/sync/trailing.input.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * ONE - * @returns {number} something - */ -function fooBar() { - return 1; -} -/** - * TWO - * @returns {number} something - */ -function fooBaz() { - return 2; -} -/** - * this is a type - * @class Something - */ diff --git a/test/fixture/sync/trailing.output.json b/test/fixture/sync/trailing.output.json deleted file mode 100644 index b5937fcb5..000000000 --- a/test/fixture/sync/trailing.output.json +++ /dev/null @@ -1,426 +0,0 @@ -[ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "ONE", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - } - } - }, - "tags": [ - { - "title": "returns", - "description": "something", - "lineNumber": 2, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - } - }, - "errors": [], - "returns": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - } - } - }, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "name": "fooBar", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "fooBar", - "kind": "function" - } - ], - "namespace": "fooBar" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "TWO", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - } - } - }, - "tags": [ - { - "title": "returns", - "description": "something", - "lineNumber": 2, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 11, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 12, - "column": 0 - }, - "end": { - "line": 14, - "column": 1 - } - } - }, - "errors": [], - "returns": [ - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - } - } - }, - "type": { - "type": "NameExpression", - "name": "number" - } - } - ], - "name": "fooBaz", - "kind": "function", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "fooBaz", - "kind": "function" - } - ], - "namespace": "fooBaz" - }, - { - "description": { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - "tags": [ - { - "title": "class", - "description": null, - "lineNumber": 2, - "type": null, - "name": "Something" - } - ], - "loc": { - "start": { - "line": 15, - "column": 0 - }, - "end": { - "line": 18, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 12, - "column": 0 - }, - "end": { - "line": 14, - "column": 1 - } - } - }, - "errors": [], - "kind": "class", - "name": "Something", - "members": { - "instance": [], - "static": [], - "events": [] - }, - "path": [ - { - "name": "Something", - "kind": "class" - } - ], - "namespace": "Something" - } -] \ No newline at end of file diff --git a/test/fixture/sync/trailing.output.md b/test/fixture/sync/trailing.output.md deleted file mode 100644 index 1848b96a3..000000000 --- a/test/fixture/sync/trailing.output.md +++ /dev/null @@ -1,23 +0,0 @@ - - -### Table of Contents - -- [fooBar](#foobar) -- [fooBaz](#foobaz) -- [Something](#something) - -## fooBar - -ONE - -Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** something - -## fooBaz - -TWO - -Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** something - -## Something - -this is a type diff --git a/test/fixture/sync/trailing.output.md.json b/test/fixture/sync/trailing.output.md.json deleted file mode 100644 index 4e5a2e4f2..000000000 --- a/test/fixture/sync/trailing.output.md.json +++ /dev/null @@ -1,299 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "fooBar" - } - ], - "data": { - "id": "foobar", - "htmlAttributes": { - "id": "foobar" - }, - "hProperties": { - "id": "foobar" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "ONE", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "fooBaz" - } - ], - "data": { - "id": "foobaz", - "htmlAttributes": { - "id": "foobaz" - }, - "hProperties": { - "id": "foobaz" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "TWO", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "something", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 10, - "offset": 9 - }, - "indent": [] - } - } - ] - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "Something" - } - ], - "data": { - "id": "something", - "htmlAttributes": { - "id": "something" - }, - "hProperties": { - "id": "something" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "this is a type", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - }, - "indent": [] - } - } - ] -} \ No newline at end of file diff --git a/test/fixture/sync/typedef.input.js b/test/fixture/sync/typedef.input.js deleted file mode 100644 index 2747c8de7..000000000 --- a/test/fixture/sync/typedef.input.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * A type definition. - * @name MyType - * @typedef {Object} MyType - * @property {number} prop1 - one property - * @property {string} prop2 - another property - */ - diff --git a/test/fixture/sync/typedef.output.md b/test/fixture/sync/typedef.output.md deleted file mode 100644 index 01f5eede6..000000000 --- a/test/fixture/sync/typedef.output.md +++ /dev/null @@ -1,16 +0,0 @@ - - -### Table of Contents - -- [MyType](#mytype) - -## MyType - -A type definition. - -Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - -**Properties** - -- `prop1` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** one property -- `prop2` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** another property diff --git a/test/fixture/sync/typedef.output.md.json b/test/fixture/sync/typedef.output.md.json deleted file mode 100644 index f898cfac4..000000000 --- a/test/fixture/sync/typedef.output.md.json +++ /dev/null @@ -1,244 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "html", - "value": "" - }, - { - "depth": 2, - "type": "heading", - "children": [ - { - "type": "text", - "value": "MyType" - } - ], - "data": { - "id": "mytype", - "htmlAttributes": { - "id": "mytype" - }, - "hProperties": { - "id": "mytype" - } - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A type definition.", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Type: " - }, - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", - "type": "link", - "children": [ - { - "type": "text", - "value": "Object" - } - ] - } - ] - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Properties" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "prop1" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", - "type": "link", - "children": [ - { - "type": "text", - "value": "number" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "one property", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 13, - "offset": 12 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 13, - "offset": 12 - }, - "indent": [] - } - } - ] - } - ] - }, - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "prop2" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", - "type": "link", - "children": [ - { - "type": "text", - "value": "string" - } - ] - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "another property", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 17, - "offset": 16 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 17, - "offset": 16 - }, - "indent": [] - } - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/system-import.output.json b/test/fixture/system-import.output.json index 0867306b0..5637943ad 100644 --- a/test/fixture/system-import.output.json +++ b/test/fixture/system-import.output.json @@ -85,7 +85,11 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], "returns": [ { "description": { @@ -140,12 +144,16 @@ } } }, + "title": "returns", "type": { "type": "NameExpression", "name": "number" } } ], + "sees": [], + "throws": [], + "todos": [], "name": "simple.input", "kind": "function", "members": { diff --git a/test/fixture/system-import.output.md.json b/test/fixture/system-import.output.md.json index 3413addb6..6ef343f9a 100644 --- a/test/fixture/system-import.output.md.json +++ b/test/fixture/system-import.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "simple.input" } - ], - "data": { - "id": "simpleinput", - "htmlAttributes": { - "id": "simpleinput" - }, - "hProperties": { - "id": "simpleinput" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/this-class.output.json b/test/fixture/this-class.output.json index c2fbb41fd..6441556d2 100644 --- a/test/fixture/this-class.output.json +++ b/test/fixture/this-class.output.json @@ -32,9 +32,9 @@ } } }, + "augments": [], "errors": [], - "kind": "module", - "name": "bookshelf", + "examples": [], "params": [ { "title": "param", @@ -42,6 +42,13 @@ "lineNumber": 4 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "module", + "name": "bookshelf", "members": { "instance": [], "static": [], @@ -87,9 +94,9 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "Book", + "examples": [], "params": [ { "title": "param", @@ -97,6 +104,13 @@ "lineNumber": 4 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "Book", "members": { "instance": [ { @@ -175,7 +189,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "title", "memberof": "Book", "scope": "instance", @@ -240,9 +262,9 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "BookShelf", + "examples": [], "params": [ { "title": "param", @@ -250,6 +272,13 @@ "lineNumber": 10 } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "BookShelf", "members": { "instance": [ { @@ -328,7 +357,15 @@ } } }, + "augments": [], "errors": [], + "examples": [], + "params": [], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], "name": "title", "memberof": "BookShelf", "scope": "instance", diff --git a/test/fixture/this-class.output.md.json b/test/fixture/this-class.output.md.json index 63cc89d71..e7b15ff40 100644 --- a/test/fixture/this-class.output.md.json +++ b/test/fixture/this-class.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "bookshelf" } - ], - "data": { - "id": "bookshelf", - "htmlAttributes": { - "id": "bookshelf" - }, - "hProperties": { - "id": "bookshelf" - } - } + ] }, { "type": "strong", @@ -69,16 +60,7 @@ "type": "text", "value": "Book" } - ], - "data": { - "id": "book", - "htmlAttributes": { - "id": "book" - }, - "hProperties": { - "id": "book" - } - } + ] }, { "type": "strong", @@ -125,16 +107,7 @@ "type": "text", "value": "title" } - ], - "data": { - "id": "title", - "htmlAttributes": { - "id": "title" - }, - "hProperties": { - "id": "title" - } - } + ] }, { "type": "paragraph", @@ -179,16 +152,7 @@ "type": "text", "value": "BookShelf" } - ], - "data": { - "id": "bookshelf-1", - "htmlAttributes": { - "id": "bookshelf-1" - }, - "hProperties": { - "id": "bookshelf-1" - } - } + ] }, { "type": "strong", @@ -235,16 +199,7 @@ "type": "text", "value": "title" } - ], - "data": { - "id": "title-1", - "htmlAttributes": { - "id": "title-1" - }, - "hProperties": { - "id": "title-1" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/type_application.output.json b/test/fixture/type_application.output.json index ce4194e12..50d5dcb33 100644 --- a/test/fixture/type_application.output.json +++ b/test/fixture/type_application.output.json @@ -102,11 +102,12 @@ } } }, + "augments": [], "errors": [], - "kind": "class", - "name": "Address6", + "examples": [], "params": [ { + "title": "param", "name": "address", "lineNumber": 3, "description": { @@ -176,6 +177,13 @@ } } ], + "properties": [], + "returns": [], + "sees": [], + "throws": [], + "todos": [], + "kind": "class", + "name": "Address6", "members": { "instance": [], "static": [], diff --git a/test/fixture/type_application.output.md.json b/test/fixture/type_application.output.md.json index 8b378fa26..a77cd28e9 100644 --- a/test/fixture/type_application.output.md.json +++ b/test/fixture/type_application.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "Address6" } - ], - "data": { - "id": "address6", - "htmlAttributes": { - "id": "address6" - }, - "hProperties": { - "id": "address6" - } - } + ] }, { "type": "paragraph", diff --git a/test/fixture/var-function-param-return.output.json b/test/fixture/var-function-param-return.output.json index 6e5959cb4..66d9c42c1 100644 --- a/test/fixture/var-function-param-return.output.json +++ b/test/fixture/var-function-param-return.output.json @@ -24,9 +24,9 @@ } } }, + "augments": [], "errors": [], - "name": "f", - "kind": "function", + "examples": [], "params": [ { "title": "param", @@ -38,14 +38,21 @@ } } ], + "properties": [], "returns": [ { + "title": "returns", "type": { "type": "NameExpression", "name": "boolean" } } ], + "sees": [], + "throws": [], + "todos": [], + "name": "f", + "kind": "function", "members": { "instance": [], "static": [], diff --git a/test/fixture/var-function-param-return.output.md.json b/test/fixture/var-function-param-return.output.md.json index 205b981b9..cc30bcd50 100644 --- a/test/fixture/var-function-param-return.output.md.json +++ b/test/fixture/var-function-param-return.output.md.json @@ -13,16 +13,7 @@ "type": "text", "value": "f" } - ], - "data": { - "id": "f", - "htmlAttributes": { - "id": "f" - }, - "hProperties": { - "id": "f" - } - } + ] }, { "type": "strong", diff --git a/test/format_type.js b/test/format_type.js index 570a627d5..589b68cc9 100644 --- a/test/format_type.js +++ b/test/format_type.js @@ -2,7 +2,7 @@ 'use strict'; var _formatType = require('../lib/output/util/format_type'), - createLinkerStack = require('../lib/output/util/linker_stack'), + LinkerStack = require('../lib/output/util/linker_stack'), remark = require('remark'), parse = require('doctrine').parse, test = require('tap').test; @@ -10,12 +10,12 @@ var _formatType = require('../lib/output/util/format_type'), function stringify(children) { return remark().stringify({ type: 'paragraph', - children: children + children }); } test('formatType', function (t) { - var linkerStack = createLinkerStack({}); + var linkerStack = new LinkerStack({}); var formatType = _formatType.bind(undefined, linkerStack.link); [ ['Foo', 'Foo'], diff --git a/test/lib/flow_doctrine.js b/test/lib/flow_doctrine.js index 67ce55eaa..1ba50537e 100644 --- a/test/lib/flow_doctrine.js +++ b/test/lib/flow_doctrine.js @@ -9,11 +9,10 @@ function toComment(fn, filename) { return parse({ file: filename, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - })[0]; + }, {})[0]; } - test('flowDoctrine', function (t) { var types = FLOW_TYPES.filter(function (type) { diff --git a/test/lib/git/mock_repo.js b/test/lib/git/mock_repo.js index a4b3d3fe4..0301d2d8c 100644 --- a/test/lib/git/mock_repo.js +++ b/test/lib/git/mock_repo.js @@ -1,3 +1,4 @@ +'use strict'; module.exports = { master: { '/my': { diff --git a/test/lib/github.js b/test/lib/github.js index 2d623f695..e1e0407cf 100644 --- a/test/lib/github.js +++ b/test/lib/github.js @@ -12,7 +12,7 @@ function toComment(fn, filename) { return parse({ file: filename, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - }).map(github); + }, {}).map(github); } function evaluate(fn) { @@ -23,7 +23,7 @@ test('github', function (t) { mock(mockRepo.master); - t.equal(evaluate(function () { + t.deepEqual(evaluate(function () { /** * get one * @returns {number} one @@ -31,9 +31,10 @@ test('github', function (t) { function getOne() { return 1; } - })[0].context.github, - 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8', - 'gets github url'); + })[0].context.github, { + path: 'index.js', + url: 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8' + }, 'gets github url'); mock.restore(); @@ -63,7 +64,7 @@ test('enterprise repository', function (t) { mock(mockRepo.enterprise); - t.equal(evaluate(function () { + t.deepEqual(evaluate(function () { /** * get one * @returns {number} one @@ -71,9 +72,10 @@ test('enterprise repository', function (t) { function getOne() { return 1; } - })[0].context.github, - 'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8', - 'gets github enterprise url'); + })[0].context.github, { + path: 'index.js', + url: 'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8' + }, 'gets github enterprise url'); mock.restore(); diff --git a/test/lib/hierarchy.js b/test/lib/hierarchy.js index 18f07cf2b..f17d5ff91 100644 --- a/test/lib/hierarchy.js +++ b/test/lib/hierarchy.js @@ -8,7 +8,7 @@ function toComments(fn, filename) { return parse({ file: filename || 'test.js', source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - }); + }, {}); } function evaluate(fn, callback) { diff --git a/test/lib/infer/access.js b/test/lib/infer/access.js index 76454a1c3..aa5ffd707 100644 --- a/test/lib/infer/access.js +++ b/test/lib/infer/access.js @@ -2,13 +2,13 @@ var test = require('tap').test, parse = require('../../../lib/parsers/javascript'), - inferName = require('../../../lib/infer/name')(), + inferName = require('../../../lib/infer/name'), inferAccess = require('../../../lib/infer/access'); function toComment(fn) { return parse({ source: '(' + fn.toString() + ')' - })[0]; + }, {})[0]; } function evaluate(fn, re) { diff --git a/test/lib/infer/kind.js b/test/lib/infer/kind.js index 0231f6cc1..6fd11c380 100644 --- a/test/lib/infer/kind.js +++ b/test/lib/infer/kind.js @@ -1,14 +1,14 @@ 'use strict'; /*eslint-disable no-unused-vars*/ var test = require('tap').test, - inferKind = require('../../../lib/infer/kind')(), + inferKind = require('../../../lib/infer/kind'), parse = require('../../../lib/parsers/javascript'); function toComment(fn, filename) { return parse({ file: filename, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - })[0]; + }, {})[0]; } test('inferKind', function (t) { diff --git a/test/lib/infer/membership.js b/test/lib/infer/membership.js index 746b54553..373230b68 100644 --- a/test/lib/infer/membership.js +++ b/test/lib/infer/membership.js @@ -6,9 +6,9 @@ var test = require('tap').test, function toComment(fn, file) { return parse({ - file: file, + file, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - }); + }, {}); } function pick(obj, props) { @@ -111,6 +111,7 @@ test('inferMembership - explicit', function (t) { scope: 'instance' }, 'instance object assignment'); + /* eslint object-shorthand: 0 */ t.deepEqual(pick(evaluate(function () { Foo.prototype = { /** @@ -123,6 +124,18 @@ test('inferMembership - explicit', function (t) { scope: 'instance' }, 'instance object assignment, function'); + t.deepEqual(pick(evaluate(function () { + Foo.prototype = { + /** + * Test + */ + bar() {} + }; + })[0], ['memberof', 'scope']), { + memberof: 'Foo', + scope: 'instance' + }, 'instance object assignment, shorthand function'); + t.deepEqual(pick(evaluate(function () { var Foo = { /** Test */ @@ -252,7 +265,7 @@ test('inferMembership - explicit', function (t) { t.equal(evaluate(function () { lend(/** @lends Foo */{}); - })[0], undefined, 'inferMembership - drops lends'); + })[0].memberof, undefined, 'inferMembership - drops lends'); t.end(); }); @@ -288,7 +301,7 @@ test('inferMembership - exports', function (t) { /** @module mod */ exports.foo = { /** bar */ - bar: function () {} + bar() {} }; })[1].memberof, 'mod.foo'); @@ -302,7 +315,7 @@ test('inferMembership - exports', function (t) { /** @module mod */ exports.foo.prototype = { /** bar */ - bar: function () {} + bar() {} }; })[1].memberof, 'mod.foo'); @@ -340,7 +353,7 @@ test('inferMembership - module.exports', function (t) { /** @module mod */ module.exports.foo = { /** bar */ - bar: function () {} + bar() {} }; })[1].memberof, 'mod.foo'); @@ -354,7 +367,7 @@ test('inferMembership - module.exports', function (t) { /** @module mod */ module.exports.prototype = { /** bar */ - bar: function () {} + bar() {} }; })[1].memberof, 'mod'); @@ -428,7 +441,7 @@ test('inferMembership - https://github.com/documentationjs/documentation/issues/ t.deepEqual(pick(evaluate(function () { Foo.prototype = { /** Test */ - bar: function () { + bar() { lend(); lend(); } diff --git a/test/lib/infer/name.js b/test/lib/infer/name.js index c155ba781..084a3b980 100644 --- a/test/lib/infer/name.js +++ b/test/lib/infer/name.js @@ -2,13 +2,13 @@ var test = require('tap').test, parse = require('../../../lib/parsers/javascript'), - inferName = require('../../../lib/infer/name')(); + inferName = require('../../../lib/infer/name'); function toComment(fn, file) { return parse({ - file: file, + file, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - })[0]; + }, {})[0]; } function evaluate(fn, file) { @@ -50,7 +50,7 @@ test('inferName', function (t) { // Identifier (comment attached here) // FunctionExpression /** Test */ - name: function () {} + name() {} }; }).name, 'name', 'property, function'); diff --git a/test/lib/infer/params.js b/test/lib/infer/params.js index b318918c4..b320847ab 100644 --- a/test/lib/infer/params.js +++ b/test/lib/infer/params.js @@ -2,13 +2,13 @@ var test = require('tap').test, parse = require('../../../lib/parsers/javascript'), - inferParams = require('../../../lib/infer/params')(); + inferParams = require('../../../lib/infer/params'); function toComment(fn, file) { return parse({ - file: file, + file, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - })[0]; + }, {})[0]; } function evaluate(fn, file) { diff --git a/test/lib/infer/type.js b/test/lib/infer/type.js index 6777d79dc..387ddc0c1 100644 --- a/test/lib/infer/type.js +++ b/test/lib/infer/type.js @@ -2,13 +2,13 @@ var test = require('tap').test, parse = require('../../../lib/parsers/javascript'), - inferKind = require('../../../lib/infer/kind')(), - inferType = require('../../../lib/infer/type')(); + inferKind = require('../../../lib/infer/kind'), + inferType = require('../../../lib/infer/type'); function toComment(code) { return parse({ source: code - })[0]; + }, {})[0]; } function evaluate(code) { diff --git a/test/lib/input/shallow.js b/test/lib/input/shallow.js index 2c0fef558..b9271f490 100644 --- a/test/lib/input/shallow.js +++ b/test/lib/input/shallow.js @@ -5,8 +5,7 @@ var test = require('tap').test, shallow = require('../../../lib/input/shallow'); test('shallow deps', function (t) { - shallow([path.resolve(path.join(__dirname, '../../fixture/es6.input.js'))], {}, function (err, deps) { - t.ifError(err); + shallow([path.resolve(path.join(__dirname, '../../fixture/es6.input.js'))], {}).then(deps => { t.equal(deps.length, 1); t.ok(deps[0], 'has path'); t.end(); @@ -17,8 +16,7 @@ test('shallow deps multi', function (t) { shallow([ path.resolve(path.join(__dirname, '../../fixture/es6.input.js')), path.resolve(path.join(__dirname, '../../fixture/es6.output.json')) - ], {}, function (err, deps) { - t.ifError(err); + ], {}).then(deps => { t.equal(deps.length, 2); t.ok(deps[0], 'has path'); t.end(); @@ -28,30 +26,23 @@ test('shallow deps multi', function (t) { test('shallow deps directory', function (t) { shallow([ path.resolve(path.join(__dirname, '../../fixture/html')) - ], {}, function (err, deps) { - t.ifError(err); + ], {}).then(deps => { t.equal(deps.length, 1); - t.ok(deps[0].match(/input.js/), 'is the input file'); + t.ok(deps[0].file.match(/input.js/), 'is the input file'); + t.end(); + }).catch(err => { + t.fail(err); t.end(); }); }); -test('shallow deps not found', function (t) { - t.throws(function () { - shallow([ - 'not-found-file' - ], {}); - }, 'not found'); - t.end(); -}); - test('throws on non-string or object input', function (t) { - t.throws(function () { - shallow([ - true - ], {}); - }, 'indexes should be either strings or objects'); - t.end(); + shallow([ + true + ], {}).catch(err => { + t.equal(err.message, 'Indexes should be either strings or objects'); + t.end(); + }); }); test('shallow deps literal', function (t) { @@ -61,8 +52,7 @@ test('shallow deps literal', function (t) { }; shallow([ obj - ], {}, function (err, deps) { - t.ifError(err); + ], {}).then(deps => { t.equal(deps[0], obj); t.end(); }); diff --git a/test/lib/lint.js b/test/lib/lint.js index 8b769ade5..c1464e6d3 100644 --- a/test/lib/lint.js +++ b/test/lib/lint.js @@ -9,7 +9,7 @@ function toComment(fn, filename) { return parse({ file: filename, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - })[0]; + }, {})[0]; } function evaluate(fn) { diff --git a/test/lib/load_config.js b/test/lib/load_config.js deleted file mode 100644 index 64ee5d48f..000000000 --- a/test/lib/load_config.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var test = require('tap').test, - path = require('path'), - loadConfig = require('../../lib/load_config'); - -test('loadConfig', function (t) { - - t.throws(function () { - loadConfig('DOES-NOT-EXIST'); - }); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config.json')), - { foo: 'bar' }); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config_comments.json')), - { foo: 'bar' }, 'config with comments'); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config.yaml')), - { foo: 'bar' }, 'config.yaml'); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config.yml')), - { foo: 'bar' }, 'config.yml'); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config')), - { foo: 'bar' }, 'config in yaml without extension'); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config_links.yml')), - { foo: 'hello [link](https://github.com/my/link) world' }, 'config with markdown link'); - - t.deepEqual(loadConfig(path.join(__dirname, '../config_fixture/config_file.yml')),{ - toc: [{ - name: 'snowflake', - file: path.join(__dirname, '../fixture/snowflake.md') - }] - }, 'config with file reference'); - - t.end(); -}); diff --git a/test/lib/merge_config.js b/test/lib/merge_config.js new file mode 100644 index 000000000..bab68574b --- /dev/null +++ b/test/lib/merge_config.js @@ -0,0 +1,69 @@ +'use strict'; + +var test = require('tap').test, + path = require('path'), + _ = require('lodash'), + mergeConfig = require('../../lib/merge_config'); + +test('bad config', function (t) { + mergeConfig({ config: 'DOES-NOT-EXIST' }) + .catch(err => { + t.ok(err); + t.end(); + }); +}); + +test('nc(mergeConfig)', function (t) { + + // Omit configuration from output, for simplicity + var nc = _.curryRight(_.omit, 2)(['config', 'no-package', 'parseExtension', 'project-homepage', + 'project-name', 'project-version']); + + Promise.all([ + [ + { config: path.join(__dirname, '../config_fixture/config.json') }, + { foo: 'bar' } + + ], [ + { passThrough: true, config: path.join(__dirname, '../config_fixture/config.json') }, + { foo: 'bar', passThrough: true } + + ], [ + { config: path.join(__dirname, '../config_fixture/config_comments.json') }, + { foo: 'bar' } + + ], [ + { config: path.join(__dirname, '../config_fixture/config.yaml') }, + { foo: 'bar' } + + ], [ + { config: path.join(__dirname, '../config_fixture/config.yml') }, + { foo: 'bar' } + + ], [ + { config: path.join(__dirname, '../config_fixture/config') }, + { foo: 'bar' } + + ], [ + { config: path.join(__dirname, '../config_fixture/config_links.yml') }, + { foo: 'hello [link](https://github.com/my/link) world' } + + ], [ + { config: path.join(__dirname, '../config_fixture/config_file.yml') }, + { + toc: [{ + name: 'snowflake', + file: path.join(__dirname, '../fixture/snowflake.md') + }] + } + ] + ].map(pair => + mergeConfig(Object.assign(pair[0], { 'no-package': true })) + .then(nc) + .then(res => { + t.deepEqual(res, pair[1]); + }) + )).then(res => { + t.end(); + }); +}); diff --git a/test/lib/nest.js b/test/lib/nest.js index 5b4aa286b..d05c96f19 100644 --- a/test/lib/nest.js +++ b/test/lib/nest.js @@ -8,13 +8,13 @@ function toComment(fn, filename) { return parse({ file: filename, source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - }).map(nest); + }, {}).map(nest); } test('nest params - no params', function (t) { - t.equal(toComment(function () { + t.deepEqual(toComment(function () { /** @name foo */ - })[0].params, undefined, 'no params'); + })[0].params, [], 'no params'); t.end(); }); diff --git a/test/lib/output/util/formatters.js b/test/lib/output/util/formatters.js index 4a95b72a1..04dc55429 100644 --- a/test/lib/output/util/formatters.js +++ b/test/lib/output/util/formatters.js @@ -1,3 +1,4 @@ +'use strict'; var test = require('tap').test; var formatters = require('../../../../lib/output/util/formatters')(getHref); diff --git a/test/lib/parse.js b/test/lib/parse.js index be1b7eda0..aef852939 100644 --- a/test/lib/parse.js +++ b/test/lib/parse.js @@ -21,7 +21,7 @@ function evaluate(fn, filename) { return parse({ file: filename || 'test.js', source: fn instanceof Function ? '(' + fn.toString() + ')' : fn - }); + }, {}); } function addJSDocTag(tree) { @@ -622,6 +622,7 @@ test('parse - @param', function (t) { /** @param test */ })[0].params[0], { name: 'test', + title: 'param', lineNumber: 0 }, 'name'); @@ -629,6 +630,7 @@ test('parse - @param', function (t) { /** @param {number} test */ })[0].params[0], { name: 'test', + title: 'param', type: { name: 'number', type: 'NameExpression' @@ -640,6 +642,7 @@ test('parse - @param', function (t) { /** @param {number} test - desc */ })[0].params[0], { name: 'test', + title: 'param', type: { name: 'number', type: 'NameExpression' @@ -664,6 +667,7 @@ test('parse - @prop', function (t) { /** @prop {number} test */ })[0].properties[0], { name: 'test', + title: 'property', type: { name: 'number', type: 'NameExpression' @@ -675,6 +679,7 @@ test('parse - @prop', function (t) { /** @prop {number} test - desc */ })[0].properties[0], { name: 'test', + title: 'property', type: { name: 'number', type: 'NameExpression' @@ -691,6 +696,7 @@ test('parse - @property', function (t) { /** @property {number} test */ })[0].properties[0], { name: 'test', + title: 'property', type: { name: 'number', type: 'NameExpression' @@ -702,6 +708,7 @@ test('parse - @property', function (t) { /** @property {number} test - desc */ })[0].properties[0], { name: 'test', + title: 'property', type: { name: 'number', type: 'NameExpression' @@ -741,6 +748,7 @@ test('parse - @return', function (t) { t.deepEqual(evaluate(function () { /** @return test */ })[0].returns[0], { + title: 'returns', description: remark().parse('test') }, 'description'); @@ -748,6 +756,7 @@ test('parse - @return', function (t) { /** @return {number} test */ })[0].returns[0], { description: remark().parse('test'), + title: 'returns', type: { name: 'number', type: 'NameExpression' @@ -761,6 +770,7 @@ test('parse - @returns', function (t) { t.deepEqual(evaluate(function () { /** @returns test */ })[0].returns[0], { + title: 'returns', description: remark().parse('test') }, 'description'); @@ -768,6 +778,7 @@ test('parse - @returns', function (t) { /** @returns {number} test */ })[0].returns[0], { description: remark().parse('test'), + title: 'returns', type: { name: 'number', type: 'NameExpression' diff --git a/test/lib/parsers/javascript.js b/test/lib/parsers/javascript.js index 3c7e18499..3541d357a 100644 --- a/test/lib/parsers/javascript.js +++ b/test/lib/parsers/javascript.js @@ -8,8 +8,8 @@ function toComments(source, filename, opts) { source = typeof source === 'string' ? source : '(' + source.toString() + ')'; return parse({ file: filename || 'test.js', - source: source - }, opts); + source + }, opts || {}); } test('parse - leading comment', function (t) { diff --git a/test/lib/parsers/polyglot.js b/test/lib/parsers/polyglot.js index b9378271e..dc80b2c0a 100644 --- a/test/lib/parsers/polyglot.js +++ b/test/lib/parsers/polyglot.js @@ -9,29 +9,64 @@ var test = require('tap').test, test('polyglot', function (t) { var file = path.resolve(path.join(__dirname, '../../fixture/polyglot/blend.cpp')); var result = polyglot({ - file: file, + file, source: fs.readFileSync(file, 'utf8') }); delete result[0].context.file; delete result[0].context.sortKey; t.deepEqual(result, [{ errors: [], + augments: [], + examples: [], + properties: [], + throws: [], + todos: [], + sees: [], context: { loc: { end: { column: 3, line: 40 }, start: { column: 1, line: 35 } } }, description: remark().parse('This method moves a hex to a color'), loc: { end: { column: 3, line: 40 }, start: { column: 1, line: 35 } }, - name: 'hexToUInt32Color', params: [ - { lineNumber: 3, name: 'hex', type: { name: 'string', type: 'NameExpression' } } ], + name: 'hexToUInt32Color', params: [{ + lineNumber: 3, + title: 'param', + name: 'hex', + type: { + name: 'string', + type: 'NameExpression' + }} + ], returns: [ { + title: 'returns', description: remark().parse('color'), - type: { name: 'number', type: 'NameExpression' } } ], - tags: [ { description: null, lineNumber: 2, name: 'hexToUInt32Color', title: 'name' }, - { description: null, lineNumber: 3, name: 'hex', title: 'param', type: { + type: { + name: 'number', + type: 'NameExpression' + } + } + ], + tags: [{ + description: null, + lineNumber: 2, + name: 'hexToUInt32Color', + title: 'name' + }, + { + description: null, + lineNumber: 3, + name: 'hex', + title: 'param', + type: { name: 'string', type: 'NameExpression' - } }, - { description: 'color', lineNumber: 4, title: 'returns', type: { + } + }, + { + description: 'color', + lineNumber: 4, + title: 'returns', + type: { name: 'number', type: 'NameExpression' - } } ] } ], 'polyglot parser'); + } + }]}], 'polyglot parser'); t.end(); }); diff --git a/test/lib/server.js b/test/lib/server.js index 301510830..e20808c3b 100644 --- a/test/lib/server.js +++ b/test/lib/server.js @@ -39,7 +39,7 @@ test('server - throws on bad port', function (t) { test('server', function (t) { var server = new Server(4001); t.ok(server, 'server is initialized'); - server.start(function () { + server.start().then(function () { t.test('start can be called more than once, without a callback', function (tt) { server.start(); @@ -78,7 +78,7 @@ test('server', function (t) { }); t.test('cleanup', function (tt) { - server.stop(function () { + server.stop().then(function () { tt.end(); }); }); diff --git a/test/linker.js b/test/linker.js index f3cca7c7a..3e9c6be5b 100644 --- a/test/linker.js +++ b/test/linker.js @@ -1,15 +1,16 @@ -var createLinkerStack = require('../lib/output/util/linker_stack'), +'use strict'; +var LinkerStack = require('../lib/output/util/linker_stack'), test = require('tap').test; test('linkerStack', function (t) { - var linkerStack = createLinkerStack({}); + var linkerStack = new LinkerStack({}); t.equal(linkerStack.link('string'), 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String', 'Default global resolution of string'); - t.equal(createLinkerStack({ + t.equal(new LinkerStack({ paths: { Point: 'http://geojson.org/geojson-spec.html#point' } @@ -18,7 +19,7 @@ test('linkerStack', function (t) { 'Custom hardcoded path for a GeoJSON type'); - t.equal(createLinkerStack({ + t.equal(new LinkerStack({ paths: { Image: 'http://custom.com/' } @@ -27,7 +28,7 @@ test('linkerStack', function (t) { 'Prefers config link to native.'); - var linker = createLinkerStack({ + var linker = new LinkerStack({ paths: { Image: 'http://custom.com/' } diff --git a/test/normalize.js b/test/normalize.js index e977f8d36..a55135e47 100644 --- a/test/normalize.js +++ b/test/normalize.js @@ -1,3 +1,4 @@ +'use strict'; var walk = require('../lib/walk'); module.exports = function (comments) { diff --git a/test/test.js b/test/test.js index db67a9141..e818a505a 100644 --- a/test/test.js +++ b/test/test.js @@ -35,8 +35,7 @@ function readOptionsFromFile(file) { if (fs.existsSync(path.join(__dirname, '../.git'))) { test('git option', function (t) { var file = path.join(__dirname, './fixture/simple.input.js'); - documentation.build([file], { github: true }, function (err, result) { - t.ifError(err); + documentation.build([file], { github: true }).then(result => { normalize(result); var outputfile = file.replace('.input.js', '.output.github.json'); if (UPDATE) { @@ -45,8 +44,7 @@ if (fs.existsSync(path.join(__dirname, '../.git'))) { var expect = require(outputfile); t.deepEqual(result, expect, 'produces correct JSON'); - outputMarkdown(result, {}, function (err, result) { - t.ifError(err); + outputMarkdown(result, {}).then(result => { var outputfile = file.replace('.input.js', '.output.github.md'); if (UPDATE) { fs.writeFileSync(outputfile, result, 'utf8'); @@ -61,7 +59,8 @@ if (fs.existsSync(path.join(__dirname, '../.git'))) { test('document-exported error', function (t) { var file = path.join(__dirname, 'fixture', 'document-exported-bad', 'x.js'); - documentation.build([file], { documentExported: true }, function (err, result) { + documentation.build([file], { documentExported: true }).then(result => { + }, err => { t.match(err.message, /Unable to find the value x/g, 'Produces a descriptive error'); t.end(); }); @@ -72,8 +71,7 @@ test('external modules option', function (t) { path.join(__dirname, 'fixture', 'external.input.js') ], { external: '(external|external/node_modules/*)' - }, function (err, result) { - t.ifError(err); + }).then(result => { normalize(result); var outputfile = path.join(__dirname, 'fixture', '_external-deps-included.json'); if (UPDATE) { @@ -88,8 +86,9 @@ test('external modules option', function (t) { test('bad input', function (tt) { glob.sync(path.join(__dirname, 'fixture/bad', '*.input.js')).forEach(function (file) { tt.test(path.basename(file), function (t) { - documentation.build([file], readOptionsFromFile(file), function (error, res) { + documentation.build([file], readOptionsFromFile(file)).then(res => { t.equal(res, undefined); + }).catch(error => { // make error a serializable object error = JSON.parse(JSON.stringify(error)); // remove system-specific path @@ -111,17 +110,13 @@ test('bad input', function (tt) { test('html', function (tt) { glob.sync(path.join(__dirname, 'fixture/html', '*.input.js')).forEach(function (file) { tt.test(path.basename(file), function (t) { - documentation.build([file], readOptionsFromFile(file), function (err, result) { - t.ifError(err); - outputHtml(result, null, function (err, result) { - t.ifError(err); - var clean = result.sort(function (a, b) { - return a.path > b.path; - }).filter(function (r) { - return r.path.match(/(html)$/); - }).map(function (r) { - return r.contents; - }).join('\n'); + documentation.build([file], readOptionsFromFile(file)) + .then(result => outputHtml(result, {})) + .then(result => { + var clean = result.sort((a, b) => a.path > b.path) + .filter(r => r.path.match(/(html)$/)) + .map(r => r.contents) + .join('\n'); var outputfile = file.replace('.input.js', '.output.files'); if (UPDATE) { fs.writeFileSync(outputfile, clean, 'utf8'); @@ -129,8 +124,10 @@ test('html', function (tt) { var expect = fs.readFileSync(outputfile, 'utf8'); t.deepEqual(clean, expect); t.end(); + }) + .catch(err => { + t.fail(err); }); - }); }); }); tt.end(); @@ -139,12 +136,10 @@ test('html', function (tt) { test('outputs', function (ttt) { glob.sync(path.join(__dirname, 'fixture', '*.input.js')).forEach(function (file) { ttt.test(path.basename(file), function (tt) { - documentation.build([file], readOptionsFromFile(file), function (err, result) { - tt.ifError(err); + documentation.build([file], readOptionsFromFile(file)).then(result => { tt.test('markdown', function (t) { - outputMarkdown(_.cloneDeep(result), { markdownToc: true }, function (err, result) { - t.ifError(err); + outputMarkdown(_.cloneDeep(result), { markdownToc: true }).then(result => { var outputfile = file.replace('.input.js', '.output.md'); if (UPDATE) { fs.writeFileSync(outputfile, result, 'utf8'); @@ -152,13 +147,12 @@ test('outputs', function (ttt) { var expect = fs.readFileSync(outputfile, 'utf8'); t.equal(result.toString(), expect, 'markdown output correct'); t.end(); - }); + }).catch(error => t.ifError(error)); }); if (file.match(/es6.input.js/)) { tt.test('no markdown TOC', function (t) { - outputMarkdown(_.cloneDeep(result), { markdownToc: false }, function (err, result) { - t.ifError(err); + outputMarkdown(_.cloneDeep(result), { markdownToc: false }).then(result => { var outputfile = file.replace('.input.js', '.output-toc.md'); if (UPDATE) { fs.writeFileSync(outputfile, result, 'utf8'); @@ -166,13 +160,12 @@ test('outputs', function (ttt) { var expect = fs.readFileSync(outputfile, 'utf8'); t.equal(result.toString(), expect, 'markdown output correct'); t.end(); - }); + }).catch(error => t.ifError(error)); }); } tt.test('markdown AST', function (t) { - outputMarkdownAST(_.cloneDeep(result), {}, function (err, result) { - t.ifError(err); + outputMarkdownAST(_.cloneDeep(result), {}).then(result => { var outputfile = file.replace('.input.js', '.output.md.json'); if (UPDATE) { fs.writeFileSync(outputfile, JSON.stringify(result, null, 2), 'utf8'); @@ -180,7 +173,7 @@ test('outputs', function (ttt) { var expect = JSON.parse(fs.readFileSync(outputfile, 'utf8')); t.deepEqual(result, expect, 'markdown AST output correct'); t.end(); - }); + }).catch(error => t.ifError(error)); }); tt.test('JSON', function (t) { @@ -206,62 +199,12 @@ test('outputs', function (ttt) { ttt.end(); }); -test('outputs - sync', function (ttt) { - glob.sync(path.join(__dirname, 'fixture/sync', '*.input.js')).forEach(function (file) { - ttt.test(path.basename(file), function (tt) { - var result = documentation.buildSync([file], readOptionsFromFile(file)); - - tt.test('markdown', function (t) { - outputMarkdown(result, { markdownToc: true }, function (err, result) { - t.ifError(err); - var outputfile = file.replace('.input.js', '.output.md'); - if (UPDATE) { - fs.writeFileSync(outputfile, result, 'utf8'); - } - var expect = fs.readFileSync(outputfile, 'utf8'); - t.equal(result.toString(), expect, 'markdown output correct'); - t.end(); - }); - }); - - tt.test('markdown AST', function (t) { - outputMarkdownAST(result, {}, function (err, result) { - t.ifError(err); - var outputfile = file.replace('.input.js', '.output.md.json'); - if (UPDATE) { - fs.writeFileSync(outputfile, JSON.stringify(result, null, 2), 'utf8'); - } - var expect = JSON.parse(fs.readFileSync(outputfile, 'utf8')); - t.deepEqual(result, expect, 'markdown AST output correct'); - t.end(); - }); - }); - - tt.test('JSON', function (t) { - normalize(result); - var outputfile = file.replace('.input.js', '.output.json'); - if (UPDATE) { - fs.writeFileSync(outputfile, JSON.stringify(result, null, 2)); - } - var expect = require(outputfile); - t.deepEqual(makePOJO(result), expect); - t.end(); - }); - - tt.end(); - }); - }); - ttt.end(); -}); - test('highlightAuto md output', function (t) { var file = path.join(__dirname, 'fixture/auto_lang_hljs/multilanguage.input.js'), hljsConfig = {hljs: {highlightAuto: true, languages: ['js', 'css', 'html']}}; - documentation.build(file, null, function (err, result) { - t.ifError(err); - outputMarkdown(result, hljsConfig, function (err, result) { - t.ifError(err); + documentation.build(file, {}).then(result => { + outputMarkdown(result, hljsConfig).then(result => { var outputfile = file.replace('.input.js', '.output.md'); if (UPDATE) { fs.writeFileSync(outputfile, result, 'utf8'); @@ -278,11 +221,8 @@ test('config', function (t) { var outputfile = path.join(__dirname, 'fixture', 'class.config.output.md'); documentation.build([file], { config: path.join(__dirname, 'fixture', 'simple.config.yml') - }, function (err, out) { - t.ifError(err); - outputMarkdown(out, {}, function (err, md) { - t.ifError(err); - + }).then(out => outputMarkdown(out, {})) + .then(md => { if (UPDATE) { fs.writeFileSync(outputfile, md); } @@ -290,16 +230,17 @@ test('config', function (t) { t.equal(md, result, 'rendered markdown is equal'); t.end(); + }) + .catch(err => { + t.fail(err); }); - }); }); test('multi-file input', function (t) { documentation.build([ path.join(__dirname, 'fixture', 'simple.input.js'), path.join(__dirname, 'fixture', 'simple-two.input.js') - ], null, function (err, result) { - t.ifError(err); + ], {}).then(result => { normalize(result); var outputfile = path.join(__dirname, 'fixture', '_multi-file-input.json'); if (UPDATE) { @@ -313,8 +254,7 @@ test('multi-file input', function (t) { test('accepts simple relative paths', function (t) { chdir(__dirname, function () { - documentation.build('fixture/simple.input.js', null, function (err, data) { - t.ifError(err); + documentation.build('test/fixture/simple.input.js', {}).then(data => { t.equal(data.length, 1, 'simple has no dependencies'); t.end(); }); @@ -323,8 +263,7 @@ test('accepts simple relative paths', function (t) { test('.lint', function (t) { chdir(__dirname, function () { - documentation.lint('fixture/simple.input.js', null, function (err, data) { - t.ifError(err); + documentation.lint('test/fixture/simple.input.js', {}).then(data => { t.equal(data, '', 'outputs lint information'); t.end(); }); @@ -333,7 +272,7 @@ test('.lint', function (t) { test('.lint with bad input', function (t) { chdir(__dirname, function () { - documentation.lint('fixture/bad/syntax.input.js', null, function (err, data) { + documentation.lint('test/fixture/bad/syntax.input.js', {}).catch(err => { t.ok(err, 'returns an error when syntax is incorrect'); t.end(); }); diff --git a/test/utils.js b/test/utils.js index e9b075614..539bf347e 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,3 +1,4 @@ +'use strict'; var http = require('http'), concat = require('concat-stream');