documentationjs / documentationjs/documentation

Lint and build break on documented class properties declared in constructor

Open
#1,617 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.8k
Forks
481
PR merge metrics
No merged PRs in 30d

Description

**If you're reporting a bug, please include _input code_, _output documentation_,
a description of what you expected to happen, and what happened instead.**

* What version of documentation.js are you using?:
* v14.0.2
* How are you running documentation.js (on the CLI, Node.js API, Grunt, other?):
* Node, tested with both `documentation.build()` and `documentation.lint()`, same error on both.

### Error
Running either `documentation.build()` or `documentation.lint()` on [this file](https://github.com/processing/p5.js/blob/main/src/core/p5.Element.js) throws an error:
```
scope.path.parentPath.parentPath.node.id.name,
^
TypeError: Cannot read properties of null (reading 'name')
at ThisExpression (file:///Users/stalgia/Desktop/Work/p5-scratch-pad/node_modules/documentation/src/infer/membership.js:98:52)
at NodePath._call (/Users/stalgia/Desktop/Work/p5-scratch-pad/node_modules/@babel/traverse/lib/path/context.js:46:20)
```

### Expectation

That these functions will run without throwing errors.

This seems to be an issue with [the documentation of the properties declared inside of the constructor](https://github.com/processing/p5.js/blob/main/src/core/p5.Element.js#L55-L98). Removing those comments allows both linting and building to work as expected. I understand that this style of inline docs for classes is not recommended but it should be possible to lint without throwing an error on this.

We are evaluating options for replacing our current inline doc parser and this issue is a blocker for documentation.js.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.