From e73dd982a72cf110fd491df96059f7211aba5479 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 9 Aug 2017 00:28:19 +0300 Subject: [PATCH] chore: Updated Flow.js dependency on 0.52.0 (#862) --- package.json | 6 +++--- src/commands/readme.js | 19 +++++++++++-------- src/extractors/exported.js | 2 +- src/parse.js | 7 ++++--- src/parsers/javascript.js | 2 +- src/smart_glob.js | 7 ++++--- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 584138d61..b10ba4377 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "eslint": "^4.1.1", "eslint-config-prettier": "^2.3.0", "eslint-plugin-flowtype": "^2.34.1", - "flow-bin": "^0.46.0", + "flow-bin": "^0.52.0", "fs-extra": "^4.0.0", "husky": "^0.14.0", "jest": "^20.0.4", @@ -102,7 +102,7 @@ "precommit": "lint-staged --verbose", "prepublish": "npm run build", "format": "prettier --write '{src,__tests__,declarations,bin,default_theme}/**/*.js' --single-quote", - "doc": "./bin/documentation.js build src/index.js -f md --access=public > docs/NODE_API.md", + "doc": "node ./bin/documentation.js build src/index.js -f md --access=public > docs/NODE_API.md", "self-lint": "node ./bin/documentation.js lint src", "test": "npm run build && eslint . && are-we-flow-yet src && flow check && jest", "test-ci": "npm run build && eslint . && are-we-flow-yet src && flow check && jest --runInBand" @@ -139,4 +139,4 @@ "yargs" ] } -} +} \ No newline at end of file diff --git a/src/commands/readme.js b/src/commands/readme.js index 81176c29b..ada303bb6 100644 --- a/src/commands/readme.js +++ b/src/commands/readme.js @@ -17,7 +17,8 @@ module.exports.description = 'inject documentation into your README.md'; * @private */ module.exports.builder = { - usage: 'Usage: documentation readme [--readme-file=README.md] --section "API"' + + 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': { @@ -26,12 +27,14 @@ module.exports.builder = { }, section: { alias: 's', - describe: 'The section heading after which to inject generated documentation', + describe: + 'The section heading after which to inject generated documentation', required: true }, 'diff-only': { alias: 'd', - describe: 'Instead of updating the given README with the generated documentation,' + + describe: + 'Instead of updating the given README with the generated documentation,' + ' just check if its contents match, exiting nonzero if not.', default: false }, @@ -42,8 +45,6 @@ module.exports.builder = { } }; -function noop() {} - /** * Insert API documentation into a Markdown readme * @private @@ -68,9 +69,11 @@ module.exports.handler = function readme(argv: Object) { argv.format = 'remark'; /* eslint no-console: 0 */ - var log = argv.q - ? noop - : console.log.bind(console, '[documentation-readme] '); + const log: Function = (...data: Array) => { + if (!argv.q) { + console.log.apply(console, data); + } + }; var readmeContent = fs.readFileSync(argv.readmeFile, 'utf8'); diff --git a/src/extractors/exported.js b/src/extractors/exported.js index e9be88a44..6d36eea6b 100644 --- a/src/extractors/exported.js +++ b/src/extractors/exported.js @@ -184,7 +184,7 @@ function getCachedData(dataCache, filePath) { var value = dataCache.get(path); if (!value) { var input = fs.readFileSync(path, 'utf-8'); - var ast = parseToAst(input, path); + var ast = parseToAst(input); value = { data: { file: path, diff --git a/src/parse.js b/src/parse.js index 49b60d4de..048da3c8b 100644 --- a/src/parse.js +++ b/src/parse.js @@ -414,9 +414,10 @@ function todo() {} * @param {string} key the eventual destination key * @returns {Function} a flattener that remembers that key */ -function synonym(key) { - return function(result, tag) { - return flatteners[key](result, tag, key); +function synonym(key: string) { + return function(result: Object, tag: Object) { + const fun = flatteners[key]; + fun.apply(null, [result, tag, key].slice(0, fun.length)); }; } diff --git a/src/parsers/javascript.js b/src/parsers/javascript.js index 30690d1d3..7b2157bda 100644 --- a/src/parsers/javascript.js +++ b/src/parsers/javascript.js @@ -37,7 +37,7 @@ function leftPad(str, width) { function parseJavaScript(data: Object, config: DocumentationConfig) { var visited = new Set(); - var ast = parseToAst(data.source, data.file); + var ast = parseToAst(data.source); var addComment = _addComment.bind(null, visited); return _.flatMap( diff --git a/src/smart_glob.js b/src/smart_glob.js index 8dc026b88..64122caf6 100644 --- a/src/smart_glob.js +++ b/src/smart_glob.js @@ -86,7 +86,8 @@ function resolveFileGlobPatterns(patterns, extensions) { * @returns Resolved absolute filenames. */ function listFilesToProcess(globPatterns: Array): Array { - var files = [], added = new Set(); + var files = [], + added = new Set(); var cwd = process.cwd(); @@ -107,7 +108,7 @@ function listFilesToProcess(globPatterns: Array): Array { globPatterns.forEach(function(pattern) { var file = path.resolve(cwd, pattern); if (shell.test('-f', file)) { - addFile(fs.realpathSync(file), !shell.test('-d', file)); + addFile(fs.realpathSync(file)); } else { var globOptions = { nodir: true, @@ -116,7 +117,7 @@ function listFilesToProcess(globPatterns: Array): Array { }; glob.sync(pattern, globOptions).forEach(function(globMatch) { - addFile(path.resolve(cwd, globMatch), false); + addFile(path.resolve(cwd, globMatch)); }); } });