Skip to content

Commit 1598a9b

Browse files
authored
fix(docs-gen): generation fixes
1 parent f7c31a2 commit 1598a9b

File tree

7 files changed

+28
-16
lines changed

7 files changed

+28
-16
lines changed

docs-gen/src/resources/helpers/declaration-title.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import { heading } from './heading';
33
import { memberSymbol } from './member-symbol';
44
import { type } from './type';
55

6-
export function declarationTitle(this: DeclarationReflection, showSymbol: boolean) {
7-
if (this.type?.type !== 'union') {
6+
export function declarationTitle(this: DeclarationReflection, showSymbol: boolean) {
7+
if (this.type?.type !== 'union' && this.type?.type !== 'tuple' && this.kind !== ReflectionKind.EnumMember) {
88
return '';
99
}
1010

1111
const md = [];
12-
const isOptional = this.flags.map(flag => flag).includes('Optional');
13-
14-
if (this.parent && this.parent.kind !== ReflectionKind.ObjectLiteral) {
12+
const isOptional = this.flags.map((flag) => flag).includes('Optional');
13+
14+
if (
15+
this.parent &&
16+
this.parent.kind !== ReflectionKind.ObjectLiteral &&
17+
this.parent.kind !== ReflectionKind.Enum &&
18+
this.kind !== ReflectionKind.TypeAlias
19+
) {
1520
md.push(heading(3));
1621
}
1722

@@ -27,6 +32,6 @@ export function declarationTitle(this: DeclarationReflection, showSymbol: boolea
2732
if (this.defaultValue) {
2833
md.push(`= ${this.defaultValue}`);
2934
}
30-
35+
3136
return md.join(' ');
3237
}

docs-gen/src/resources/helpers/member-title.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { DeclarationReflection } from 'typedoc';
1+
import { DeclarationReflection, ReflectionKind } from 'typedoc';
22

33
export function memberTitle(this: DeclarationReflection) {
4+
if (this.parent?.kind === ReflectionKind.Enum) {
5+
return '';
6+
}
7+
48
const md = [];
59

610
if (this.flags) {
7-
md.push(this.flags.map(flag => `\`${flag}\``).join(' '));
11+
md.push(this.flags.map((flag) => `\`${flag}\``).join(' '));
812
}
913
md.push(this.name);
1014
return md.join(' ');

docs-gen/src/resources/helpers/parameter-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function parameterTable(this: ParameterReflection[]) {
2828
const typeOut = type.call(parameter.type);
2929

3030
const row = [
31-
`\`${parameter.flags.isRest ? '...' : ''}${parameter.name}${isOptional ? '?' : ''}\``,
31+
`${parameter.flags.isRest ? '...' : ''}${parameter.name}${isOptional ? '?' : ''}`,
3232
typeOut ? typeOut.toString().replace(/\|/g, '|') : '',
3333
];
3434
if (hasDefaultValues) {

docs-gen/src/resources/helpers/signature-title.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SignatureReflection, ReflectionKind } from 'typedoc';
1+
import { SignatureReflection } from 'typedoc';
22

33
import { memberSymbol } from './member-symbol';
44
import { type } from './type';
@@ -27,11 +27,11 @@ export function signatureTitle(this: SignatureReflection, showSymbol: boolean) {
2727
if (param.flags.isRest) {
2828
paramsmd.push('...');
2929
}
30-
paramsmd.push(`\`${param.name}`);
30+
paramsmd.push(`**${param.name}`);
3131
if (param.flags.isOptional) {
3232
paramsmd.push('?');
3333
}
34-
paramsmd.push(`\`: ${type.call(param.type)}`);
34+
paramsmd.push(`**: ${type.call(param.type)}`);
3535
return paramsmd.join('');
3636
})
3737
.join(', ')

docs-gen/src/resources/helpers/type.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TypeOperatorType,
1010
UnionType,
1111
} from 'typedoc/dist/lib/models/types';
12-
import { dasherize, underscore } from 'inflection';
12+
import { dasherize, underscore, camelize } from 'inflection';
1313

1414
import MarkdownTheme from '../../theme';
1515

@@ -59,9 +59,10 @@ export function type(
5959
return this;
6060
}
6161

62-
6362
function anchorName(link) {
64-
return '#' + dasherize(underscore(link.replace(/#/g, '-')));
63+
return (
64+
'#' + dasherize(underscore(link.replace(/[A-Z]{2,}(?=[A-Z])/, (v) => camelize(v.toLowerCase())).replace(/#/g, '-')))
65+
);
6566
}
6667

6768
function getReferenceType(model: ReferenceType) {

docs-gen/src/resources/partials/member.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
{{else}}
99

10+
{{#if memberTitle}}
1011
{{heading 3}} {{{ memberTitle }}}
12+
{{/if}}
1113

1214
{{/ifParentIsModule}}
1315

packages/cubejs-client-core/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ declare module '@cubejs-client/core' {
218218
static getNormalizedPivotConfig(query: Query, pivotConfig?: Partial<PivotConfig>): PivotConfig;
219219

220220
/**
221-
* Creates new instance of ResultSet based on [LoadResponse](#load-response) data.
221+
* Creates a new instance of ResultSet based on [LoadResponse](#load-response) data.
222222
*
223223
* ```js
224224
* import cubejs, { ResultSet } from '@cubejs-client/core';

0 commit comments

Comments
 (0)