Compodoc: [BUG] Incompatible with Angular 8

Created on 13 Aug 2019  路  17Comments  路  Source: compodoc/compodoc

Overview of the issue

compodoc 1.1.10 is incompatible with Angular 8.

Documentation created without errors but the source code isn't parsed probably because the routing isn't taken into account.
FYI, Angular 8 introduced a new directory structure (ex: tsconfig.app.json moved from inside /src to / by default)

Works with Angular 7:

npm -g install @angular/[email protected]
ng new angular7-test --routing --style=scss
cd angular7-test
npx compodoc -p src/tsconfig.app.json

1.1.10

TypeScript version used by Compodoc : 2.9.1

TypeScript version of current project : 3.2.2

Node.js version : v12.7.0

Operating system : Windows 10

[09:14:23] No configuration file found, switching to CLI flags.
[09:14:23] Using tsconfig file : C:\Work\Playground\angular7-test\src\tsconfig.app.json
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\browserslist
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\favicon.ico
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\index.html
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\karma.conf.js
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\main.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\polyfills.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\styles.scss
[09:14:23] Excluding      : C:\Work\Playground\angular7-test\src\test.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\tsconfig.app.json
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\tsconfig.spec.json
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\tslint.json
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\app\app.component.html
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\app\app.component.scss
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\app\app-routing.module.ts
[09:14:23] Ignoring       : C:\Work\Playground\angular7-test\src\app\app.component.spec.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\app\app.component.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\app\app.module.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\assets\.gitkeep
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\environments\environment.prod.ts
[09:14:23] Including      : C:\Work\Playground\angular7-test\src\environments\environment.ts
[09:14:23] Searching package.json file
[09:14:23] package.json file found
[09:14:23] Processing package.json dependencies
[09:14:23] Searching README.md, CHANGELOG.md, CONTRIBUTING.md, LICENSE.md, TODO.md files
[09:14:23] README.md file found
[09:14:23] Error during C:\Work\Playground\angular7-test\CHANGELOG read
[09:14:23] Continuing without CHANGELOG.md file
[09:14:23] Error during C:\Work\Playground\angular7-test\CONTRIBUTING read
[09:14:23] Continuing without CONTRIBUTING.md file
[09:14:23] Error during C:\Work\Playground\angular7-test\LICENSE read
[09:14:23] Continuing without LICENSE.md file
[09:14:23] Error during C:\Work\Playground\angular7-test\TODO read
[09:14:23] Continuing without TODO.md file
[09:14:23] Get dependencies data
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/main.ts
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/polyfills.ts
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/app/app-routing.module.ts
[09:14:23] Analysing routes definitions and clean them if necessary
[09:14:23] found          : AppRoutingModule
[09:14:23]                : - imports:
[09:14:23]                :     - RouterModule
[09:14:23]                : - exports:
[09:14:23]                :     - RouterModule
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/app/app.component.ts
[09:14:23] found          : AppComponent
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/app/app.module.ts
[09:14:23] found          : AppModule
[09:14:23]                : - imports:
[09:14:23]                :     - BrowserModule
[09:14:23]                :     - AppRoutingModule
[09:14:23]                : - declarations:
[09:14:23]                :     - AppComponent
[09:14:23]                : - bootstrap:
[09:14:23]                :     - AppComponent
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/environments/environment.prod.ts
[09:14:23] parsing        : C:/Work/Playground/angular7-test/src/environments/environment.ts
[09:14:23] -------------------
[09:14:23] Project statistics
[09:14:23] - files      : 18
[09:14:23] - module     : 2
[09:14:23] - component  : 1
[09:14:23] -------------------
[09:14:23] Prepare components
[09:14:23]  AppComponent has a templateUrl, include it
[09:14:23]  AppComponent has styleUrls, include them
[09:14:23] Prepare modules
[09:14:23] Process routes
[09:14:23]  Routes index generated
[09:14:23] Prepare miscellaneous
[09:14:23] Process documentation coverage report
[09:14:23] Process main graph
(node:7040) V8: C:\Users\hewatp\AppData\Roaming\npm\node_modules\@compodoc\compodoc\node_modules\viz.js\viz.js:33 Invalid asm.js: Function definition doesn't match use
[09:14:23] Process module graph : AppModule
[09:14:23] Process module graph : AppRoutingModule
[09:14:23] Process pages
[09:14:23] Process page   : AppComponent
[09:14:24] Process page   : AppModule
[09:14:24] Process page   : AppRoutingModule
[09:14:24] Process page   : coverage
[09:14:24] Process page   : dependencies
[09:14:24] Process page   : index
[09:14:24] Process page   : modules
[09:14:24] Process page   : overview
[09:14:24] Process page   : routes
[09:14:24] Process page   : variables
[09:14:24] Process menu...
[09:14:24] Copy main resources
[09:14:24] Documentation generated in ./documentation/ in 1.341 seconds using gitbook theme
Content of src/tsconfig.app.json (generated using @angular/[email protected])
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
Fails with Angular 8:

npm -g remove @angular/cli
npm -g install @angular/[email protected]
ng new angular8-test --routing --style=scss
cd angular8-test
npx compodoc -p tsconfig.app.json

1.1.10

TypeScript version used by Compodoc : 2.9.1

TypeScript version of current project : 3.5.3

Node.js version : v12.7.0

Operating system : Windows 10

