compodoc / compodoc

:notebook_with_decorative_cover: The missing documentation tool for your Angular, Nest & Stencil application
https://compodoc.app
MIT License
4k stars 400 forks source link

[BUG] CompoDoc Fails To Parse Angular Route Files #968

Closed mabdrew closed 4 years ago

mabdrew commented 4 years ago
Overview of the issue

Whenever I run the build:docs script below. CompoDoc will fail, saying it cannot parse routing files.

Command: npm run build:docs which just runs npx compodoc -p tsconfig.json

This parsing errors occurs if a route has a data member with a field assigned to a lambda, or a member function. Assigning a field on data to a function defined earlier in the file seems to work fine, though.

Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.
      at InvalidOperationError.BaseError [as constructor] (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\BaseError.js:7:28)
      at new InvalidOperationError (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:8:28)
      at Object.throwIfNullOrUndefined (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
      at Identifier.Node.getSymbolOrThrow (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\compiler\common\Node.js:131:23)
      at RouterParserUtil.cleanFileDynamics (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:5668:18)
      at AngularDependencies.getSourceFileDecorators (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:8152:46)
      at D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:7960:31
      at Array.map (<anonymous>)
      at AngularDependencies.getDependencies (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:7949:21)
      at CliApplication.Application.getDependenciesData (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:9498:40) } reason: Error: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\BaseError.js:7:28)
    at new InvalidOperationError (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (D:\src\VAST\UI\VAST UI API UI\node_modules\ts-simple-ast\dist\compiler\common\Node.js:131:23)
    at RouterParserUtil.cleanFileDynamics (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:5668:18)
    at AngularDependencies.getSourceFileDecorators (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:8152:46)
    at D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:7960:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:7949:21)
    at CliApplication.Application.getDependenciesData (D:\src\VAST\UI\VAST UI API UI\node_modules\@compodoc\compodoc\dist\application-54cd2170.js:9498:40)
[08:26:37] Sorry, but there was a problem during parsing or generation of the documentation. Please fill an issue on github. (https://github.com/compodoc/compodoc/issues/new)
Operating System, Node.js, npm, compodoc version(s)

NPM: 6.14.5 Node: v10.16.2 OS: Win10 CompoDoc: 1.1.11

Angular configuration, a package.json file in the root folder
{
    "name": "app",
    "version": "0.0.0",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "start:debug": "ng serve -c=debug",
        "build:debug": "ng build -c=debug",
        "build:dev": "ng build -c=dev",
        "build:qual": "ng build -c=qual",
        "build:release": "ng build -c=release",
        "build:docs": "npx compodoc -p tsconfig.json",
        "test": "ng test --watch=false --code-coverage",
        "lint": "ng lint app --format=json > lint.json",
        "prettier": "prettier --write src/**/*.{js,ts,scss}",
        "e2e": "ng e2e"
    },
    "husky": {
        "hooks": {
            "pre-commit": "pretty-quick --staged --pattern=src/**/*.{js,ts,scss}"
        }
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "9.0.1",
        "@angular/common": "9.0.1",
        "@angular/compiler": "9.0.1",
        "@angular/core": "9.0.1",
        "@angular/forms": "9.0.1",
        "@angular/localize": "9.0.1",
        "@angular/platform-browser": "9.0.1",
        "@angular/platform-browser-dynamic": "9.0.1",
        "@angular/router": "9.0.1",
        "@fortawesome/angular-fontawesome": "0.5.0",
        "@fortawesome/fontawesome-pro": "5.8.1",
        "@fortawesome/fontawesome-svg-core": "1.2.17",
        "@fortawesome/pro-light-svg-icons": "5.8.1",
        "@fortawesome/pro-regular-svg-icons": "5.8.1",
        "@fortawesome/pro-solid-svg-icons": "5.8.1",
        "@ng-bootstrap/ng-bootstrap": "5.3.0",
        "@types/jquery": "3.3.31",
        "bootstrap": "4.3.1",
        "bootstrap4-notify": "4.0.3",
        "core-js": "2.5.4",
        "jquery": "3.4.0",
        "lodash-es": "4.17.11",
        "luxon": "1.13.2",
        "ngx-cookie-service": "2.2.0",
        "rxjs": "6.5.3",
        "tslib": "1.10.0",
        "zone.js": "0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "0.900.2",
        "@angular/cli": "9.0.2",
        "@angular/compiler-cli": "9.0.1",
        "@angular/language-service": "9.0.1",
        "@compodoc/compodoc": "1.1.11",
        "@types/jasmine": "2.8.8",
        "@types/jasminewd2": "2.0.3",
        "@types/node": "12.11.1",
        "codelyzer": "5.1.2",
        "husky": "4.2.5",
        "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.3",
        "karma-jasmine": "1.1.0",
        "karma-jasmine-html-reporter": "1.3.1",
        "karma-trx-reporter": "0.3.0",
        "prettier": "1.18.2",
        "pretty-quick": "2.0.1",
        "protractor": "5.4.0",
        "ts-node": "7.0.0",
        "tslint": "5.20.0",
        "tslint-angular": "3.0.2",
        "tslint-config-prettier": "1.18.0",
        "typescript": "3.7.5"
    }
}
Compodoc installed globally or locally ?

Locally

If possible sourcecode of the file where it breaks

Below is an example route that breaks compodocs

{
    path: 'someRoute',
    component: SomeComponent,
    pathMatch: 'full',
    data: {
        func: (data) => {
            return data && data.field ? data.field : '';
        }
    }
}

It also breaks if func is defined as a function and not a member field assigned to a lambda

func(data) {
    return data && data.field ? data.field : '';
}

Interestingly enough, if func is assigned to a free floating function, the doc generation does not break

function doThing(data) {
    return data && data.field ? data.field : '';
}
... later in file
{
    path: 'someRoute',
    component: SomeComponent,
    pathMatch: 'full',
    data: {
        func: doThing
    }
}
Motivation for or Use Case

It breaks our compo doc generation.

Reproduce the error

Create a route with member assigned to a lambda, or a member function, on the data field

stale[bot] commented 4 years ago

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.

Alex-hv commented 4 years ago

same for me

stale[bot] commented 4 years ago

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.