Skip to content

[docs-utils] 4️⃣ Improve missing comments detection#252642

Merged
mistic merged 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-missing-comments
Feb 23, 2026
Merged

[docs-utils] 4️⃣ Improve missing comments detection#252642
mistic merged 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-missing-comments

Conversation

@clintandrewhall
Copy link
Copy Markdown
Contributor

Summary

Improves the missingComments detection in kbn-docs-utils to avoid false positives on destructured parameter nodes. Previously, a parameter like obj in crazyFunction(obj: {hi: string}) was flagged as missing a comment even when its children (obj.hi) were individually documented via JSDoc.

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 JSDoc-annotated function:

/**
 * Who would write such a complicated function?? Ewwww.
 *
 * @param {Object} obj A very crazy parameter.
 * @param {string} obj.hi Greeting on the obj.
 */
export const crazyFunction = (
  obj: { hi: string },
) => { /* ... */ };

Before this PR:

The obj parameter node was flagged as "missing a comment" even though its child obj.hi had a description extracted from @param obj.hi:

{
  "missingComments": [
    { "id": "def-public.crazyFunction.$1", "label": "obj" }
  ]
}
// obj flagged even though its children are documented!

After this PR:

Parameter nodes (identified by .$ in their id) are no longer flagged when at least one child has a description:

{
  "missingComments": []
}
// obj NOT flagged — child obj.hi has a description ✅

Detection Logic

Scenario Flagged? Reason
No description, no children with descriptions Yes Genuinely undocumented
No description, but child has description No Parent is implicitly documented via children
Has own description No Directly documented
Non-parameter node without description Yes Not a parameter, normal rules apply

Changes

  • Refactor missingComment logic in collectStatsForApi() in stats.ts to check for child descriptions on parameter nodes
  • Un-skip the does not flag destructured params when @param obj exists test
  • Simplify the does not flag destructured parameter children when documented test to assert the correct behavior directly

Impact

  • Reduces false positives in missingComments for plugins with well-documented destructured parameters

Made with Cursor

@clintandrewhall clintandrewhall requested a review from a team as a code owner February 11, 2026 02:54
@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)

- Update collectStatsForApi to check for parent or property-level comments.
- Don't flag as missing if property-level JSDoc exists.
- Add validation for required vs optional parameter documentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
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

@mistic mistic enabled auto-merge (squash) February 23, 2026 21:57
@mistic mistic merged commit 9e4ce02 into elastic:main Feb 23, 2026
16 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #5 / discover responsive sidebar should render buttons in data view picker correctly
  • [job] [logs] FTR Configs #140 / discover/ccs_compatible discover search CCS timeout bfetch disabled timeout on single shard shows warning and results
  • [job] [logs] Jest Tests #11 / Header QueryTabHeader should render the immutable timeline call out with correct message

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/config-schema 142 141 -1
@kbn/core-application-browser 25 24 -1
@kbn/core-test-helpers-kbn-server 60 59 -1
@kbn/evals 250 248 -2
@kbn/index-editor 22 21 -1
@kbn/json-ast 30 29 -1
@kbn/lens-common 1381 1380 -1
@kbn/mock-idp-utils 40 39 -1
@kbn/object-versioning 50 48 -2
@kbn/sse-utils-server 7 6 -1
@kbn/synthtrace 314 313 -1
@kbn/test-eui-helpers 96 95 -1
@kbn/visualization-ui-components 139 138 -1
data 2612 2610 -2
dataViews 452 448 -4
fleet 1693 1691 -2
kibanaUtils 423 421 -2
lens 606 605 -1
ruleRegistry 212 211 -1
total -27

History

bhapas pushed a commit to bhapas/kibana that referenced this pull request Feb 25, 2026
## Summary

Improves the `missingComments` detection in `kbn-docs-utils` to avoid
false positives on destructured parameter nodes. Previously, a parameter
like `obj` in `crazyFunction(obj: {hi: string})` was flagged as missing
a comment even when its children (`obj.hi`) were individually documented
via JSDoc.

