typedoc-plugin-markdown
typedoc-plugin-markdown copied to clipboard
Getting extra spaces before a function parameter
Giving the following source code,
export function fn(
a: () => number,
b: number,
c: GetNum,
): void {
console.log(a() + b + c())
}
export type GetNum = () => number
And the following typedoc config,
{
"plugin": [
"typedoc-plugin-markdown",
],
"useCodeBlocks": true,
"expandParameters": true,
}
I get the result below:
# Function: fn()
```ts
fn(
a: () => number,
b: number,
c: GetNum): void
```
Notice that there are some extra spaces after a.
Minimal reproduction:
https://githubbox.com/issueset/typedoc-plugin-markdown-function-param
Thank you - will fix this.
On a related note, you can actually format the output with Prettier using typedoc-plugin-remark. Example output here - https://github.com/tgreyuk/typedoc-plugin-markdown-examples/tree/main/examples/03-typedoc-plugin-remark#prettier.
Oh thanks. I didn't know about typedoc-plugin-remark before.
For this particular code block, Prettier cannot format it. I found that I need to add a function keyword at the beginning to make Prettier work. I can achieve this by overriding helpers.getKeyword. typedoc-plugin-markdown's API is very flexible and I love it.
// Prettier cannot format this
fn(
a: () => number,
b: number,
c: GetNum): void
// Prettier can format this
function fn(
a: () => number,
b: number,
c: GetNum): void
Thanks - thats a good spot actually. The function keyword should be present when useCodeBlocks are enabled.