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

Multiple mixins output #195

Open thepassle opened 4 years ago

thepassle commented 4 years ago

Given the following code:

export const BarMixin = klass => class BarMixin extends klass {}
export const FooMixin = klass => class FooMixin extends BarMixin(klass) {}

export class MyComponent extends FooMixin(HTMLElement) {

}

The output custom-elements.json looks like this:

custom-elements.json ```json { "kind": "class", "superclass": { "name": "HTMLElement" }, "mixins": [ { "name": "FooMixin", "module": "./dev/src/custom-element/MyComponent.js" } ], "name": "MyComponent", "tagName": "my-component" }, { "kind": "class", "mixins": [ { "name": "BarMixin", "module": "./dev/src/custom-element/MyComponent.js" } ], "name": "FooMixin" }, { "kind": "class", "name": "BarMixin" }, { "kind": "variable", "name": "BarMixin", "type": "(klass: any) => typeof BarMixin" }, { "kind": "variable", "name": "FooMixin", "type": "(klass: any) => typeof FooMixin" } ] ```

The output here seems... off:

        {
          "kind": "class",
          "mixins": [
            {
              "name": "BarMixin",
              "module": "./dev/src/custom-element/MyComponent.js"
            }
          ],
          "name": "FooMixin"
        },

Maybe we should allow a mixin to have a nested mixins field? Something like:

{
  "kind": "variable",
  "name": "FooMixin",
  "type": "(klass: any) => typeof FooMixin",
  "mixins": {
    "name": "BarMixin",
    "module": "./dev/src/custom-element/MyComponent.js"
  }
}