> [!NOTE]
> This PR is a subset of elastic#247688
for ease of review.
>
> This PR was written with Cursor and `claude-4.5-opus-high`.

### Before / After Example

Given this JSDoc-annotated function:

```typescript
/**
 * Who would write such a complicated function?? Ewwww.
 *
 * @param {Object} obj A very crazy parameter.
 * @param {string} obj.hi Greeting on the obj.
 */
export const crazyFunction = (
  obj: { hi: string },
) => { /* ... */ };
```

**Before this PR:**

The `obj` parameter node was flagged as "missing a comment" even though
its child `obj.hi` had a description extracted from `@param obj.hi`:

```json
{
  "missingComments": [
    { "id": "def-public.crazyFunction.$1", "label": "obj" }
  ]
}
// obj flagged even though its children are documented!
```

**After this PR:**

Parameter nodes (identified by `.$` in their `id`) are no longer flagged
when at least one child has a description:

```json
{
  "missingComments": []
}
// obj NOT flagged — child obj.hi has a description ✅
```

### Detection Logic

| Scenario | Flagged? | Reason |
|----------|----------|--------|
| No description, no children with descriptions | Yes | Genuinely
undocumented |
| No description, but child has description | **No** | Parent is
implicitly documented via children |
| Has own description | No | Directly documented |
| Non-parameter node without description | Yes | Not a parameter, normal
rules apply |

### Changes

- Refactor `missingComment` logic in `collectStatsForApi()` in
`stats.ts` to check for child descriptions on parameter nodes
- Un-skip the `does not flag destructured params when @param obj exists`
test
- Simplify the `does not flag destructured parameter children when
documented` test to assert the correct behavior directly

### Impact

- Reduces false positives in `missingComments` for plugins with
well-documented destructured parameters

Made with [Cursor](https://cursor.com)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
## Summary

Improves the `missingComments` detection in `kbn-docs-utils` to avoid
false positives on destructured parameter nodes. Previously, a parameter
like `obj` in `crazyFunction(obj: {hi: string})` was flagged as missing
a comment even when its children (`obj.hi`) were individually documented
via JSDoc.

> [!NOTE]
> This PR is a subset of elastic#247688
for ease of review.
>
> This PR was written with Cursor and `claude-4.5-opus-high`.

### Before / After Example

Given this JSDoc-annotated function:

```typescript
/**
 * Who would write such a complicated function?? Ewwww.
 *
 * @param {Object} obj A very crazy parameter.
 * @param {string} obj.hi Greeting on the obj.
 */
export const crazyFunction = (
  obj: { hi: string },
) => { /* ... */ };
```

**Before this PR:**

The `obj` parameter node was flagged as "missing a comment" even though
its child `obj.hi` had a description extracted from `@param obj.hi`:

```json
{
  "missingComments": [
    { "id": "def-public.crazyFunction.$1", "label": "obj" }
  ]
}
// obj flagged even though its children are documented!
```

**After this PR:**

Parameter nodes (identified by `.$` in their `id`) are no longer flagged
when at least one child has a description:

```json
{
  "missingComments": []
}
// obj NOT flagged — child obj.hi has a description ✅
```

### Detection Logic

| Scenario | Flagged? | Reason |
|----------|----------|--------|
| No description, no children with descriptions | Yes | Genuinely
undocumented |
| No description, but child has description | **No** | Parent is
implicitly documented via children |
| Has own description | No | Directly documented |
| Non-parameter node without description | Yes | Not a parameter, normal
rules apply |

### Changes

- Refactor `missingComment` logic in `collectStatsForApi()` in
`stats.ts` to check for child descriptions on parameter nodes
- Un-skip the `does not flag destructured params when @param obj exists`
test
- Simplify the `does not flag destructured parameter children when
documented` test to assert the correct behavior directly

### Impact

- Reduces false positives in `missingComments` for plugins with
well-documented destructured parameters

Made with [Cursor](https://cursor.com)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
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