[docs-utils] 4️⃣ Improve missing comments detection#252642
Merged
mistic merged 3 commits intoelastic:mainfrom Feb 23, 2026
Merged
[docs-utils] 4️⃣ Improve missing comments detection#252642mistic merged 3 commits intoelastic:mainfrom
mistic merged 3 commits intoelastic:mainfrom
Conversation
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>
92b1305 to
31c96ba
Compare
13 tasks
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
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>
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
Improves the
missingCommentsdetection inkbn-docs-utilsto avoid false positives on destructured parameter nodes. Previously, a parameter likeobjincrazyFunction(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:
Before this PR:
The
objparameter node was flagged as "missing a comment" even though its childobj.hihad 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 theirid) are no longer flagged when at least one child has a description:{ "missingComments": [] } // obj NOT flagged — child obj.hi has a description ✅Detection Logic
Changes
missingCommentlogic incollectStatsForApi()instats.tsto check for child descriptions on parameter nodesdoes not flag destructured params when @param obj existstestdoes not flag destructured parameter children when documentedtest to assert the correct behavior directlyImpact
missingCommentsfor plugins with well-documented destructured parametersMade with Cursor