Skip to content

Commit

Permalink
fix(docs-gen): generation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilev-alex authored Jul 1, 2020
1 parent f7c31a2 commit 1598a9b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
17 changes: 11 additions & 6 deletions docs-gen/src/resources/helpers/declaration-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import { heading } from './heading';
import { memberSymbol } from './member-symbol';
import { type } from './type';

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

const md = [];
const isOptional = this.flags.map(flag => flag).includes('Optional');

if (this.parent && this.parent.kind !== ReflectionKind.ObjectLiteral) {
const isOptional = this.flags.map((flag) => flag).includes('Optional');

if (
this.parent &&
this.parent.kind !== ReflectionKind.ObjectLiteral &&
this.parent.kind !== ReflectionKind.Enum &&
this.kind !== ReflectionKind.TypeAlias
) {
md.push(heading(3));
}

Expand All @@ -27,6 +32,6 @@ export function declarationTitle(this: DeclarationReflection, showSymbol: boolea
if (this.defaultValue) {
md.push(`= ${this.defaultValue}`);
}

return md.join(' ');
}
8 changes: 6 additions & 2 deletions docs-gen/src/resources/helpers/member-title.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { DeclarationReflection } from 'typedoc';
import { DeclarationReflection, ReflectionKind } from 'typedoc';

export function memberTitle(this: DeclarationReflection) {
if (this.parent?.kind === ReflectionKind.Enum) {
return '';
}

const md = [];

if (this.flags) {
md.push(this.flags.map(flag => `\`${flag}\``).join(' '));
md.push(this.flags.map((flag) => `\`${flag}\``).join(' '));
}
md.push(this.name);
return md.join(' ');
Expand Down
2 changes: 1 addition & 1 deletion docs-gen/src/resources/helpers/parameter-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function parameterTable(this: ParameterReflection[]) {
const typeOut = type.call(parameter.type);

const row = [
`\`${parameter.flags.isRest ? '...' : ''}${parameter.name}${isOptional ? '?' : ''}\``,
`${parameter.flags.isRest ? '...' : ''}${parameter.name}${isOptional ? '?' : ''}`,
typeOut ? typeOut.toString().replace(/\|/g, '|') : '',
];
if (hasDefaultValues) {
Expand Down
6 changes: 3 additions & 3 deletions docs-gen/src/resources/helpers/signature-title.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SignatureReflection, ReflectionKind } from 'typedoc';
import { SignatureReflection } from 'typedoc';

import { memberSymbol } from './member-symbol';
import { type } from './type';
Expand Down Expand Up @@ -27,11 +27,11 @@ export function signatureTitle(this: SignatureReflection, showSymbol: boolean) {
if (param.flags.isRest) {
paramsmd.push('...');
}
paramsmd.push(`\`${param.name}`);
paramsmd.push(`**${param.name}`);
if (param.flags.isOptional) {
paramsmd.push('?');
}
paramsmd.push(`\`: ${type.call(param.type)}`);
paramsmd.push(`**: ${type.call(param.type)}`);
return paramsmd.join('');
})
.join(', ')
Expand Down
7 changes: 4 additions & 3 deletions docs-gen/src/resources/helpers/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TypeOperatorType,
UnionType,
} from 'typedoc/dist/lib/models/types';
import { dasherize, underscore } from 'inflection';
import { dasherize, underscore, camelize } from 'inflection';

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

Expand Down Expand Up @@ -59,9 +59,10 @@ export function type(
return this;
}


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

function getReferenceType(model: ReferenceType) {
Expand Down
2 changes: 2 additions & 0 deletions docs-gen/src/resources/partials/member.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

{{else}}

{{#if memberTitle}}
{{heading 3}} {{{ memberTitle }}}
{{/if}}

{{/ifParentIsModule}}

Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-client-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ declare module '@cubejs-client/core' {
static getNormalizedPivotConfig(query: Query, pivotConfig?: Partial<PivotConfig>): PivotConfig;

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

0 comments on commit 1598a9b

Please sign in to comment.