runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
502 stars 63 forks source link

[discussion] property analysis behavior is strange #112

Closed jrobinson01 closed 4 years ago

jrobinson01 commented 4 years ago

Given a plain JS lit-element like so:

/**
* @prop {boolean} myProperty - description for myProperty
*/
class MyElement extends LitElement {
    static get properties() {
        return {
           myProperty: { type: Boolean }
        }
    }
    constructor() {
        super();
        this.myProperty = false;
        this.myBoundFunction = this.someFunction.bind(this); 
    }

    someFunction() {
    }
}

The (JSON) output contains both the myProperty and myBoundFunction properties. It seems that wca is analyzing not only the jsdoc but also the component's constructor. This seems to be causing two issues. The first is that the descriptions are not present in the output, and the second is that I wouldn't expect myBoundFunction to be present in the output. I see that there is work to support @private/@protected, which may solve the latter issue.

daKmoR commented 4 years ago

imho every public property or function should be of interest as that is the public api right?

you can prefix a function with _ so the become "protected" and will not appear in the public properties list as far as I know.

you could also use the js "#myPrivateFunction"