-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Started to add rationales #5681
base: main
Are you sure you want to change the base?
Conversation
Here's an example of your CHANGELOG entry: * Started to add rationales.
[mildm8nnered](https://github.com/mildm8nnered)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
2e234b3
to
e9e38be
Compare
That's an ambitious plan with 238 existing rules. 😅 But I very much appreciate the effort. This definitely something helpful and can be extended over time with the infrastructure as a starting point. A few thoughts from my side:
|
238 is a lot yes, but I think definitely achievable. I've had a lot of fun writing the ones so far, and it's the kind of thing that you can knock some off on a rainy afternoon. Keep going, and before you know it you're done. I think one think to talk about is "voice" - we could go for something very dry and technical, or somewhat more lighthearted, or even something a bit zany. I think my take is that some kind of middle ground is good, but it would be nice to have some "character" to the rationale's, and to let them be a little bit opionated in places ("almost no-one enables this rule").
So I think I kind of see "Why should I care about this rule/how should I get the most out of it", together with a bit more of a narrative explanation of what it actually is - sometimes the examples can be a little obtuse.
Yep - I think it would be great to have something more formal for config options. It's kind of a pain, because we probably have a lot, and someone has to write the text (see rationale's), but we could definitely do a better job of explaining what individual options do. I think mentions of config options in rationale's are of the kind - "this option is one that you might want to use" rather than documenting the config options per se.
My kind of tacky solution was
So strip "```" for the Terminal and add I think the Terminal case is harder. Adding |
Oh, perfect. Happy to learn you like writing documentation. 😉
I think all these styles are fine. And maybe even a mixture makes them interesting for readers. One consistent style throughout the whole set of rules is anyway almost impossible.
The thing is that without using Markdown, there is no good way to use different text styles and add links to other rules or further references. For the terminal output, all the styling modifiers could be removed afterwards.
Important is that it allows to choose other languages as well. |
Source/SwiftLintBuiltInRules/Rules/Idiomatic/AnonymousArgumentInMultilineClosureRule.swift
Outdated
Show resolved
Hide resolved
:-)
I hadn't thought of it like that, but actually I think that is absolutely the best approach. Nothing too prescriptive, and then we can catch anything that goes too far off-piste, or lacks clarity in individual CR. I think comprehensibility to English as a second language speakers is important, so probably we wouldn't want rationale's in Yorkshire Dialect or Runyonese, sadly.
Any tips for how you think we should go about the styling modifiers stripping? Not entirely keen on having a markdown parser just so that I can de-markdown it :-)
So the intention is to ignore any language code that's present, as an override. |
2db6532
to
7370528
Compare
7370528
to
72177c2
Compare
Fully support that, especially the last part! 🫣
Well, there is swiftlang/swift-markdown from Apple which I had been playing around with a little at that time. A new dependency should be well thought of. As these rationales are going to provide such a huge benefit, that would be justified though I guess. Apart from removing any Markdown styling, it would also allow SwiftLint to check that the whole text is actually valid Markdown before rendering the docs in the build. On the other hand, even unrendered Markdown is so well readable, that I wouldn't complain if we just print the text as is into the console (keeping also URLs). There are also console rendering tools available that could be used to prettify the output. That, however, oughtn't be SwiftLint's job then.
👍 |
c53b70e
to
6ec46a0
Compare
6ec46a0
to
1954f36
Compare
132d531
to
1d9eaf6
Compare
cfe760a
to
a5087ac
Compare
Are these CI failures something that I'm doing @SimplyDanny ? - https://buildkite.com/swiftlint/swiftlint/builds/8753 - they all seem to be concurrency related, but it feels like they come and go at random |
They fail randomly. It's annoying. A retrigger normally helps. I hope this gets fixed by having strict concurrency checking always on by default. But until then there's still a long way to go. Optionally, we can disable warnings reported as errors in Bazel builds for the time being. |
It feel like mine always fail :-) Apart from pushing an empty commit, is there a better way to retrigger them? |
|
||
Possibly you could refactor your closure code and extract some of it into a function. | ||
|
||
Many installations, including SwiftLint's, increase the default warning value from \ |
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.
Should I remove this configuration related note @SimplyDanny ? I've removed most of the others, as per your comment that better configuration docs are coming
Co-authored-by: Danny Mösch <[email protected]>
1724a2e
to
1ce8ea8
Compare
Addresses #4811
The idea is to add a longer explanation of the purpose or motivation behind each rule.
You can now see the output via
swiftlint rules rule_name
For example
And when rendered via Jazzy:
Rationales may contain MarkDown formatting.
When formatting for the console, any lines containing "```" will be stripped from the output, and any lines between them will be indented by four spaces - so in the raitionale definition, code samples should not be indented - no other formatting will be performed, so any MarkDown will appear as is.
When formatting for jazzy, line containing "```" that start a code block will be assumed to be swift code, and will have
swift
appended to them. If you want to format for a different language, then specify that explicitly when starting the code block.This assures that any code samples in the rationale will be formatted in a very similar way to any examples that are provided for the rules - see output and screenshots above.