typedoc2md/typedoc-plugin-markdown

Inline code formatting issues with newlines, template literals

Closed this issue · 3 comments

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

I found a few cases where inline code doesn't get rendered properly. I think they are related but might be separate issues. The two cases are:

  • The output contains newlines (seen in index signatures and constructor overrides)
  • The output contains a template literal type

I created an example repository with the TypeScript code that causes these cases as well as a custom theme I hacked together that overrides some partials to produce output that renders correctly (at least on GitHub): https://github.com/lukekarrys/typedoc-markdown-hacks

The readme shows a diff of the original vs modified markdown output as well as a script that can be run to generate it.

Here are the specific cases as well:

template literals

#### Returns

\`sha512-$\{string\}\`

#### Returns

asserts i is \`sha512-$\{string\}\`

#### Returns

i is \`sha512-$\{string\}\`

constructor overrides

###### Overrides

`LRUCache<
  CacheFetchContext,
  CacheFetchContext,
  CacheFetchContext
>.constructor`

index signatures

#### Index Signature

 \[`key`: 
  \| \`git·$\{string\}·$\{string\} $\{string\}\`
  \| \`remote·$\{string\}·$\{string\} $\{string\}\`\]: 
  \| \`dev git·$\{string\}·$\{string\}\`
  \| \`dev remote·$\{string\}·$\{string\}\`
  \| \`prod git·$\{string\}·$\{string\}\`
  \| \`prod remote·$\{string\}·$\{string\}\`

TypeDoc configuration

{
  "entryPoints": ["./src/*"],
  "name": "Example",
  "outputFileStrategy": "modules",
  "mergeReadme": false,
  "entryFileName": "index.md",
  "disableSources": true,
  "excludeScopesInPaths": true,
  "useCodeBlocks": true,
  "hideBreadcrumbs": true,
  "hidePageHeader": true,
  "hidePageTitle": true,
  "readme": "none",
  "plugin": ["typedoc-plugin-markdown"]
}

Expected behavior

Here is the markdown output I expect in the cases above:

template literals

#### Returns

`` `sha512-${string}` ``

#### Returns

`` asserts i is `sha512-${string}` ``

#### Returns

`` i is `sha512-${string}` ``

constructor overrides

###### Overrides

```ts
LRUCache<
  CacheFetchContext,
  CacheFetchContext,
  CacheFetchContext
>.constructor
```

index signatures

#### Index Signature

```ts
 [key: 
  | `git·${string}·${string} ${string}`
  | `remote·${string}·${string} ${string}`]: 
  | `dev git·${string}·${string}`
  | `dev remote·${string}·${string}`
  | `prod git·${string}·${string}`
  | `prod remote·${string}·${string}`
```

thank you @lukekarrys this is super useful. I am working through the use cases.

@lukekarrys fixes in typedoc-plugin-markdown@4.4.0.

Here is a diff on the example repository lukekarrys/typedoc-markdown-hacks@main...tgreyuk:typedoc-fixes

I think things are looking pretty good.

Let me know if you find more use-cases.

Thanks again

Thanks @tgreyuk! I updated to the latest version and everything looks great without any manual theming now, so I'm going to close this.