[09:38:48] No configuration file found, switching to CLI flags.
[09:38:48] Using tsconfig file : C:\Work\Playground\angular8-test\tsconfig.app.json
[09:38:48] Searching package.json file
[09:38:48] package.json file found
[09:38:48] Processing package.json dependencies
[09:38:48] Searching README.md, CHANGELOG.md, CONTRIBUTING.md, LICENSE.md, TODO.md files
[09:38:48] README.md file found
[09:38:48] Error during C:\Work\Playground\angular8-test\CHANGELOG read
[09:38:48] Continuing without CHANGELOG.md file
[09:38:48] Error during C:\Work\Playground\angular8-test\CONTRIBUTING read
[09:38:48] Continuing without CONTRIBUTING.md file
[09:38:48] Error during C:\Work\Playground\angular8-test\LICENSE read
[09:38:48] Continuing without LICENSE.md file
[09:38:48] Error during C:\Work\Playground\angular8-test\TODO read
[09:38:48] Continuing without TODO.md file
[09:38:48] Get dependencies data
[09:38:48] parsing        : C:/Work/Playground/angular8-test/src/main.ts
[09:38:48] parsing        : C:/Work/Playground/angular8-test/src/polyfills.ts
[09:38:48] -------------------
[09:38:48] Project statistics
[09:38:48] -------------------
[09:38:48] Prepare components
[09:38:48] Prepare modules
[09:38:48] Process documentation coverage report
[09:38:48] Process main graph
(node:14016) V8: C:\Users\hewatp\AppData\Roaming\npm\node_modules\@compodoc\compodoc\node_modules\viz.js\viz.js:33 Invalid asm.js: Function definition doesn't match use
[09:38:48] Process pages
[09:38:48] Process page   : coverage
[09:38:48] Process page   : dependencies
[09:38:48] Process page   : index
[09:38:48] Process page   : modules
[09:38:48] Process page   : overview
[09:38:48] Process menu...
[09:38:48] Copy main resources
[09:38:48] Documentation generated in ./documentation/ in 0.951 seconds using gitbook theme

Content of tsconfig.app.json (generated using @angular/[email protected])
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ]
}
Related issues

801

807

Bug

Most helpful comment

with angular 8, use
compodoc -p tsconfig.json -s and everything is working, including routing

All 17 comments

Basically happens due to this part in index-cli.ts
if (typeof scannedFiles === 'undefined') {

Due to scannedFiles never being undefined in Angular 8 because "files" is always defined in tsconfig.app.json.
TMP fix
TMP fix for this is just removing the "files" part or move them to the "include" part.
Do note that if your exclude has some sort of exclusion pattern it is possible that they will be filtered out of the "include" part as per their documentation

Skipping the "include" and "exclude" based on if "files" is defined seems as unwanted behaviour to me.

Confirmed, the same problem for me.
TMP fix worked (docs generated properly), thanks @jelgersma , not sure how this affects the application build.

Same happening here. @jelgersma's workaround did the trick to get the documentation. However, and it's another issue, new Angular 8 routing syntax is apparently not supported.

@sebastiandg7 "@jelgersma's workaround did the trick to get the documentation." You actually managed to get it to work? From my tests, it only produces an empty shell of a documentation. Angular 8 has been release 5 months ago and 9 is just around the corner. Anyone found a good alternative ?

@jelgersma I hadn"t understood your TMP fix corretly. I have done what you said and it works now. Thanks for the temporary workaround.

Basically happens due to this part in index-cli.ts
if (typeof scannedFiles === 'undefined') {

Due to scannedFiles never being undefined in Angular 8 because "files" is always defined in tsconfig.app.json.
TMP fix
TMP fix for this is just removing the "files" part or move them to the "include" part.
Do note that if your exclude has some sort of exclusion pattern it is possible that they will be filtered out of the "include" part as per their documentation

Skipping the "include" and "exclude" based on if "files" is defined seems as unwanted behavior to me.

Where should I remove the "files" block? Or where "include" block?

@triostudio The tsconfig.app.json file

@Triostudio The tsconfig.app.json file

Thank you very much. This works for me.

TMPFix is working fine in Angular 8
but it gives below error while i expanding route links and unable to generate flow of routes.

image

Hello everyboday.

I have got the same problem while using compodoc with Angular 8.

Hope an official fix will come out soon.

By the way, thanks a lot to this project's maintainers.

@sebastiandg7 is there any workaround for Angular 8 routing syntax to generate routing documentation correctly.

@krishnareddyML not that I know. We are now very close to Angular 9 and apparently there is no activity about this.

I will release something very soon ;)

1.1.11 is out, with ng 8 routing support

I confirm the issue as well. I moved the files "src/main.ts" and "src/polyfills.ts" from "files" key to "include". The project works properly until now and docs as well.

with angular 8, use
compodoc -p tsconfig.json -s and everything is working, including routing

with angular 8, use
compodoc -p tsconfig.json -s and everything is working, including routing

This with what @rysst-jelgersma said "TMP fix for this is just removing the "files" part or move them to the "include" part.
Do note that if your exclude has some sort of exclusion pattern it is possible that they will be filtered out of the "include" part as per their documentation

Skipping the "include" and "exclude" based on if "files" is defined seems as unwanted behaviour to me." Made it work! Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

froodley picture froodley  路  15Comments

crh225 picture crh225  路  20Comments

tsteuwer picture tsteuwer  路  15Comments

sclausen picture sclausen  路  14Comments

dharsanav picture dharsanav  路  16Comments