-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extension point for stylizing console output #687
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #687 +/- ##
==========================================
+ Coverage 87.29% 87.50% +0.21%
==========================================
Files 68 70 +2
Lines 3951 4050 +99
Branches 760 783 +23
==========================================
+ Hits 3449 3544 +95
Misses 396 396
- Partials 106 110 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
At first I thought that this implementation would only support style buckets defined in a central API. But I actually think that the way output style extensions work the style extension can decide which styles to implement. However, the call sites where styles are actually used must also only use styles exist in the provided output style, so we're realistically going to wind up with a centrally agreed upon list of styling options. This differs from an after-the-fact decorator like Vim's syntax highlighting patterns or a markup, then style approach which allows for the style formatter to drop styles it doesn't know what to do with. Do you anticipate any strife with having a limited set of well supported style options or is that an explicit goal of the feature? |
This should behave similarly to a defaultdict, but with attributes.
This is a good point. I set up a default getter in 65a7364 that should allow call sites to use styles that aren't explicitly defined by the selected provider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval here is focused on the proposed OutputStyle extension API since the AnsiEscape example is included only for testing.
This change provides two noteworthy APIs:
Style
class can be imported in other colcon packages to annotate their console output.Some example use cases:
This PR contains a sort of "smoke test" implementation for ANSI color codes. I intend to remove that implementation prior to merging this PR. It is only there to demonstrate behavior, and I'm not interested in debating what colors are appropriate or what the "default" behavior should be. We can consider adding lightweight stylizers directly to
colcon_core
at a later date - this PR is about getting the framework in-place.To see a demo of what the styles look like without performing actual operations, run
python3 -m colcon_core.output_style
.For now, the interface only allows you to select a single output style extension. It may be desirable in the future to differentiate between "primary" extensions of which only a single one should be used, and "secondary" extensions which overlay the primary one.