Skip to content

[docs-utils] 4️⃣ Handle multiple call signature declarations#252643

Merged
clintandrewhall merged 2 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-call-signatures
Feb 24, 2026
Merged

[docs-utils] 4️⃣ Handle multiple call signature declarations#252643
clintandrewhall merged 2 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-call-signatures

Conversation

@clintandrewhall
Copy link
Copy Markdown
Contributor

Summary

Adds support for interfaces and variables with multiple call signatures (function overloads) in kbn-docs-utils API documentation generation. Previously, these declarations were either silently dropped or incorrectly typed, resulting in missing documentation for overloaded functions.

Note

This PR is a subset of #247688 for ease of review.

This PR was written with Cursor and claude-4.5-opus-high.

Before / After Example

Given this TypeScript code:

export interface OverloadedFunction {
  (input: string): number;
  (input: number): string;
  (input: boolean): boolean;
}

/** Process the input value using the overloaded function. */
export const overloadedFn: OverloadedFunction = (input: any): any => input;

Before this PR:

The OverloadedFunction interface was exported but its call signatures were lost. The overloadedFn variable was typed as ObjectKind instead of FunctionKind, with no parameter documentation:

{
  "label": "overloadedFn",
  "type": "Object",
  "children": [],
  "signature": []
}
// Call signatures silently dropped! No parameter docs!

After this PR:

The new buildMultipleCallSignaturesDec() handler detects multiple call signatures, extracts parameter docs from the first signature, and produces a proper function declaration:

{
  "label": "overloadedFn",
  "type": "Function",
  "children": [
    {
      "label": "input",
      "type": "CompoundType",
      "description": [],
      "signature": [{ "text": "string" }, " | ", { "text": "number" }, " | ", "boolean"]
    }
  ],
  "signature": [
    "(input: string | number | boolean) => ",
    { "pluginId": "pluginA", "section": "def-public.OverloadedFunction", "text": "OverloadedFunction" }
  ]
}
// ✅ Typed as Function, parameters extracted, signature links to interface

How It Works

Declaration Type Before After
Interface with call signatures Signature empty, no children Call signatures become children
Variable typed as overloaded interface ObjectKind, no params FunctionKind, params from first signature
Non-overloaded function Unchanged Unchanged

Changes

  • New buildMultipleCallSignaturesDec() in build_multiple_call_signatures_dec.ts -- handles nodes whose resolved type has multiple call signatures
  • Updated buildVariableDec() -- detects when a variable's type has multiple call signatures and delegates to the new handler
  • Updated buildFunctionDec() -- extracts parameter source from the first call signature when the node itself has none
  • Test fixtures -- adds OverloadedFunction interface and overloadedFn variable to the plugin_a test fixture
  • Integration tests -- 4 new test cases verifying interface children, variable type, parameter extraction, and signature linking

Impact

  • API declarations for overloaded functions are now correctly typed and documented
  • Test plugin apiCount increases from 136 to 145 (new fixture entries)

Made with Cursor

@clintandrewhall clintandrewhall requested a review from a team as a code owner February 11, 2026 02:56
@clintandrewhall clintandrewhall added review Team:Operations Kibana-Operations Team release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v9.4.0 labels Feb 11, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@clintandrewhall clintandrewhall force-pushed the feat/docs-utils/4-call-signatures branch from 1b8fe3a to d7f01f1 Compare February 11, 2026 02:59
@clintandrewhall clintandrewhall force-pushed the feat/docs-utils/4-call-signatures branch 4 times, most recently from 16f8097 to 15f37b8 Compare February 20, 2026 05:08
Copy link
Copy Markdown
Contributor

@mistic mistic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

- Handle interfaces with multiple call signatures.
- Extract parameter documentation from first overload signature.
- Add test cases for overloaded functions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@clintandrewhall clintandrewhall force-pushed the feat/docs-utils/4-call-signatures branch from 13511b0 to b39cf54 Compare February 24, 2026 00:32
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #4 / discover responsive sidebar should not render buttons in data view picker when in viewer mode

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/cell-actions 30 31 +1
@kbn/config-schema 141 152 +11
@kbn/content-list-table 27 29 +2
@kbn/core-http-browser 36 58 +22
@kbn/esql-language 685 702 +17
@kbn/evals 248 250 +2
@kbn/handlebars 24 27 +3
@kbn/inference-tracing 22 25 +3
@kbn/lens-common 1380 1384 +4
@kbn/monaco 222 227 +5
@kbn/synthtrace-client 297 303 +6
@kbn/workspaces 21 23 +2
data 2610 2611 +1
lens 605 609 +4
telemetryCollectionManager 26 29 +3
total +86

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
@kbn/cell-actions 1 0 -1
@kbn/content-list-table 9 7 -2
@kbn/core-http-browser 4 0 -4
@kbn/esql-language 3 0 -3
@kbn/handlebars 3 1 -2
@kbn/monaco 11 7 -4
total -16

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/monaco 0 1 +1
@kbn/workspaces 4 5 +1
total +2
Unknown metric groups

API count

id before after diff
@kbn/cell-actions 45 46 +1
@kbn/config-schema 152 163 +11
@kbn/connector-specs 148 149 +1
@kbn/content-list-table 94 96 +2
@kbn/core-http-browser 120 142 +22
@kbn/esql-language 908 930 +22
@kbn/evals 287 293 +6
@kbn/handlebars 33 36 +3
@kbn/inference-tracing 26 29 +3
@kbn/lens-common 1536 1540 +4
@kbn/monaco 222 227 +5
@kbn/react-kibana-context-styled 18 22 +4
@kbn/scout 615 651 +36
@kbn/scout-oblt 606 642 +36
@kbn/scout-search 595 631 +36
@kbn/scout-security 608 644 +36
@kbn/security-hardening 7 13 +6
@kbn/synthtrace-client 297 303 +6
@kbn/workspaces 21 23 +2
@kbn/zod 1275 1281 +6
data 3233 3234 +1
kibanaReact 143 147 +4
lens 716 720 +4
observabilityShared 515 516 +1
screenshotting 32 33 +1
telemetryCollectionManager 31 34 +3
total +262

History

@clintandrewhall clintandrewhall merged commit eed213f into elastic:main Feb 24, 2026
16 checks passed
@clintandrewhall clintandrewhall deleted the feat/docs-utils/4-call-signatures branch February 24, 2026 05:20
nreese pushed a commit to nreese/kibana that referenced this pull request Feb 25, 2026
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes review Team:Operations Kibana-Operations Team v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants