[docs-utils] 4️⃣ Extract destructured param property JSDoc#250813
Merged
clintandrewhall merged 3 commits intoelastic:mainfrom Feb 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements extraction of JSDoc @param comments for nested properties in destructured function parameters using dot notation (e.g., @param obj.prop, @param fns.fn1.foo.param). This allows individual properties within destructured parameters to be documented in generated API docs.
Changes:
- Implements parameter comment cache to avoid re-parsing JSDoc for deep structures
- Adds dot-notation parameter matching logic
- Updates fixture code to use named parameters with property-level JSDoc
- Fixes typo: "arguements" → "arguments"
- Reduces missing comments count from 76 to 64 in test plugin
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/kbn-docs-utils/src/types.ts | Adds IssuesByPlugin interface to group validation issues for cleaner function signatures |
| packages/kbn-docs-utils/src/stats.ts | Refactors collectApiStatsForPlugin to accept grouped issues via new interface |
| packages/kbn-docs-utils/src/stats.test.ts | Updates tests to use IssuesByPlugin and adds helper for empty issues |
| packages/kbn-docs-utils/src/cli/tasks/collect_stats.ts | Updates call site to use new grouped issues parameter |
| packages/kbn-docs-utils/src/build_api_declarations/js_doc_utils.ts | Implements dot-notation parameter matching and raw JSDoc parsing for nested properties |
| packages/kbn-docs-utils/src/build_api_declarations/js_doc_utils.test.ts | Updates tests to verify property-level JSDoc extraction works |
| packages/kbn-docs-utils/src/build_api_declarations/build_parameter_decs.ts | Adds ParamCommentCache and applyParamComments for efficient recursive comment application |
| packages/kbn-docs-utils/src/build_api_declarations/build_api_declaration.test.ts | Updates tests to verify nested destructured parameter comments are extracted |
| packages/kbn-docs-utils/src/integration_tests/api_doc_suite.test.ts | Updates tests to verify property-level validation works and renames parameters |
| packages/kbn-docs-utils/src/integration_tests/fixtures/src/plugin_a/public/plugin.ts | Updates expected missing comments count and removes resolved items from list |
| packages/kbn-docs-utils/src/integration_tests/fixtures/src/plugin_a/public/fns.ts | Refactors to use named parameters, adds comprehensive dot-notation JSDoc, fixes typo |
| packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_b.mdx | Updates generated date |
| packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a_foo.mdx | Updates missing comments count and date |
| packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.stats.json | Removes resolved missing comments entries and updates line numbers |
| packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.mdx | Updates missing comments count and date |
| packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.devdocs.json | Adds property descriptions, updates line numbers, changes parameter labels from destructured to named |
| packages/kbn-docs-utils/src/README.md | Improves documentation structure and clarity |
packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.devdocs.json
Outdated
Show resolved
Hide resolved
13 tasks
Contributor
|
Pinging @elastic/kibana-operations (Team:Operations) |
…ters
Implements extraction of JSDoc `@param` comments for nested properties using dot notation (e.g., `@param obj.prop`, `@param fns.fn1.foo.param`). This allows documentation of individual properties within destructured function parameters.
Changes:
- Add `ParamCommentCache` to pre-parse all `@param` entries once per function, avoiding quadratic re-parsing for deep parameter structures
- Implement `applyParamComments()` to recursively apply JSDoc comments to API declarations and their children
- Fix potential crash when `@param tag` has no name token (e.g., malformed `@param {string}`)
- Fix suffix matching that could incorrectly attach `@param options.foo` to an unrelated parameter named `foo`
- Update test fixtures to use named parameters with comprehensive dot-notation JSDoc
- Fix typo: "arguements" → "arguments"
Impact:
- Missing comments count reduced from 76 to 64 for the test plugin
- Destructured parameters now show their JSDoc descriptions in generated API docs
ff1940f to
45f33b1
Compare
Contributor
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements extraction of JSDoc
@paramcomments for nested properties using dot notation (e.g.,@param obj.prop,@param fns.fn1.foo.param). This allows documentation of individual properties within destructured function parameters.Note
This PR is a subset of #247688 for ease of review.
This PR was written with Cursor and
claude-4.5-opus-high.Important
This PR relies on #250810 and includes it as its base commit. This PR will remain draft until that PR is merged and this branch is rebased.
Before / After Example
Given this JSDoc-annotated function:
Before this PR:
The generated API docs had empty descriptions for destructured parameters:
{ "label": "obj", "description": [], "children": [{ "label": "hi", "description": [] // <-- Missing! @param obj.hi was ignored }] }, { "label": "fns", "description": [], "children": [{ "label": "fn1", "description": [], // <-- Missing! @param fns.fn1 was ignored "children": [{ "label": "foo", "description": [], // <-- Missing! @param fns.fn1.foo was ignored "children": [{ "label": "param", "description": [] // <-- Missing! @param fns.fn1.foo.param was ignored }] }] }] }After this PR:
Dot-notation
@paramtags are now correctly extracted:{ "label": "obj", "description": ["A very crazy parameter."], "children": [{ "label": "hi", "description": ["Greeting on the obj."] // ✅ Extracted! }] }, { "label": "fns", "description": ["A destructured object containing two functions."], "children": [{ "label": "fn1", "description": ["The first function."], // ✅ Extracted! "children": [{ "label": "foo", "description": ["A parameter object for fn1."], // ✅ Extracted! "children": [{ "label": "param", "description": ["A nested parameter for foo."] // ✅ Extracted! }] }] }] }Changes
ParamCommentCacheto pre-parse all@paramentries once per function, avoiding quadratic re-parsing for deep parameter structuresapplyParamComments()to recursively apply JSDoc comments to API declarations and their children@param taghas no name token (e.g., malformed@param {string})@param options.footo an unrelated parameter namedfooImpact