Skip to content

[kbn-docs-utils] Improve CLI output and single-plugin/package build performance#254835

Open
clintandrewhall wants to merge 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/5-cli-perf
Open

[kbn-docs-utils] Improve CLI output and single-plugin/package build performance#254835
clintandrewhall wants to merge 3 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/5-cli-perf

Conversation

@clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Feb 25, 2026

Summary

Makes @kbn/docs-utils CLI output easier to read and single-plugin builds noticeably faster.

Note

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

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

  • Cleaner metrics output. Diagnostic tables (ANY types, missing comments, unexported APIs) now share a consistent format: a header with a count followed by a table, or a simple "none" when there's nothing to report. No more empty tables cluttering the console.
  • Better GitHub links. Source links now point directly to line numbers when available, instead of relying on text-fragment search.
  • Faster filtered builds. When you run with --plugin or --package, the TypeScript project only loads files from that directory instead of the entire repo. Cross-references still resolve correctly thanks to a two-pass plugin discovery.
  • Aggregate docs only in full builds. The plugin directory and deprecation summaries are now written once (not per-plugin) and skipped entirely for filtered builds, since partial data would be misleading.
  • Safer cross-references. Links to plugins outside the current build are preserved as-is instead of being removed as "broken."
  • Neutral terminology. Log messages now use the package ID or say "package(s)" instead of "plugin" where both apply.

Example output

metrics_output_screenshot Screenshot 2026-02-24 at 9 26 30 PM

Commits

Commit Description
984c53f All production code changes
81c02c6 Updated and new unit tests

Test plan

  • yarn test:type_check --project packages/kbn-docs-utils/tsconfig.json passes.
  • yarn test:jest packages/kbn-docs-utils — 326/326 tests pass.
  • ESLint clean on all changed files.
  • Full doc build (node scripts/build_api_docs) produces identical output.
  • Single-plugin build (node scripts/build_api_docs --plugin <id>) completes faster and produces correct cross-references.

…erformance

- Refactor metrics output to use structured table helpers (`printIssueTable`, `printMissingExportsTable`) and improve GitHub links with line-number anchors via `getLink`.
- Introduce two-pass plugin discovery so filtered builds receive an `allPlugins` list for accurate cross-reference resolution while scoping the TypeScript project to a single plugin's directory for faster compilation.
- Gate aggregate documentation (plugin directory, deprecation summaries) behind a check for both `pluginFilter` and `packageFilter` to avoid writing partial data.
@clintandrewhall clintandrewhall requested a review from a team as a code owner February 25, 2026 02:08
@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 25, 2026
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/docs-utils 9 8 -1

Total ESLint disabled count

id before after diff
@kbn/docs-utils 11 10 -1

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.

2 participants