Skip to content

Commit 5f6a6b7

Browse files
committed
fix mixed namespaces (all callable members plus @propertyTableDoc tag)
1 parent a432b35 commit 5f6a6b7

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

.typedoc/custom-theme.mjs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ class ClerkMarkdownThemeContext extends MarkdownThemeContext {
925925
? model.filter(
926926
prop =>
927927
!isCallableInterfaceProperty(prop, this.helpers) &&
928-
!isCallableOnlyNamespaceProperty(prop, this.helpers),
928+
!isInlineNamespaceFullyExtractedToMethods(prop, this.helpers),
929929
)
930930
: model;
931931
return superPartials.propertiesTable(filtered, options);
@@ -1567,11 +1567,56 @@ function isCallableInterfaceProperty(prop, helpers) {
15671567
return isCallablePropertyValueType(t, helpers, new Set());
15681568
}
15691569

1570+
/**
1571+
* Inline object namespace whose **direct** members are each documented under `methods/` (either a callable → method MDX, or `@propertyTableDoc` → nested property table). Omits the parent row from reference-object property tables (e.g. `emailCode`, `emailLink` on `SignInFutureResource`).
1572+
*
1573+
* @param {import('typedoc').DeclarationReflection} prop
1574+
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext['helpers']} helpers
1575+
*/
1576+
function isInlineNamespaceFullyExtractedToMethods(prop, helpers) {
1577+
const t =
1578+
(prop.kind === ReflectionKind.Property || prop.kind === ReflectionKind.Variable) && prop.type
1579+
? prop.type
1580+
: helpers.getDeclarationType(prop);
1581+
let cur = /** @type {import('typedoc').Type | undefined} */ (t);
1582+
while (
1583+
cur &&
1584+
typeof cur === 'object' &&
1585+
/** @type {{ type?: string }} */ (cur).type === 'optional' &&
1586+
'elementType' in cur
1587+
) {
1588+
cur = /** @type {import('typedoc').Type} */ (/** @type {import('typedoc').OptionalType} */ (cur).elementType);
1589+
}
1590+
if (!(cur instanceof ReflectionType)) {
1591+
return false;
1592+
}
1593+
const children = cur.declaration?.children ?? [];
1594+
if (children.length === 0) {
1595+
return false;
1596+
}
1597+
for (const c of children) {
1598+
if (
1599+
c.kind !== ReflectionKind.Property &&
1600+
c.kind !== ReflectionKind.Variable &&
1601+
c.kind !== ReflectionKind.Accessor
1602+
) {
1603+
return false;
1604+
}
1605+
const documentedViaPropertyTable = Boolean(
1606+
/** @type {import('typedoc').DeclarationReflection} */ (c).comment?.getTag?.('@propertyTableDoc'),
1607+
);
1608+
if (!isCallableInterfaceProperty(c, helpers) && !documentedViaPropertyTable) {
1609+
return false;
1610+
}
1611+
}
1612+
return true;
1613+
}
1614+
15701615
/**
15711616
* Inline object type whose **direct** members are exclusively callables (e.g. `emailCode: { sendCode, verifyCode }` in `SignInFutureResource`).
1572-
* Omitted from reference-object property tables; nested callables are documented via extract-methods.
1617+
* Used by extract-methods to decide which namespaces need the mixed-namespace nested callable path.
15731618
*
1574-
* If any direct member is not callable, the parent stays in the property table. Use the @propertyTableDoc tag on non-callable members to avoid this behavior; it will create a page for that non-callable member in /methods that contains a heading and property table. (See `emailLink` in `SignInFutureResource` for an example; `emailLink.verification` is not callable and uses the @propertyTableDoc tag.)
1619+
* For property-table omission, see {@link isInlineNamespaceFullyExtractedToMethods}.
15751620
*
15761621
* @param {import('typedoc').DeclarationReflection} prop
15771622
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext['helpers']} helpers

.typedoc/extract-methods.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ function signatureWithInstantiation(sig, instantiationMap) {
491491
}
492492

493493
/**
494-
* Must stay aligned with allowlisted `propertiesTable` filtering in `custom-theme.mjs` (callable members and callable-only namespaces are extracted here, not listed as properties).
494+
* Must stay aligned with allowlisted `propertiesTable` filtering in `custom-theme.mjs` (`isCallableInterfaceProperty` / `isInlineNamespaceFullyExtractedToMethods`: extracted here, not listed as properties).
495495
*
496496
* @param {import('typedoc').DeclarationReflection} decl
497497
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext} ctx

0 commit comments

Comments
 (0)