Skip to content

Commit

Permalink
fix: sfm docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Oct 30, 2024
1 parent 36e86da commit 47abd2f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/docgen/render/apiFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function renderParameters(options: {

const link = getTypeLink({ dataLookup, type: parameter })

const c = `\`${type}\``.replace(/(<.*>)/, '')
const c = `\`${type}\``
const listContent = link
? [`- **Type:** [${c}](${link})`]
: [`- **Type:** ${c}`]
Expand Down Expand Up @@ -243,8 +243,14 @@ function renderProperties(options: {

const nodes = references
.map((x) => {
const identifier = x?.getFirstDescendantByKind(ts.SyntaxKind.Identifier)
const typeName = x?.getTypeName()

const identifier = typeName?.isKind(ts.SyntaxKind.QualifiedName)
? typeName.getRight()
: typeName

if (!identifier) return
if (!identifier.isKind(ts.SyntaxKind.Identifier)) return
return identifier
.getDefinitionNodes()
.find((x) => x.isKind(ts.SyntaxKind.TypeAliasDeclaration))
Expand Down Expand Up @@ -423,8 +429,8 @@ function extractParameterTypeNode(
?.getDescendantsOfKind(ts.SyntaxKind.TypeReference)
.at(0)
const typeAliasDeclaration = reference
?.getType()
.getAliasSymbol()
?.getTypeName()
.getSymbol()
?.getDeclarations()
.at(0)
if (!typeAliasDeclaration?.isKind(ts.SyntaxKind.TypeAliasDeclaration)) return
Expand Down Expand Up @@ -483,7 +489,7 @@ function expandInlineType(options: {
) {
const groups =
type.primaryCanonicalReference.match(expandRegex)?.groups ?? {}
if (groups.type) return groups.type
if (groups.type) return groups.type.replace(/~(.*)_\d/, '$1')
} else if (dataLookup[`ox!${type.type}:type`]) return type.type
return type.type
}

0 comments on commit 47abd2f

Please sign in to comment.