Skip to content

[BUG] Allow custom decorators along with @Component #868

Closed

Description

@juanmendes
Overview of the issue

When using a custom decorator on a class already decorated with @Component(), compodoc does not read its angular specific properties

The following component does not output its @Inputs and @Outputs because of the extra @Example decorator

@Example({path: "combo-box"})
@Component({...})
export class ComboBox {
  @Input() prop = "value";
}
Workaround

Make sure @Component() is the first in the decorator chain

@Component({...})
@Example({path: "combo-box"})
export class ComboBox {
  @Input() prop = "value";
}
Operating System, Node.js, npm, compodoc version(s)

Not OS specific, using compodoc version 1.1.11.

Angular configuration, a package.json file in the root folder
{
  "name": "vcd-ui-common",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "lint-fix": "tslint --fix \"src/**/*.ts\" --exclude \"src/main/*.ts\"",
    "compodoc": "compodoc src/components/ -p tsconfig.json -e json"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "8.2.8",
    "@angular/common": "8.2.8",
    "@angular/compiler": "8.2.8",
    "@angular/core": "8.2.8",
    "@angular/forms": "8.2.8",
    "@angular/platform-browser": "8.2.8",
    "@angular/platform-browser-dynamic": "8.2.8",
    "@angular/router": "8.2.8",
    "@clr/angular": "2.2.1",
    "@clr/ui": "2.2.1",
    "@clr/icons": "2.2.1",
    "rxjs": "6.4.0",
    "tslib": "1.10.0",
    "zone.js": "0.9.1",
    "@webcomponents/custom-elements": "1.0.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.803.9",
    "@angular/cli": "8.3.9",
    "@angular/compiler-cli": "8.2.8",
    "@angular/language-service": "8.2.8",
    "@compodoc/compodoc": "1.1.11",
    "@types/jasmine": "3.3.8",
    "@types/jasminewd2": "2.0.3",
    "@types/node": "8.9.4",
    "codelyzer": "5.0.0",
    "husky": "3.0.9",
    "jasmine-core": "3.4.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.1",
    "karma-jasmine": "2.0.1",
    "karma-jasmine-html-reporter": "1.4.0",
    "prettier": "1.18.2",
    "pretty-quick": "2.0.0",
    "protractor": "5.4.0",
    "ts-node": "7.0.0",
    "tslint": "5.15.0",
    "typescript": "3.5.3"
  }
}
Compodoc installed globally or locally ?

Locally, run through npm run compodoc

If possible sourcecode of the file where it breaks

Doesn't break, just doesn't recognize @Component

If possible your terminal logs before the error
Motivation for or Use Case

I am creating an angular examples app that uses annotations to register components to be showcased.

Reproduce the error

Using the sample component above, run compodoc -e json and notice that the output does not show anything for the components["ComboBox"]inputsClass array

Related issues

Did not find any

Suggest a Fix

It looks like the code that parses the annotations needs to look at all the annotation for a class, not just the first one.

See

if (classDeclaration.decorators) {

The loop over decorators for a class only ever looks at the first one. If it's not a directive/component/pipe it just treats it as a regular class without ever checking the other attributes

Activity

  1. juanmendes commented on Nov 14, 2019

    @juanmendes
    Author

    I know the guidelines said to create a branch and a merge request but I was not allowed to push to a custom branch in compodoc so I created a PR. #872

  2. pburgmer commented on Nov 20, 2019

    @pburgmer

    Same happens if I decorate a pipe with @pipe and @Injectable. Compodoc then ignores the pipe decorator and only generates the documentation for the injectable. There is a link in the menu for the pipe, but I get an 404

  3. juanmendes commented on Nov 25, 2019

    @juanmendes
    Author

    @pburgmer My fix wouldn't fix that, it just ignores unrecognized decorators. It does not add support for two angular decorators. As much as it's kind of related, it probably deserves its own issue.

  4. stale commented on Jan 24, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  5. juanmendes commented on Jan 30, 2020

    @juanmendes
    Author

    Not stale, there's a pending PR

  6. stale commented on Mar 30, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  7. stale commented on Apr 6, 2020

    @stale

    This issue has been automatically closed because it has not had recent activity. Please file a new issue if you are encountering a similar or related problem. Thank you for your contributions.

  8. lock commented on Jun 24, 2020

    @lock

    This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. Why locking ? Having issues with the most up-to-date context.

  9. locked as resolved and limited conversation to collaborators on Jun 24, 2020
  10. added this to the 1.1.16 milestone on Oct 12, 2021
  11. vogloblinsky commented on Oct 14, 2021

    @vogloblinsky
    Contributor

    Fixed by 3814299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions