Skip to content

Commit

Permalink
chore: Updated Flow.js dependency on 0.52.0 (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-redFox authored and tmcw committed Aug 8, 2017
1 parent aa3496a commit e73dd98
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -139,4 +139,4 @@
"yargs"
]
}
}
}
19 changes: 11 additions & 8 deletions src/commands/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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
},
Expand All @@ -42,8 +45,6 @@ module.exports.builder = {
}
};

function noop() {}

/**
* Insert API documentation into a Markdown readme
* @private
Expand All @@ -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<string>) => {

This comment has been minimized.

Copy link
@tmcw

tmcw Aug 12, 2017

Member

Unfortunately my review & our CI setup let this slip through: Node v4 doesn't support parameter rest syntax and our Babel transform doesn't transpile it. I'm going to update this section to maintain v4 compatibility. Down the line we could use babel-preset-env or something to transpile new JS features, but going down that rabbit hole was nothing but a trainwreck when I tried it yesterday.

This comment has been minimized.

Copy link
@tmcw

tmcw Aug 12, 2017

Member

It looks like async tests also won't work in Node v4 with our current setup, so I'm adding the es2015 transform in, in an effort to make things work. Ideally, though, well, I can get a time machine and just keep documentation.js vanilla non-transpiled JavaScript, or buy a time machine forward and cut Node v4 support and only rely on native features.

if (!argv.q) {
console.log.apply(console, data);
}
};

var readmeContent = fs.readFileSync(argv.readmeFile, 'utf8');

Expand Down
2 changes: 1 addition & 1 deletion src/extractors/exported.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions src/smart_glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function resolveFileGlobPatterns(patterns, extensions) {
* @returns Resolved absolute filenames.
*/
function listFilesToProcess(globPatterns: Array<string>): Array<string> {
var files = [], added = new Set();
var files = [],
added = new Set();

var cwd = process.cwd();

Expand All @@ -107,7 +108,7 @@ function listFilesToProcess(globPatterns: Array<string>): Array<string> {
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,
Expand All @@ -116,7 +117,7 @@ function listFilesToProcess(globPatterns: Array<string>): Array<string> {
};

glob.sync(pattern, globOptions).forEach(function(globMatch) {
addFile(path.resolve(cwd, globMatch), false);
addFile(path.resolve(cwd, globMatch));
});
}
});
Expand Down

0 comments on commit e73dd98

Please sign in to comment.