Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

cottsay
Copy link
Member

@cottsay cottsay commented Mar 4, 2025

This change provides two noteworthy APIs:

  • A set of "buckets" which call out specific categories of console output, like errors, warnings, package names, measurements, etc. This Style class can be imported in other colcon packages to annotate their console output.
  • An extension point for performing specific text augmentation for console output in these buckets.

Some example use cases:

  1. Colorizing (ANSI color escapes, etc)
  2. Formatting (markdown, RST, simple character tables, etc)
  3. Hyperlinks (HTTP, OSC 8, markdown, RST, etc)
  4. Collapsible blocks (Jenkins, GitHub Actions, etc)

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.

@cottsay cottsay added the enhancement New feature or request label Mar 4, 2025
@cottsay cottsay self-assigned this Mar 4, 2025
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 93.63057% with 10 lines in your changes missing coverage. Please review.

Project coverage is 87.51%. Comparing base (c8f5479) to head (7798cca).

Files with missing lines Patch % Lines
colcon_core/output_style/ansi_colors.py 89.47% 3 Missing and 3 partials ⚠️
colcon_core/output_style/__init__.py 94.44% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #687      +/-   ##
==========================================
+ Coverage   87.29%   87.51%   +0.22%     
==========================================
  Files          68       71       +3     
  Lines        3951     4101     +150     
  Branches      760      787      +27     
==========================================
+ Hits         3449     3589     +140     
- Misses        396      399       +3     
- Partials      106      113       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant