From cd25635cfe6bf385abe57704af7c7ae41fbc35a3 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Thu, 31 Oct 2024 06:53:26 +0100 Subject: [PATCH] fix: new lines in types (#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: new lines in types * fix: new lines * 🤖 Documentation auto-update --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 2 +- src/lib/markdown.ts | 8 +++++++- src/test/mock.json | 8 ++++++++ src/test/mock.md | 9 +++++++++ src/test/mock.ts | 6 +++++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 40545ef..9c9e987 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,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#L265) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/markdown.ts#L271) ### :gear: generateDocumentation diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts index 9be2238..d7da77f 100644 --- a/src/lib/markdown.ts +++ b/src/lib/markdown.ts @@ -128,7 +128,13 @@ const sourceCodeLink = ({ `[${emojiTitle({emoji, key: 'link'}).trim()} Source](${url})\n`; // Avoid issue if the Markdown table gets formatted with Prettier -const parseType = (type: string): string => type.replace(/ \| /g, ' or ').replace(/ & /g, ' and '); +const parseType = (type: string): string => + type + .split('\n') + .map((line) => line.trim()) + .join(' ') + .replace(/ \| /g, ' or ') + .replace(/ & /g, ' and '); const toMarkdown = ({ entries, diff --git a/src/test/mock.json b/src/test/mock.json index 08bc7aa..28da26b 100644 --- a/src/test/mock.json +++ b/src/test/mock.json @@ -448,5 +448,13 @@ } ], "fileName": "src/test/mock.ts" + }, + { + "name": "SatelliteConfig", + "documentation": "", + "type": "Either &\n CliConfig &\n SatelliteConfigOptions", + "jsDocs": [], + "doc_type": "type", + "fileName": "src/test/mock.ts" } ] diff --git a/src/test/mock.md b/src/test/mock.md index 964510d..3bc2994 100644 --- a/src/test/mock.md +++ b/src/test/mock.md @@ -260,6 +260,7 @@ Use a URL redirect to prevent broken links if you've moved a page or to shorten - [yolo](#gear-yolo) - [Abc](#gear-abc) - [StorageConfigSourceGlob](#gear-storageconfigsourceglob) +- [SatelliteConfig](#gear-satelliteconfig) ### :gear: yolo @@ -289,3 +290,11 @@ A type yolo [:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L219) +### :gear: SatelliteConfig + +| Type | Type | +| ---------- | ---------- | +| `SatelliteConfig` | `Either and CliConfig and SatelliteConfigOptions` | + +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L245) + diff --git a/src/test/mock.ts b/src/test/mock.ts index 6d5696a..f82fdf1 100644 --- a/src/test/mock.ts +++ b/src/test/mock.ts @@ -240,4 +240,8 @@ export interface StorageConfigRedirect { * @type {301 | 302} */ code: 301 | 302; -} \ No newline at end of file +} + +export type SatelliteConfig = Either & + CliConfig & + SatelliteConfigOptions;