Skip to content

Commit

Permalink
Add desc to enum fields
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Dec 12, 2024
1 parent 4eabfcc commit e90712c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/mcdoc/src/binder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,10 @@ function convertEnumBlock(node: EnumBlockNode, ctx: McdocBinderContext): EnumTyp
}

function convertEnumField(node: EnumFieldNode, ctx: McdocBinderContext): EnumTypeField {
const { attributes, identifier, value } = EnumFieldNode.destruct(node)
const { attributes, docComments, identifier, value } = EnumFieldNode.destruct(node)
return {
attributes: convertAttributes(attributes, ctx),
desc: DocCommentsNode.asText(docComments),
identifier: identifier.value,
value: convertEnumValue(value, ctx),
}
Expand Down
8 changes: 7 additions & 1 deletion packages/mcdoc/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,15 @@ export interface EnumFieldNode extends AstNode {
export namespace EnumFieldNode {
export function destruct(
node: EnumFieldNode,
): { attributes: AttributeNode[]; identifier: IdentifierNode; value: EnumValueNode } {
): {
attributes: AttributeNode[]
docComments?: DocCommentsNode
identifier: IdentifierNode
value: EnumValueNode
} {
return {
attributes: node.children.filter(AttributeNode.is),
docComments: node.children.find(DocCommentsNode.is),
identifier: node.children.find(IdentifierNode.is)!,
value: node.children.find(EnumValueNode.is)!,
}
Expand Down
1 change: 1 addition & 0 deletions packages/mcdoc/src/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export interface EnumType extends McdocBaseType {
export interface EnumTypeField extends McdocBaseType {
identifier: string
value: string | number
desc?: string
}

export interface ReferenceType extends McdocBaseType {
Expand Down

0 comments on commit e90712c

Please sign in to comment.