TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.66k stars 692 forks source link

`plugin` option from option file not used. #1016

Closed GerkinDev closed 4 years ago

GerkinDev commented 5 years ago

I'm using a configuration file to store my TypeDoc settings. This configuration file contains the list of plugins to use, but they are not called at all. I don't want to rely on NPM auto-discovery.

This issue may be somehow related to #875.

Expected Behavior

Typedoc should use plugin array provided in the configuration file, and eventually merge it with the one provided by CLI arguments

Actual Behavior

Typedoc does not use the plugin option from the config file, and uses only NPM auto-discovery or the --plugin CLI argument

Steps to reproduce the bug

Install any typedoc plugin. From the installed plugin, remove the keyword typedocplugin from the keywords of the installed package.json, thus disabling npm auto-discovery.

Create a typedoc.json file

{
    "mode": "file",
    "out": "docs",
    "plugin": ["my-typedoc-plugin"]
}

Run typedoc:

npx typedoc --options typedoc.json

Environment

What I've tried

As far as I've seen and experimented, the problem is here: https://github.com/TypeStrong/typedoc/blob/9a76bec7cbc9fc7be7e00dd22f58f715bb4cebed/src/lib/application.ts#L124-L125

If I replace those lines with the following, the plugin is called correctly, but I didn't checked for side effects:

const optionsRead = this.options.read(this.options.getRawValues(), OptionsReadMode.Fetch);
this.plugins.load(); 
return optionsRead;

So is it intentional that options are parsed after plugins load ?


Edit : after further checks, I saw that options declared by the plugin are not provided to it if I apply the solution mentioned above. So, maybe options should be parsed once before plugins load, stored somewhere as raw options, then use those raw options when a plugin declares them.

Gerrit0 commented 4 years ago

Thank you for the detailed report! It informed my solution to the problem.

So, maybe options should be parsed once before plugins load, stored somewhere as raw options, then use those raw options when a plugin declares them.

This doesn't quite work, because we'd have to guess what type the options should be stored as. What does work though is parsing options, loading plugins, throwing away the parsed options, and re-parsing options :)

Fixed in v0.16.0.