feat: add optional semantic color to discovery output#177
Merged
Conversation
Owner
Author
|
Implementation plan used for this PR ( Plan# Issue 175 Implementation Plan
## Summary
Add optional semantic ANSI color to human-facing discovery and onboarding output while keeping structured/machine output uncolored. Color should be centralized, TTY-aware, and disabled when `NO_COLOR` is set.
## Branch
`175/semantic-discovery-colors`
## Implementation Steps
1. Add a centralized discovery styling module (`src/discovery_style.rs`) with:
- semantic style roles (API title, headings, metadata, next-step labels, HTTP methods, required markers, success/warning)
- ANSI rendering helpers
- enablement detection based on `stdout` TTY and `NO_COLOR`
- unit tests for enablement and rendering behavior
2. Thread optional style support through discovery formatters:
- update `src/docs.rs` to support styled rendering for overview/reference/docs/help list output
- keep plain-text generation behavior available for non-colored paths/tests
- ensure paths/payload-like text remain unstyled
3. Apply style usage in CLI command handlers for required surfaces:
- `src/cli/commands/docs.rs` (`overview`, `commands`, `docs` text modes)
- `src/cli/commands/api.rs` landing output next-step guidance
- `src/cli/commands/config.rs` `config api add` success/partial acceptance/next-step labels
- `src/search.rs` / `src/cli/commands/search.rs` minimal semantic styling for human-readable results
4. Add/adjust tests to satisfy acceptance criteria:
- colored TTY case (formatter rendered with forced-enabled style)
- `NO_COLOR` case (style detection test)
- machine-output case (assert no ANSI escapes in JSON/structured output)
5. Run targeted tests and full quality gate (`cargo test && cargo fmt && cargo clippy`), then fix any regressions.
## Testing Approach
- Targeted unit/integration tests:
- discovery style module tests for TTY and `NO_COLOR` behavior
- docs/search formatting tests for styled output (escape sequences present when style enabled)
- structured output tests ensuring JSON remains parseable and uncolored
- Full project validation:
- `cargo test`
- `cargo fmt --all --check`
- `cargo clippy --all-targets --all-features -- -D warnings` |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
DiscoveryStylemodule for semantic ANSI stylingoverview,commands,docs, API landing,config api add, andsearch)NO_COLOR, while keeping machine/JSON output uncoloredNO_COLORdisablement, and ANSI-free structured outputValidation
cargo testcargo fmt --all --checkcargo clippy --all-targets --all-features -- -D warningsCloses #175