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
722 stars 177 forks source link

[bug] [vuepress-plugin-typedoc] should supply VuePress env flag to auto bootstrap watch ability. #413

Closed koolc closed 1 year ago

koolc commented 1 year ago

The VuePress env flag should be supplied to auto bootstrap watch ability. Sometimes, user doesn't configure the typedocOptions.watch the option, and use a single vuepress.config.ts config file to support vuepress dev and vuepress build .

if (typedocOptions.watch) {
    app.convertAndWatch(async (project) => {
        app.generateDocs(project, outputDirectory);
    });
}

if (typedocOptions.watch || app.env.isDev || app.env.isDebug) {
    app.convertAndWatch(async (project) => {
        app.generateDocs(project, outputDirectory);
    });
}
tgreyuk commented 1 year ago

Ok thanks. Will have a look at that.

tgreyuk commented 1 year ago

I think the preferable thing here would be to do:

package.json

"start": "TYPEDOC_WATCH=true vuepress dev docs",
"build": "TYPEDOC_WATCH=false vuepress build docs",

config.js


plugins: [
    typedocPlugin({
     ....
      watch: process.env.TYPEDOC_WATCH,
    }),
  ],```
koolc commented 1 year ago

But ,running the code below, the value is string "false", not boolean value.

if (typedocOptions.watch) {
    app.convertAndWatch(async (project) => {
       app.generateDocs(project, outputDirectory);
    });
}
koolc commented 1 year ago

So, having to use "boolean" ==="true" to fix the condition in vuepress.config.js file:

plugins: [
    typedocPlugin({
     ....
      watch: process.env.TYPEDOC_WATCH === 'true',  // the fix
    }),
  ],```