Skip to content

Docs for a class couldn't be generated after require statements #795

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

Closed
niklauslee opened this issue Jun 4, 2017 · 7 comments
Closed

Docs for a class couldn't be generated after require statements #795

niklauslee opened this issue Jun 4, 2017 · 7 comments

Comments

@niklauslee
Copy link

Successfully generates docs for the following code:

/**
 * A table object
 * @param {number} width
 * @param {number} height
 */
class Table {
  constructor(width, height) {
    this.width = width;
    this.height = height;
  }
}

But, just adding a require statement results that it couldn't generate docs for the Table class.

const _ = require('lodash')

/**
 * A table object
 * @param {number} width
 * @param {number} height
 */
class Table {
  constructor(width, height) {
    this.width = width;
    this.height = height;
  }
}

How can I fix this problem?

@tmcw
Copy link
Member

tmcw commented Jun 4, 2017

These examples correctly produce the same documentation in my local environment. Can you elaborate on "it couldn't produce docs": is there an error, or is it blank? What version of documentation.js are you using, and how are you invoking it?

@niklauslee
Copy link
Author

version is 4.0.0-rc1.

command I used is:

documentation build test.js -f html -o docs

Lint result is:

$ documentation lint test.js
/Users/niklaus/git/staruml-electron/test.js
  3:1  warning  could not determine @name for hierarchy

The generated docs files are attached.
docs.zip

@tmcw
Copy link
Member

tmcw commented Jun 5, 2017

Okay, so to be clearer, the issue is that the require statement causes the name Table to be lost, but the documentation for Table is still there?

@niklauslee
Copy link
Author

OK, I found the reason. The problem is resolved by adding semicolon to the last of the require statement. But, removing the semicolon causes the problem again.

I think this problem should be resolved. I'm using ESLint with JavsScript Standard Style. The standard style don't allow adding unnecessary semicolon in the last of statements.

So, please fix this problem in the next release :)

Thank you for your response.

@tmcw
Copy link
Member

tmcw commented Jun 6, 2017

I certainly hope to, and agree that this is an important issue! Might I also suggest that, as a community project, you might be interested in helping out? You can test the AST that this example generates in astexplorer.net - most likely, if the AST changes depending on that semicolon but the JavaScript's behavior is the same, the appropriate resolution would be to file a bug report and testcase upstream at babylon's repository, the JavaScript parser that documentation.js uses.

@niklauslee
Copy link
Author

I've just tested on astexplorer.net. In babylon-6.17.1 it works well. Current version of documentation is using babylon-6.11.4. So, I replaced the module by the new version babylon-6.17.1. It works well!!!. I think this problem can be resolved by just replacing the babylon by the new version.

@tmcw
Copy link
Member

tmcw commented Jun 6, 2017

Thanks for digging in! I've just pushed a yarn.lock update that points to 6.17 and will momentarily bump the minimum required version in package.json. I'll publish this as soon as I finish up the backlog for rc2.

Thanks again - makes my day to get some help on this project 💕 !

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

No branches or pull requests

2 participants