"There are no input files to process" error from explainSync()
I am attempting to pass file contents that I retrieved by calling the GitHub API into explainSync. When I was previously reading a local file using fs.readFileSync(<file_path>).toString() and passing this into explainSync, it worked. However, now when I am doing the following, I get the error "There are no input files to process".
const sourceCode = Buffer.from(<fileContents>, 'base64').toString();
const documentationBlocks = explainSync({ source: sourceCode });
I verified that sourceCode is a string that contains the contents of the file that I wish to parse the documentation of.
I have also tried passing in a plain string to explainSync without creating a Buffer and converting it to a string, and the plain string approach gives the same error.
Does anyone know of a solution to fix this?
Hi, there's not enough context in your report - could you post a reproduction case I can run and see the issue please? You don't need to include a call to the Github API, just include the string you are passing into options.source as a string literal..
Also, which version of node and jsdoc-api are you using? Which OS?
I am using version 5.0.3 of jsdoc-api, and version 10.16.0 of node. I am developing on a Mac with the Mojave OS.
The string I am passing into options.source is the contents of a webdriverIO test file. I cannot provide the exact test file as the code is proprietary, but here is the gist of what it looks like:
const viewport = browser.options.formFactor;
const { URLS } = require('constants');
const button = '#button-1';
const errorView = '.error-view';
// FUTURE: TASK-NUM - Remove this
const ignoredA11y = { 'color-contrast': { enabled: false } };
/**
* Requirements tested
*/
describe('Workflows', () => {
/**
* @name test
* @traces 2390829304
* @traces 12091290123
* @describe Description
*/
describe('Description', () => {
before(() => {
browser.url(URLS.URL);
browser.refresh();
browser.waitForEnabled(button);
browser.click(button);
browser.waitForVisible(errorView);
});
Thing.should.matchScreenshot();
Thing.should.beAccessible({ viewport, rules: ignoredA11y });
it('does ' +
'stuff', () => {
browser.click(button);
browser.waitForVisible(errorView);
expect(browser.getText('text')).to.contain('text');
});
Thing.should.matchScreenshot();
Thing.should.beAccessible();
});
describe('Description 2', () => {
before(() => {
browser.url(URLS.URL);
browser.refresh();
});
it('does stuff 2', () => {
expect(browser.getText('text')).to.contain('text');
});
Thing.should.matchScreenshot();
Thing.should.matchScreenshot();
});
});
As for the value of <fileContents> in the code snippet in my first description, that is a Base64-encoded string like:
Y29ucyLm9wdGlvbnMuZm9ybUZhY3RvcjsK
CmNvbnN0IHsgUFxTIHPSByZXF1aXJlKCcuLiZGlvVGVz
dENvbnN0kZXItZGV0YWlscy12
aWV3LXVIvd3Nlci53YWl0Rm9yVmlz
aWJsZShzeXN01FcnJvclZpZXcpOwogICAgICBpAodmlld3BvQgPT09
ICd0wZkaW5nIG9yZGVyIHdW4g
dGhlIHVuZG8gYndG9uIGlzIGNsaWNrZWQnLoKSPiB7CiAgICAgIGlm
ICh2aWV3cG9ydCA9PTJ3RpbnknKSB7CiAgICAgIgYnJvd3Nlci5jbGlj
ayhwZW5kaW5nTwaXRvcik7CiAgICAgIH0KCiAgICAgIGJyb3ZXIud2Fp
dEZvckVuYWJsZWQocmVtblUGVuZGluZ09yZGVyQnV0dG9uKKICAgICAg
YnJvd3Nlci5jljayLCAoKSA9PiB7CiACBiZWZv
cmUoKCkgPT4gewogICAgICBicmc2VyLnVybChQUk9GSUxFVSTFMuUkVG
SUxMX0FERFNfQUxFRTX1BST0ZJTEUpOwogICAgICcm93c2VyLnJlZnJl
c2goKTsKICAgICYnJvd3Nlci53YWl0Rm9yRW5hYlZChsaXBpdG9yVG9S
ZWZpbGwpOwICAgICBicm93c2VyLmNsaWNrKGxpcGl0b3b1JlZmlsbCk7
CgdmFsdWICc1MDAnIH0pogICAgICBicm93
c2VyLmNsaWNrKHJmlVGVy
cmEuc2hvxkLmJlQWNjZXNzaWJsZSgpOwIH0pOwp9KTsK
I'm sorry, I can't reproduce your issue. On node v10 on macOS I get the expected output. This is the reproduction case I ran:
const jsdocApi = require('jsdoc-api')
const source = `const viewport = browser.options.formFactor;
const { URLS } = require('constants');
const button = '#button-1';
const errorView = '.error-view';
// FUTURE: TASK-NUM - Remove this
const ignoredA11y = { 'color-contrast': { enabled: false } };
/**
* Requirements tested
*/
describe('Workflows', () => {
/**
* @name test
* @traces 2390829304
* @traces 12091290123
* @describe Description
*/
describe('Description', () => {
before(() => {
browser.url(URLS.URL);
browser.refresh();
browser.waitForEnabled(button);
browser.click(button);
browser.waitForVisible(errorView);
});
Thing.should.matchScreenshot();
Thing.should.beAccessible({ viewport, rules: ignoredA11y });
it('does ' +
'stuff', () => {
browser.click(button);
browser.waitForVisible(errorView);
expect(browser.getText('text')).to.contain('text');
});
Thing.should.matchScreenshot();
Thing.should.beAccessible();
});
describe('Description 2', () => {
before(() => {
browser.url(URLS.URL);
browser.refresh();
});
it('does stuff 2', () => {
expect(browser.getText('text')).to.contain('text');
});
Thing.should.matchScreenshot();
Thing.should.matchScreenshot();
});
});`
const documentationBlocks = jsdocApi.explainSync({ source });
console.log(documentationBlocks)
// correct output is printed
I suspect your issue might not be directly related to jsdoc-api.
Please post some code which fails every time on your system. Please post the full script, not just snippets - I need a reproduction case, a complete script (like what I posted above) that can be run as supplied. I don't need to see all your propritary file content, just example file content would be enough so long as it fails every time, highlighting the issue.
I actually just ran the exact reproduction case that you responded with and got the same error.
that's odd.. could you try uninstalling then reinstalling all your deps please?
I think I found the problem. The problem that I was having is that on my computer, the name of the folder that the temporary file was placed into started with an underscore. The default options of JSDoc are to exclude folders and files that begin with an underscore. A workaround to fix the issue was to create a JSDoc configuration file that allowed files and folders to begin with an underscore, and then pass that as the "configure" option to the API. A recommendation would be to possibly override the exclude pattern by default.
oh, i see! So your system temp dir begins with an underscore?
You can view your tmpdir like this on the node REPL:
> os.tmpdir()
'/var/folders/z2/1d63yd8x4yx5vnbnknzxvyw80000gn/T'
I don't know how system tmp dirs are named but if there is a possibility of them beginning with _ I should look into it..
Right, this is what that path to the temporary file looked like:
/var/folders/_9/nl_3vwh14lx9325r9cn6s08s96pd8g/T/mgyzm6w9alb582old8pnle.js
I think it just so happened that after the last reboot of my computer, it started having an underscore in that folder name. But the name should change every time you reboot your system, so that's probably why it was working for me in the past.
I searched the jsdoc repo and found several issues caused by this leading underscore behaviour, but they were all closed without resolution. I've opened a new issue and will let you know if I hear anything back. If I don't hear anything back I'll consider a different fix.
Thanks for your patience with this, let me know if you find anything else.
I can confirm this issue as well in macOS Catalina. Thank you for the workaround @juliacalandro you saved me hours of debugging! <3
And thank you @75lb for your good work!
We had to implement the workaround since we can't wait for the issue to be solved from the jsdoc team. Contributing with a gist here that automatically implements the solution provided by @juliacalandro https://gist.github.com/devtin/5ec0b681a0bbad57f18f0774c4ab0973