Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ Parameters:
- `params.inputFiles`: The list of files to scan and for which the documentation should be build.
- `params.options`: Optional compiler options to generate the docs

Returns:
An array of documentation entries

[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/docs.ts#L496)

### :gear: documentationToMarkdown
Expand All @@ -164,7 +167,7 @@ Parameters:
- `params.entries`: The entries of the documentation (functions, constants and classes).
- `params.options`: Optional configuration to render the Markdown content. See `types.ts` for details.

[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/markdown.ts#L335)
[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/markdown.ts#L364)

### :gear: generateDocumentation

Expand Down
25 changes: 18 additions & 7 deletions src/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,16 @@ const toMarkdown = ({
const jsDocsToReturnType = (jsDocs: JSDocTagInfo[]): string => {
const returns: JSDocTagInfo[] = jsDocs.filter(({name}: JSDocTagInfo) => name === 'returns');
const texts: Array<SymbolDisplayPart[] | undefined> = returns.map(({text}) => text);
const returnType = texts.reduce((acc: SymbolDisplayPart[][], values: SymbolDisplayPart[] | undefined) => {
if (values === undefined) {
return acc;
}
const returnType = texts.reduce(
(acc: SymbolDisplayPart[][], values: SymbolDisplayPart[] | undefined) => {
if (values === undefined) {
return acc;
}

return [...acc, values];
}, []);
return [...acc, values];
},
[]
);

return returnType.map((parts) => parts.map(({text}) => text).join('')).join(' ');
};
Expand Down Expand Up @@ -271,7 +274,15 @@ const toMarkdown = ({
})
);

const rowToMarkdown = ({name, documentation, type, params, returnType, examples, url}: Row): string => {
const rowToMarkdown = ({
name,
documentation,
type,
params,
returnType,
examples,
url
}: Row): string => {
const markdown: string[] = [
`${headingLevel}# ${emoji === undefined || emoji === null ? '' : ':gear: '}${name}\n`
];
Expand Down
2 changes: 1 addition & 1 deletion src/test/mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,4 @@
],
"fileName": "src/test/mock.ts"
}
]
]