Skip to content

[docs-utils] 4️⃣ Add complex type validation#250825

Merged
clintandrewhall merged 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-complex-types
Feb 11, 2026
Merged

[docs-utils] 4️⃣ Add complex type validation#250825
clintandrewhall merged 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/4-complex-types

Conversation

@clintandrewhall
Copy link
Copy Markdown
Contributor

@clintandrewhall clintandrewhall commented Jan 28, 2026

Summary

This PR adds missingComplexTypeInfo field to ApiStats to track complex types (objects, interfaces, compound types) that are missing descriptions. These types are particularly important to document because their structure isn't self-explanatory.

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 these TypeScript types:

/** User preferences for the application. */
export interface UserPreferences {
  theme: 'light' | 'dark';
  language: string;
}

export interface SearchOptions {   // <-- No description!
  query: string;
  filters: FilterSpec;
}

export type FilterSpec = {         // <-- No description!
  field: string;
  operator: 'eq' | 'neq';
};

export const DEFAULT_TIMEOUT = 5000;  // Simple type, not complex

Before this PR:

All undocumented items were lumped together in missingComments, making it hard to prioritize:

{
  "counts": {
    "missingComments": 4
  },
  "missingComments": [
    { "label": "SearchOptions", "type": "Interface" },
    { "label": "query", "type": "string" },
    { "label": "FilterSpec", "type": "Object" },
    { "label": "DEFAULT_TIMEOUT", "type": "number" }
  ]
}
// No way to identify which items are complex types needing priority!

After this PR:

Complex types are tracked separately for prioritized documentation efforts:

{
  "counts": {
    "missingComments": 4,
    "missingComplexTypeInfo": 2  // ✅ Complex types flagged separately!
  },
  "missingComplexTypeInfo": [
    {
      "id": "def-public.SearchOptions",
      "label": "SearchOptions",
      "type": "Interface",      // ✅ Interface - complex!
      "lineNumber": 6
    },
    {
      "id": "def-public.FilterSpec",
      "label": "FilterSpec",
      "type": "Object",         // ✅ Object - complex!
      "lineNumber": 11
    }
    // UserPreferences NOT flagged (has description)
    // DEFAULT_TIMEOUT NOT flagged (not a complex type)
  ]
}

What Counts as "Complex"?

TypeKind Flagged? Reason
InterfaceKind Yes Structure needs explanation
ObjectKind Yes Inline object types need context
CompoundTypeKind Yes Union/intersection types need clarification
StringKind No Self-explanatory primitive
NumberKind No Self-explanatory primitive
FunctionKind No Tracked by other validations

Why This Matters

Complex types are the highest-value documentation targets:

  • Simple types like string or number are self-documenting
  • But interface SearchOptions with 5 properties? Readers need context
  • Union types like 'eq' | 'neq' | 'gt' | 'lt' need explanation of what each value means

Changes

  • Add trackMissingComplexTypeInfo function in stats.ts to detect and collect these issues during API stat collection
  • Update check_package_docs_cli.ts to include missingComplexTypeInfo in the comments validation check
  • Update mocks, fixture expected issue comments, and snapshot counts to reflect the new tracking

Impact

  • Test plugin shows 22 complex types missing descriptions
  • Validation integrated with --check comments flag in check_package_docs

@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 Jan 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances API documentation validation by tracking complex types (objects, interfaces, compound types) that lack descriptions, adding a new missingComplexTypeInfo field to the ApiStats interface.

Changes:

  • Added missingComplexTypeInfo tracking to identify complex types without descriptions
  • Refactored collectApiStatsForPlugin to accept an IssuesByPlugin object instead of individual parameters
  • Updated tests, mocks, and fixtures to reflect the new validation

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/kbn-docs-utils/src/types.ts Adds missingComplexTypeInfo field to ApiStats and introduces IssuesByPlugin interface
packages/kbn-docs-utils/src/stats.ts Implements trackMissingComplexTypeInfo function and refactors function signature
packages/kbn-docs-utils/src/stats.test.ts Updates all test cases to use new IssuesByPlugin parameter format
packages/kbn-docs-utils/src/integration_tests/api_doc_suite.test.ts Updates stats collection calls and adds missingComplexTypeInfo to snapshot output
packages/kbn-docs-utils/src/integration_tests/snapshots/*.stats.json Updates snapshot with expected missingComplexTypeInfo counts and entries
packages/kbn-docs-utils/src/integration_tests/snapshots/*.mdx Updates generated date stamps in documentation files
packages/kbn-docs-utils/src/integration_tests/__fixtures__/src/plugin_a/* Adds expected issue comments documenting missing complex type info
packages/kbn-docs-utils/src/cli/tasks/collect_stats.ts Updates stats collection to use new IssuesByPlugin parameter
packages/kbn-docs-utils/src/cli/tasks/collect_stats.test.ts Adds missingComplexTypeInfo to mock stats
packages/kbn-docs-utils/src/check_package_docs_cli.ts Includes missingComplexTypeInfo in comment validation check
packages/kbn-docs-utils/src/__test_helpers__/mocks.ts Adds missingComplexTypeInfo to mock data structures
packages/kbn-docs-utils/src/README.md Reformats and updates documentation structure
packages/kbn-docs-utils/scripts/update_fixture_comments.js Adds missingComplexTypeInfo category to fixture comment updater

@clintandrewhall clintandrewhall changed the title [docs-utils] Add complex type validation [docs-utils] 4️⃣ Add complex type validation Jan 29, 2026
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

@clintandrewhall clintandrewhall marked this pull request as ready for review February 10, 2026 20:25
@clintandrewhall clintandrewhall requested a review from a team as a code owner February 10, 2026 20:25
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@clintandrewhall clintandrewhall enabled auto-merge (squash) February 10, 2026 20:25
@clintandrewhall clintandrewhall force-pushed the feat/docs-utils/4-complex-types branch from 067e1c7 to 1f7cb2f Compare February 11, 2026 00:22
- Add missingComplexTypeInfo field to ApiStats.
- Add trackMissingComplexTypeInfo function.
- Update mocks and fixture Expected issues blocks.
@clintandrewhall clintandrewhall force-pushed the feat/docs-utils/4-complex-types branch from e88110e to 4180094 Compare February 11, 2026 02:02
@clintandrewhall clintandrewhall merged commit f947430 into elastic:main Feb 11, 2026
16 checks passed
@clintandrewhall clintandrewhall deleted the feat/docs-utils/4-complex-types branch February 11, 2026 03:50
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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.

4 participants