Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Node.js API with source instead of the input file broken #1057

Closed
bodia-uz opened this issue Apr 23, 2018 · 3 comments · Fixed by #1058
Closed

Node.js API with source instead of the input file broken #1057

bodia-uz opened this issue Apr 23, 2018 · 3 comments · Fixed by #1058

Comments

@bodia-uz
Copy link
Contributor

Commit f60d90c breaks ability to use Node.js API with source instead of the input file.

Or more precisely next lines:

documentation/src/index.js

Lines 108 to 110 in f60d90c

if (path.extname(sourceFile.file) === '.vue') {
return parseVueScript(sourceFile, config).map(buildPipeline);
}

  • What version of documentation.js are you using?:
    6.3.0
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?):
    Node.js API
documentation.build([{ source: documentationSource }], { shallow: true })

Error:

[08:26:34][npm test]     TypeError: Path must be a string. Received undefined
[08:26:34][npm test]       
[08:26:34][npm test]       at node_modules/documentation/lib/index.js:97:14
[08:26:34][npm test]       at arrayMap (node_modules/lodash/lodash.js:631:23)
[08:26:34][npm test]       at map (node_modules/lodash/lodash.js:9546:14)
[08:26:34][npm test]       at Function.flatMap (node_modules/lodash/lodash.js:9249:26)
[08:26:34][npm test]       at buildInternal (node_modules/documentation/lib/index.js:92:31)
bodia-uz referenced this issue Apr 23, 2018
Thanks to @batje, documentation.js now supports Vue! .vue files are parsed for their JavaScript contents by default.
@batje
Copy link
Contributor

batje commented Apr 23, 2018

if ((typeof sourceFile.file !== 'undefined') && (path.extname(sourceFile.file) === '.vue')) {

should do the trick for now. Let me see if I can write a test to reproduce your problem and test my solution.

@bodia-uz
Copy link
Contributor Author

It should. Thanks @batje

@bodia-uz
Copy link
Contributor Author

Mb better condition will be:

if (typeof sourceFile.file === 'string' && path.extname(sourceFile.file) === '.vue') {}

batje added a commit to CognosExt/documentation that referenced this issue Apr 23, 2018
tmcw pushed a commit that referenced this issue Apr 23, 2018
* fix: adding vue support broke tests that are not file based

fix #1057

* Got the tests and code working for supporting non-file documenting

* Added fresh snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants