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

Class that has superclasses doesnt appear in output #192

Open thepassle opened 4 years ago

thepassle commented 4 years ago

Given:

import { SuperD } from './SuperD.js';

class C extends SuperD {
    ccc = 'c';
}

customElements.define('c-c', C);

where SuperD.js looks like:

import { SuperB } from './SuperB.js'; // same as SuperD, just different name

export class SuperD extends SuperB {
  superd = 'd';
}

In the custom-elements.json output, I only get the definition:

{
      "path": "./dev/src/custom-element/c-c.js",
      "exports": [
        {
          "kind": "definition",
          "name": "c-c",
          "declaration": {
            "name": "C",
            "module": "./dev/src/custom-element/c-c.js"
          }
        }
      ]
    }

I would also expect the C class to be present in my custom-elements.json

thepassle commented 4 years ago

I guess this is happening because

class C extends SuperD {
  ccc = 'c';
}

isnt exported. But this means there is no way for me to get the information of class C if I write my code like:

class C extends SuperD {
  ccc = 'c';
}

customElements.define('c-c', C);

While I think its good practice to separate class definitions from the custom elements definition, I still think this should be supported because there'll be a lot of code thats written like this

justinfagnani commented 4 years ago

@thepassle this is one of the things I mentioned in https://github.com/webcomponents/custom-elements-json/pull/9#issuecomment-699042840

We should separate declarations from exports so that SuperD can be documented.

thepassle commented 4 years ago

SuperD in that example actually is present in the output, the problem is:

import { SuperD } from './SuperD.js';`

class C extends SuperD {
  ccc = 'c';
}

customElements.define('c-c', C);

There is only a definition for C, but the actual classdoc (and any fields etc) is missing from the output custom-elements.json