Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typedoc seems to never terminate when trying to document a very large definition file #1755

Closed
xmo-odoo opened this issue Oct 21, 2021 · 4 comments
Labels
bug Functionality does not match expectation

Comments

@xmo-odoo
Copy link

This is trying to build the documentation for https://github.com/octokit/openapi-types.ts, the "entry point" is rather large at 1.5MB, I added the following tsconfig.json at the root of the repository in order to enable typedoc:

{
    "compilerOptions": {
        "strict": true
    },
    "typedocOptions": {
        "entryPoints": ["packages/openapi-types/types.d.ts"],
        "out": "docs",
        "readme": "none",
    }
}

Running typedoc with --logLevel Verbose prints the following:

Debug: Using TypeScript 4.4.4 from ./node_modules/typescript/lib
Debug: Converting with 1 programs 1 entry points
Debug: Finished getting entry points in 2656ms
Debug: Begin readme search at ./packages/openapi-types
Debug: Finished conversion in 11168ms
Debug: Renderer: Loading highlighter took 752ms

then it pegs a core and doesn't log anything anymore, I ended up killing the process after a bit more than an hour:

4957.74s user 3.66s system 99% cpu 1:22:42.55 total
@xmo-odoo xmo-odoo added the bug Functionality does not match expectation label Oct 21, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 22, 2021

Something's definitely very wrong here, conversion should take significantly longer than rendering in almost all cases (unless maybe there's a ridiculous number of code samples to highlight)

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 22, 2021

Well... the initial "fix" is easy. The culprit is Reflection.getAlias, which had a naive implementation to get a unique alias, resulting in O(n^2), where n is roughly the number of times the key appears in the page (several keys with >2000 for n in this project), to determine one. Replaced that with an O(1) implementation and it renders in 20 seconds on my machine.

The output however is... not great. Because typedoc displays object literal types inline, the operations interface page takes legitimately 60+ seconds to render. I'm not sure how any autogenerated documentation for an interface this large would fare though...

@xmo-odoo
Copy link
Author

Well... the initial "fix" is easy. The culprit is Reflection.getAlias, which had a naive implementation to get a unique alias, resulting in O(n^2), where n is roughly the number of times the key appears in the page (several keys with >2000 for n in this project), to determine one. Replaced that with an O(1) implementation and it renders in 20 seconds on my machine.

Nice, thanks! I guess it'll be in the next release or something?

The output however is... not great. Because typedoc displays object literal types inline, the operations interface page takes legitimately 60+ seconds to render. I'm not sure how any autogenerated documentation for an interface this large would fare though...

Yeah I wouldn't expect greatness from that large a file: this is documented from an openapi file, which most openapi navigators also choke on IIRC.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 22, 2021

Yep! I plan to make a release either tomorrow or Sunday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants