Compodoc: [BUG] Lazy loaded routes are not documented

Created on 6 May 2020  路  15Comments  路  Source: compodoc/compodoc

Overview of the issue

Lazy Loaded routes are not showing in documentation:

image

Operating System, Node.js, npm, compodoc version(s)

OS: Windows
Node: 12.8.0
npm: 6.10.2
Angular CLI: 9.1.0

Compodoc installed globally or locally ?

Tried both

If possible sourcecode of the file where it breaks

Here is part of my app-routing.module.ts

// src/app/app-routing.module.ts
const routes: Routes = [
  {
    path: 'module1',
    loadChildren: () =>
      import('./modules/module1/module1.module').then((m) => m.Module1Module),
  }
]

And for each module, such as Module1:

// src/app/modules/module1/module1-routing.module.ts
const routes: Routes = [
  {
    path: '',
    component: Module1Component,
    data: {
      ...
    },
    canActivate: [AuthGuard],
    children: [
      {
        path: '',
        redirectTo: 'list'
      },
      {
        path: 'list',
        pathMatch: 'full',
        component: ListComponent,
        data: {
          ...
        },
      },
      {
        path: ':id',
        component: DetailsComponent,
        data: {
          ...
        },
      },
    ],
  },
];
If possible your terminal logs before the error
Error during generation of routes JSON file, maybe a trailing comma or an external variable inside one route.

image

Motivation for or Use Case

It should document all routes in the corresponding section.

Reproduce the error
  • Create a new app using the CLI and adding --routing
  • Create a new module (ng g m module --routing)
  • Add some routes an sample components as previously specified.
  • Try to create the documentation (npx compodoc -p tsconfig.json)
Related issues

Several times, but all of them have been closed due to inactivity

690, #569, #609, #805, #819.

Suggest a Fix

I haven't found a solution yet.

Bug wontfix

Most helpful comment

Hi,
I've just found a workaround that works for me on compodoc 1.1.11. Just replace

(m) => m.MyModule

by

m => m.MyModule

I think the regex need some improvement here : https://github.com/compodoc/compodoc/blob/8c509f0c130fb7cfc63f470a16e2fce73ddca092/src/utils/router-parser.util.ts#L25

All 15 comments

I'm having the same issue. It feels like the routes don't support the new syntax for lazy loading.

If that's the case, is there anyone looking into this?

I offer myself to work on this, but I am available starting next week.

I too need this bug fixed. Thanks @diegovincent to get started.

same problem here.

Same Problem here - I upgraded to Angular 9 - now no routes will be included into the documentation at all

I get an error with asm.js (don't know, if it is related)

(node:14104) V8: C:\repos\myProject\webapp\node_modules\viz.js\viz.js:33 Invalid asm.js: Function definition doesn't match use (Usenode --trace-warnings ...to show where the warning was created)

I have the same problem no routes presented.
image

But even when I remove all lazy loading logic the same error is shown:
image

I'm using this dependencies:
image

getting this error as well on angular 10.1.1 and compodoc 1.1.11

is there any progress on this?

Hi there. I getting the same issue and what i see.

TL;DR; globally installed compodoc, seems works well (for me)

:red_circle: compodoc(version 0.0.41) installed as devDependency

image

npm run compodoc

image

:green_circle: compodoc(v0.0.41) installed as GLOBAL package ("npm install -g compodoc")

All works without router parsing errors !!! and documentation looks good

compodoc -p tsconfig.json src 

image

So it seems some shared local dependency or special working mode of compodoc as devDependency adds side effect

Hi,
I've just found a workaround that works for me on compodoc 1.1.11. Just replace

(m) => m.MyModule

by

m => m.MyModule

I think the regex need some improvement here : https://github.com/compodoc/compodoc/blob/8c509f0c130fb7cfc63f470a16e2fce73ddca092/src/utils/router-parser.util.ts#L25

I was always using the global package, still it did not work.

But I can confirm the workaround posted by @headonkeyboard

I was always using the global package, still it did not work.

But I can confirm the workaround posted by @headonkeyboard

Same here, but its not a correct solution because when u build with --prod, got an error

Routes parsing error, maybe a trailing comma or an external variable ?

Same for me as @rodmax

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.

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.

I've tried the workaround by @headonkeyboard , but it's not working for me
Angular version: 11.2.0
Compodoc version: 1.1.11

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  17Comments

DimitriRO-IBM picture DimitriRO-IBM  路  15Comments

x1unix picture x1unix  路  18Comments

nikhilknoldus picture nikhilknoldus  路  18Comments

elvisbegovic picture elvisbegovic  路  14Comments