Skip to content

Conversation

@johnbute
Copy link
Contributor

@johnbute johnbute commented Mar 12, 2025

Added the no-color-diagnostics flag to allow users to toggle on/off color diagnostics

Continuation of #8316

Motivation:

Not everyone has access to tty, or like colors in their terminal, or are color blind. This feature allows them to control if they want to see colors or not.

Modifications:

Added the color-diagnostics/no-color-diagnostics flag
Added test cases to test for colors
edited snippets to include this feature too

Result:

Developers can now control their color diagnostics when building, running, testing, installing sdks, or browsing code snippets within the swift package learn feature.

@johnbute
Copy link
Contributor Author

Sorry for the new pr, due to a merge conflict and a mistake on my part, I had to do another pr.

@bripeticca
Copy link
Contributor

@swift-ci please test


// helper protocol to share default behavior
/// Helper protocol to configurate the style of diagnostics.
protocol SeverityConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll reiterate the feedback I've given previously: would you clarify the purpose of this protocol? It's only used in a single place and seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This protocol originally was also used in testing, but I had to scrap the testing since it is difficult to test colors when you do not know the environment where the user is running these tests. As it stands, it is only used in one place. Although I agree with you that this added level of abstraction may be unnecessary, if ever someone does figure out a better way of testing color diagnostics, I believe that this protocol would help them out. Thus, for the sake of not adding test debt, I would want to keep this level of abstraction.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer we don't add abstractions until they are absolutely necessary. Whoever would follow up with testing can create such protocol tailored for their purposes in their own PR.

@johnbute
Copy link
Contributor Author

@swift-ci please test

@johnbute
Copy link
Contributor Author

@swift-ci please test

Thanks Max :)

Co-authored-by: Max Desiatov <m_desiatov@apple.com>
@johnbute
Copy link
Contributor Author

@swift-ci please test

@bkhouri
Copy link
Contributor

bkhouri commented Mar 17, 2025

@swift-ci please test windows

@johnbute
Copy link
Contributor Author

@swift-ci please test

@bkhouri
Copy link
Contributor

bkhouri commented Mar 19, 2025

@swift-ci please test windows

@bkhouri
Copy link
Contributor

bkhouri commented Mar 19, 2025

@swift-ci please test linux

Copy link
Contributor

@bkhouri bkhouri left a comment

Choose a reason for hiding this comment

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

Nothing blocking merging of the PR.

Question: do we need to incorporate the "no-color-diagnostics" option with the SwiftBuild build system?

case debug

internal var naturalIntegralValue: Int {
var naturalIntegralValue: Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: it does not appear this is used elsewhere. is this still needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is used in the < operator implementation below.

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, but below where? searching for naturalIntegralValue did not yield any hits on changes software

Copy link
Contributor

Choose a reason for hiding this comment

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

Only a dozen lines below:

lhs.naturalIntegralValue < rhs.naturalIntegralValue

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but that's in unchanged code. So the variable can likely remain internal

"\n\n"
}.terminalString()
:
plain {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Out of curiosity, why do we need two nested plain here? can this something like this

plain {
    "# "
    snippet.name
   "\n\n"
}

}
}.terminalString()
}.terminalString() :
plain {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: do we need the two nested plain?

}.terminalString()
"\n"
}.terminalString() :
plain {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: do we need the two nested plain?

@bkhouri bkhouri requested a review from MaxDesiatov March 20, 2025 20:18
@bkhouri bkhouri merged commit db9fef2 into swiftlang:main Mar 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants