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

sourceLinkTemplate option is not supported #617

Closed haroldadmin closed 1 month ago

haroldadmin commented 1 month ago

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

I use this plugin with typedoc in a monorepo with 50 packages to generate API reference docs for them. The API reference is generated in PRs, and deployed on each push to the main branch.

For each symbol in the generated docs, this plugin emits source links for them pointing to Github. The link includes the commit hash, which changes with each commit. This causes PRs to have massive diffs, just because the commit hash changed.

I want to work around this behaviour with the sourceLinkTemplate option. I want to use a template that points to the main branch instead of the latest commit hash (e.g. https://github.com/<org>/<repo>/blob/main/{path}#line={line}).

The plugin does not seem to respect this option. Can we please fix this behaviour?

TypeDoc configuration

{
  "$schema": "https://typedoc-plugin-markdown.org/schema.json",
  "entryPoints": ["packages/*"],
  "entryPointStrategy": "packages",
  "includeVersion": false,
  "cleanOutputDir": true,
  "out": "./apps/docs/src/pages/api-reference",
  "plugin": ["typedoc-plugin-markdown"],
  "hideBreadcrumbs": true,
  "hidePageHeader": true,
  "entryFileName": "index",
  "sourceLinkTemplate": "https://github.com/<org-name>/<repo-name>/blob/main/{path}#line={line}"
}

Expected behavior

The generated source link should respect the supplied template.

tgreyuk commented 1 month ago

Hello. This is more of a TypeDoc question that a plugin question, however this is supported but the config needs to be set in the config file for each package. TypeDoc 0.26 will be introducing a packageOptions option to address this very issue. https://github.com/TypeStrong/typedoc/issues/2523

haroldadmin commented 1 month ago

Thanks! Adding config at the package level fixed my issue.