Skip to content

Commit

Permalink
fix: new lines in types (#34)
Browse files Browse the repository at this point in the history
* fix: new lines in types

* fix: new lines

* 🤖 Documentation auto-update

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
peterpeterparker and github-actions[bot] authored Oct 31, 2024
1 parent ed1572a commit cd25635
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/test/mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,5 +448,13 @@
}
],
"fileName": "src/test/mock.ts"
},
{
"name": "SatelliteConfig",
"documentation": "",
"type": "Either<SatelliteId, SatelliteIds> &\n CliConfig &\n SatelliteConfigOptions",
"jsDocs": [],
"doc_type": "type",
"fileName": "src/test/mock.ts"
}
]
9 changes: 9 additions & 0 deletions src/test/mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<SatelliteId, SatelliteIds> and CliConfig and SatelliteConfigOptions` |

[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L245)

6 changes: 5 additions & 1 deletion src/test/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,8 @@ export interface StorageConfigRedirect {
* @type {301 | 302}
*/
code: 301 | 302;
}
}

export type SatelliteConfig = Either<SatelliteId, SatelliteIds> &
CliConfig &
SatelliteConfigOptions;

0 comments on commit cd25635

Please sign in to comment.