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

"There are no input files to process" error from explainSync() #19

Open
juliacalandro opened this issue Oct 10, 2019 · 12 comments
Open

Comments

@juliacalandro
Copy link

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?

@75lb
Copy link
Member

75lb commented Oct 11, 2019

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?

@juliacalandro
Copy link
Author

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

@75lb
Copy link
Member

75lb commented Oct 13, 2019

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.

@75lb
Copy link
Member

75lb commented Oct 13, 2019

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.

@juliacalandro
Copy link
Author

I actually just ran the exact reproduction case that you responded with and got the same error.

@75lb
Copy link
Member

75lb commented Oct 14, 2019

that's odd.. could you try uninstalling then reinstalling all your deps please?

@juliacalandro
Copy link
Author

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.

@75lb
Copy link
Member

75lb commented Oct 15, 2019

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..

@juliacalandro
Copy link
Author

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.

@75lb
Copy link
Member

75lb commented Oct 16, 2019

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.

@devtin
Copy link

devtin commented Nov 22, 2019

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!

@devtin
Copy link

devtin commented Nov 22, 2019

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

instructure-gerrit pushed a commit to instructure/instructure-ui that referenced this issue Aug 6, 2020
JSDoc was [failing](jsdoc2md/jsdoc-api#19) while attempting to read a temp file written to a directory beginning with an underscore. This resulted in several docs being marked as "uncategorized" and appearing at the root level of the sidebar navigation in the docs app. This fix overwrites the default configuration for JSDoc, as documented [here](https://jsdoc.app/about-configuring-jsdoc.html)

TEST PLAN:
- Load the docs and make sure no docs appear at the root level of the sidebar navigation
- Make sure docs appear under the "Utilities" menu item, and nested properly under sub-categories.

Closes: INST-2696
Change-Id: Id2ae089063a0949e42cb3c62330ce8d64e470b3a
Reviewed-on: https://gerrit.instructure.com/c/instructure-ui/+/244179
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Bence Toppanto <bence.toppanto@instructure.com>
QA-Review: Daniel Sasaki <dsasaki@instructure.com>
Product-Review: Chris Guerrero <cguerrero@instructure.com>
Visual-Regression-Test: Chris Guerrero <cguerrero@instructure.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants