Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jsDocs description containing pipes #32

Merged
merged 2 commits into from
Oct 30, 2024
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
4 changes: 2 additions & 2 deletions src/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const interfacesToMarkdown = ({
);

markdown.push(
`| \`${name}\` | \`${parseType(type ?? '')}\` | ${documentation !== undefined && documentation !== '' ? `${parseType(documentation).replace(/\r?\n|\r/g, '')}` : ''}${jsDocsDescription.length > 0 ? ` ${jsDocsDescription.join('')}` : ''} |`
`| \`${name}\` | \`${parseType(type ?? '')}\` | ${documentation !== undefined && documentation !== '' ? `${parseType(documentation).replace(/\r?\n|\r/g, '')}` : ''}${jsDocsDescription.length > 0 ? ` ${parseType(jsDocsDescription.join(''))}` : ''} |`
);
});

Expand Down Expand Up @@ -180,7 +180,7 @@ const toMarkdown = ({
const rows: Row[] = entries.map(
({name, type, documentation, parameters, jsDocs, url}: DocEntry) => ({
name,
type: type ?? '',
type: parseType(type ?? ''),
documentation: documentation ?? '',
params: [...toParams(parameters), ...jsDocsToParams(jsDocs ?? [])],
examples: [...jsDocsToExamples(jsDocs ?? [])],
Expand Down
75 changes: 75 additions & 0 deletions src/test/mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,80 @@
],
"doc_type": "function",
"fileName": "src/test/mock.ts"
},
{
"name": "StorageConfigSourceGlob",
"documentation": "",
"jsDocs": [],
"doc_type": "type",
"fileName": "src/test/mock.ts"
},
{
"name": "StorageConfigRedirect",
"documentation": "Use a URL redirect to prevent broken links if you've moved a page or to shorten URLs.",
"type": "any",
"jsDocs": [
{
"name": "interface",
"text": [
{
"text": "StorageConfigRedirect",
"kind": "text"
}
]
}
],
"doc_type": "interface",
"properties": [
{
"name": "source",
"documentation": "The glob pattern or specific path to match for incoming requests that should be redirected.",
"type": "string",
"jsDocs": [
{
"name": "type",
"text": [
{
"text": "{StorageConfigSourceGlob}",
"kind": "text"
}
]
}
]
},
{
"name": "location",
"documentation": "The URL or path to which the request should be redirected.",
"type": "string",
"jsDocs": [
{
"name": "type",
"text": [
{
"text": "{string}",
"kind": "text"
}
]
}
]
},
{
"name": "code",
"documentation": "The HTTP status code to use for the redirect, typically 301 (permanent redirect) or 302 (temporary redirect).",
"type": "301 | 302",
"jsDocs": [
{
"name": "type",
"text": [
{
"text": "{301 | 302}",
"kind": "text"
}
]
}
]
}
],
"fileName": "src/test/mock.ts"
}
]
21 changes: 21 additions & 0 deletions src/test/mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Description
## :tropical_drink: Interfaces

- [Foo](#gear-foo)
- [StorageConfigRedirect](#gear-storageconfigredirect)

### :gear: Foo

Expand All @@ -243,10 +244,22 @@ A Foo interface description.
| `abc` | `Abc` | |


### :gear: StorageConfigRedirect

Use a URL redirect to prevent broken links if you've moved a page or to shorten URLs.

| Property | Type | Description |
| ---------- | ---------- | ---------- |
| `source` | `string` | The glob pattern or specific path to match for incoming requests that should be redirected. type: {StorageConfigSourceGlob} |
| `location` | `string` | The URL or path to which the request should be redirected. type: {string} |
| `code` | `301 or 302` | The HTTP status code to use for the redirect, typically 301 (permanent redirect) or 302 (temporary redirect). type: {301 or 302} |


## :cocktail: Types

- [yolo](#gear-yolo)
- [Abc](#gear-abc)
- [StorageConfigSourceGlob](#gear-storageconfigsourceglob)

### :gear: yolo

Expand All @@ -268,3 +281,11 @@ A type yolo

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

### :gear: StorageConfigSourceGlob

| Type | Type |
| ---------- | ---------- |
| `StorageConfigSourceGlob` | |

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

30 changes: 30 additions & 0 deletions src/test/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,33 @@ export function formInvalidateHandler(form: any, err: any, cb?: (msg: string) =>
if (msg && cb) cb(msg);
}
}

/**
* Represents a glob pattern for matching files in the Storage configuration.
* @typedef {string} StorageConfigSourceGlob
*/
export type StorageConfigSourceGlob = string;

/**
* Use a URL redirect to prevent broken links if you've moved a page or to shorten URLs.
* @interface StorageConfigRedirect
*/
export interface StorageConfigRedirect {
/**
* The glob pattern or specific path to match for incoming requests that should be redirected.
* @type {StorageConfigSourceGlob}
*/
source: StorageConfigSourceGlob;

/**
* The URL or path to which the request should be redirected.
* @type {string}
*/
location: string;

/**
* The HTTP status code to use for the redirect, typically 301 (permanent redirect) or 302 (temporary redirect).
* @type {301 | 302}
*/
code: 301 | 302;
}
Loading