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
689 stars 172 forks source link

Bug? Missing 'relativeURL' handlebars helper #97

Closed mcortesi closed 4 years ago

mcortesi commented 4 years ago

I'm trying to run typedoc with markdown plugin and have the following error:

mcortesi packages/contractkit% ./node_modules/.bin/typedoc --theme markdown
Loaded plugin /Users/mcortesi/code/monorepo/node_modules/typedoc-plugin-markdown

Using TypeScript 3.5.3 from /Users/mcortesi/code/monorepo/node_modules/typescript/lib
Rendering [==--------------------------------------] 4%/Users/mcortesi/code/monorepo/node_modules/typedoc-plugin-markdown/dist/resources/helpers/type.js:35
        ? [`[${model.reflection.name}](${Handlebars.helpers.relativeURL.call(this, model.reflection.url)})`]

Which seems related to #41, but at least not the same error message.

I did try to run as suggested in #41 with: ./node_modules/.bin/typedoc --theme markdown

Not sure if this changes anything, but I have a monorepo and I'm trying to generate doc in one of the packages..

Apart from that, the typdoc.json is:

{
  "target": "es5",
  "module": ["es2017","dom"],
  "ignoreCompilerErrors": true,
  "includeDeclarations": false,
  "excludeProtected": true,
  "excludePrivate": true,
  "mode": "modules",
  "out": "docs-build",
  "theme": "markdown",
  "mdEngine": "gitbook",
  "stripExternal": false,
  "exclude": ["**/*.test.ts"],
  "readme": "README.md",
  "hideGenerator": "true",
  "verbose": true,
}

Any ideas?

tgreyuk commented 4 years ago

Hi @mcortesi

For now, if you are running from the shell then you will need to point to locally installed typedoc ie:

$ node_modules/.bin/typedoc 
mcortesi commented 4 years ago

That's what i did

mcortesi packages/contractkit% ./node_modules/.bin/typedoc --theme markdown

Maybe this is because of the monorepo setup?

I have:

monorepo/
   node_modules/
      typedoc/
      typepoc-plugin-markdown
   packages/
       contractkit/
           node_modules/.bin/typedoc (symlink to root node_module binary)
           src/**/*ts 
           typedoc.json
           tsconfig.json

And i run ./node_modules/.bin/typedoc --theme markdown in packages/congractkit

mcortesi commented 4 years ago

Hi @mcortesi

For now, if you are running from the shell then you will need to point to locally installed typedoc ie:

$ node_modules/.bin/typedoc 

Why is this required?

On my research i found that Marked plugin in typedoc/output/plugins folder seems to be the one that register relativeURL helper. But I'm not sure how those plugins are loaded, or if the are plugin in the same way that typedoc-plugin-markdown is a plugin....

tgreyuk commented 4 years ago

ok sorry - i realise you did explain that now. Will have a look.

tgreyuk commented 4 years ago

Ok have looked into this and basically the plugin does need to be executed from the same location as the typedoc cmd. Othewise there is a conflict t with the instances of Handlebars. In your example you don't need to symlink typdoc but just reference from the root ie:

../../node_modules/.bin/typedoc