fix: doc generation for return types

This commit is contained in:
iCrawl
2022-06-08 19:12:42 +02:00
parent 5de9b80814
commit 5259639c2c
3 changed files with 14 additions and 10 deletions

View File

@@ -44,10 +44,12 @@ export class DocumentedMethod extends DocumentedItem<Method | DeclarationReflect
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize()) ? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize())
: undefined, : undefined,
returns: signature.type returns: signature.type
? new DocumentedVarType( ? [
{ names: [parseType(signature.type)], description: signature.comment?.returns?.trim() }, new DocumentedVarType(
this.config, { names: [parseType(signature.type)], description: signature.comment?.returns?.trim() },
).serialize() this.config,
).serialize(),
]
: undefined, : undefined,
returnsDescription: signature.comment?.returns?.trim(), returnsDescription: signature.comment?.returns?.trim(),
meta, meta,

View File

@@ -122,10 +122,12 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
deprecated: sig?.comment?.tags?.some((t) => t.tagName === 'deprecated'), deprecated: sig?.comment?.tags?.some((t) => t.tagName === 'deprecated'),
params, params,
returns: sig?.type returns: sig?.type
? new DocumentedVarType( ? [
{ names: [parseType(sig.type)], description: sig.comment?.returns?.trim() }, new DocumentedVarType(
this.config, { names: [parseType(sig.type)], description: sig.comment?.returns?.trim() },
).serialize() this.config,
).serialize(),
]
: undefined, : undefined,
returnsDescription: sig?.comment?.returns?.trim(), returnsDescription: sig?.comment?.returns?.trim(),
}; };

View File

@@ -10,11 +10,11 @@ export class DocumentedVarType extends DocumentedItem<VarType> {
const names = data.names?.map((name) => splitVarName(parseType(name))); const names = data.names?.map((name) => splitVarName(parseType(name)));
if (!data.description && !data.nullable) { if (!data.description && !data.nullable) {
return [names]; return names;
} }
return { return {
types: [names], types: names,
description: data.description, description: data.description,
nullable: data.nullable, nullable: data.nullable,
}; };