Skip to content

Commit

Permalink
fix: Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Mar 21, 2024
1 parent 06187c7 commit 5983059
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/pages/options.mdx
Expand Up @@ -579,6 +579,7 @@ Below is the full list of keys and default values:
"label.indexSignature": "Index signature",
"label.member": "Member",
"label.modifier": "Modifier",
"label.name": "Name",
"label.overrides": "Overrides",
"label.packages": "Packages",
"label.reExports": "Re-exports",
Expand Down
Expand Up @@ -90,6 +90,7 @@ export interface TextContentMappings {
'label.indexSignature': string;
'label.member': string;
'label.modifier': string;
'label.name': string;
'label.overrides': string;
'label.packages': string;
'label.reExports': string;
Expand Down
Expand Up @@ -22,6 +22,7 @@ export const TEXT_MAPPING_DEFAULTS = {
'label.indexSignature': 'Index signature',
'label.member': 'Member',
'label.modifier': 'Modifier',
'label.name': 'Name',
'label.overrides': 'Overrides',
'label.packages': 'Packages',
'label.reExports': 'Re-exports',
Expand Down
@@ -1,3 +1,3 @@
export function backTicks(text: string) {
return /(\`)/g.test(text) ? text.replace(/`/g, '\\`') : `\`${text}\``;
return /(\`)/g.test(text) ? `\`\`${text}\`\`` : `\`${text}\``;
}
Expand Up @@ -22,7 +22,7 @@ export function packagesIndex(
);

if (context.options.getValue('packagesFormat') === 'table') {
const headers = ['Package'];
const headers = [context.helpers.getText('label.name')];
if (includeVersion) {
headers.push('Version');
}
Expand Down
Expand Up @@ -169,3 +169,11 @@ export const someQuery = 1;
* Comments for query type
*/
export type QueryType = typeof someQuery;

/**
* Union with template strings
*/
export type UnionTypeWithTemplateStrings =
| `v${number}`
| `v${number}.${number}`
| `v${number}.${number}.${number}`;
Expand Up @@ -1838,6 +1838,10 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
{
"title": "UnionType",
"url": "type-aliases/UnionType.md"
},
{
"title": "UnionTypeWithTemplateStrings",
"url": "type-aliases/UnionTypeWithTemplateStrings.md"
}
]
},
Expand Down
Expand Up @@ -174,7 +174,7 @@ Some text.
## Packages
| Package | Version | Description |
| Name | Version | Description |
| :------ | :------ | :------ |
| [@scope/package-1](package-1/index.md) | 1.0.0 | Description for package-1 |
| [package-1b](package-1b/index.md) | - | - |
Expand Down
Expand Up @@ -514,7 +514,7 @@ Comments for ReadonlyMapedType
exports[`Type Alias Reflection should compile string literal type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type alias: StringLiteralType
> **StringLiteralType**: \`" "\` \\| \`"string"\` \\| \`"string|with|pipes"\` \\| "string\\\`with\\\`backticks" \\| \`"<foo>"\` \\| \`"*"\`
> **StringLiteralType**: \`" "\` \\| \`"string"\` \\| \`"string|with|pipes"\` \\| \`\`"string\`with\`backticks"\`\` \\| \`"<foo>"\` \\| \`"*"\`
Comments for StringLiteralType
Expand All @@ -532,7 +532,7 @@ type StringLiteralType:
| " "
| "string"
| "string|with|pipes"
| "string\\with\\backticks"
| "stringwithbackticks"
| "<foo>"
| "*";
\`\`\`
Expand Down Expand Up @@ -614,6 +614,34 @@ Comments for TypeWithTypeParams
"
`;
exports[`Type Alias Reflection should compile union type with template strings: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type alias: UnionTypeWithTemplateStrings
> **UnionTypeWithTemplateStrings**: \`\`\`v\${number}\`\`\` \\| \`\`\`v\${number}.\${number}\`\`\` \\| \`\`\`v\${number}.\${number}.\${number}\`\`\`
Union with template strings
## Source
[types.ts:176](http://source-url)
"
`;
exports[`Type Alias Reflection should compile union type with template strings: (Output File Strategy "members") (Option Group "2") 1`] = `
"# UnionTypeWithTemplateStrings
\`\`\`ts
type UnionTypeWithTemplateStrings: v\${number} | v\${number}.\${number} | v\${number}.\${number}.\${number};
\`\`\`
Union with template strings
## Source
[types.ts:176](http://source-url)
"
`;
exports[`Type Alias Reflection should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type alias: UnionType
Expand Down
Expand Up @@ -421,6 +421,7 @@ exports[`Urls should gets Urls for single entry points: outputFileStrategy: memb
"type-aliases/TypeWithExternalSymbolLinkMapping.md",
"type-aliases/TypeWithTypeParams.md",
"type-aliases/UnionType.md",
"type-aliases/UnionTypeWithTemplateStrings.md",
"variables/objectLiteralVariable.md",
"variables/objectWithSymbol.md",
"variables/someQuery.md",
Expand Down Expand Up @@ -485,6 +486,7 @@ exports[`Urls should gets Urls for single entry points: outputFileStrategy: memb
"type-aliases/TypeWithExternalSymbolLinkMapping.md",
"type-aliases/TypeWithTypeParams.md",
"type-aliases/UnionType.md",
"type-aliases/UnionTypeWithTemplateStrings.md",
"variables/objectLiteralVariable.md",
"variables/objectWithSymbol.md",
"variables/someQuery.md",
Expand Down
Expand Up @@ -104,4 +104,12 @@ describe(`Type Alias Reflection`, () => {
test(`should compile query type`, () => {
expectFileToEqual('reflections', 'members', 'type-aliases/QueryType.md');
});

test(`should compile union type with template strings`, () => {
expectFileToEqual(
'reflections',
'members',
'type-aliases/UnionTypeWithTemplateStrings.md',
);
});
});

0 comments on commit 5983059

Please sign in to comment.