typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
714 stars 176 forks source link

Getting error: "TypeError: template is not a function" when running typedoc generateDocs() function #424

Closed axli20 closed 1 year ago

axli20 commented 1 year ago

I wrote a script that uses typedoc (v^0.23.27) and typedoc-plugin-markdown (v3.15.2, latest) to generate markdown documentation files for my project. I'm running into the following error when I run the script:

Loaded plugin typedoc-plugin-markdown
TypeError: template is not a function

The script is super simple:

const app = new TypeDoc.Application();
app.options.addReader(new TypeDoc.TypeDocReader());
app.options.addReader(new TypeDoc.TSConfigReader());

const options = {
...
plugin: 'typedoc-plugin-markdown'
...
}

app.bootstrap(bootstrapOptions);
const project = app.convert();

if (project) {
  await app.generateDocs(project, outputDir);
}

After debugging, I've narrowed it down to the app.generateDocs(project, outputDir) call that's throwing the error. Would love to see this fixed, as the only solution I've found is to use version 3.14.0 of the typedoc-plugin-markdown package for now.

tgreyuk commented 1 year ago

Are you able to upgrade TypeDoc to ^0.24? There were some breaking API changes between 0.23 and 0.24.

tgreyuk commented 1 year ago

just to clarify the compatibility version. Its probably a bit confusing as breaking changes occur between typedoc minor versions.

typedoc version typedoc-plugin-markdown version
0.23 3.14
0.24 3.15
axli20 commented 1 year ago

@tgreyuk Just tried updating the typedoc version to 0.24.6 with plugin version 3.15.2, and this time it looks like typedoc didn't pick up on the plugin? When I ran the script it generated html files even though I specify the typedoc-plugin-markdown plugin in the bootStrap options.

tgreyuk commented 1 year ago

You now need to use app.bootstrapWithPlugins()

Application.bootstrap will no longer load plugins. If you want to load plugins, use Application.bootstrapWithPlugins instead, #1635.

https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md#v0240-2023-04-08

axli20 commented 1 year ago

Ahh I see, thank you!

axli20 commented 1 year ago

@tgreyuk Tried using app.bootstrapWithPlugins() with typedoc version 0.24.6, plugin version 3.15.2, and generateDocs call just hangs...

axli20 commented 1 year ago

Any updates here?

tgreyuk commented 1 year ago

Those methods return promises - are you using async/await ?