runem / web-component-analyzer

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

Exports list non-exported items (json2) #186

Open thepassle opened 4 years ago

thepassle commented 4 years ago

Given the following example:

class Foo extends HTMLElement {
  __foo() {
  }
}

const bar = klass => class SomethingMixin extends klass {
  __bar(){
  }
}

/**
 * A text field web component
 * @attr {Boolean} disabled - Disables this element
 * @fires change - Dispatched when the text of the text field changes
 * @slot - Default content placed inside of the text field
 * @slot header - Content placed in the header of the text field
 * @cssprop --placeholder-color - Controls the color of the placeholder
 * @csspart placeholder - Placeholder css shadow part
 */
export class TextField extends bar(Foo) {
  /**
   * Size of the text field
   * @attr
   * @type {"small"|"large"}
   */
  size = "large";

  constructor() {
    super();
    this.value = "";
  }

  static get observedAttributes() {
    return ["placeholder"];
  }

  onEnterKey() {
    /**
     * Dispatched when the enter key is pressed
     */
    this.dispatchEvent(new CustomEvent("enter"));
  }
}

customElements.define("text-field", TextField);

The exports field will list:

"exports": [
        {
          "kind": "class",
          "name": "bar"
        },
        {
          "kind": "class",
          "superclass": {
            "name": "HTMLElement"
          },
          "name": "Foo"
        }
]

Even though neither bar nor Foo are technically exported