-
Notifications
You must be signed in to change notification settings - Fork 247
Improve dump-configuration
with inline comments to explain each rule
#606
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
Comments
JSON5 does support comments, and while it's possible to set Instead, the real issue is this parenthesized part:
We need to do a much better job of keeping the documentation updated. DocC feels like it might at first be the obvious thing to reach for, because the rule documentation is represented as doc comments on the rules themselves, but there are some quirks about the rules (they're behind Thinking about it more, we already have the |
I was doing some exploration yesterday night and got the late memo about json and comments. And yep, injecting comments into json AFTER it’s encoded sounds very hacky.
I think the idea with generating a markdown article into a docc bundle is an interesting path that might work!
Another idea: we could try and generate a Snippet and then use it in `@Snippet` directive in DocC. Since the snippet is just a swift file, we can easily do that in generate-pipeline, and then we have a guarantee that the DocC bundle has an up to date list of rules with comments for each.
It feels like markdown is a better approach, we could also generate a docc table directive to make the list more readable and ahow default values.
**UPD**: After looking at the `generate-pipeline`, I think it should be easy to generate the markdown file.
We could do this a in a few ways:
1. Minimal: just generate a `Documentation/LintFormatRules.md` and link to it from `Documentation/Configuration.md`. We can also link to it from `swift-format --help` for now.
2. Better: convert the `Documentation` directory to a DocC bundle, and then work on publishing it on Swift Package Index.
Let me work on pt 1 as a proof of concept, then proceed to pt2. @allevato, sounds good?
|
Right now,
swift-format dump-configuration
is a great (and automatically up to date!) source of documentation on what rules are available:But, it's not clear what exactly each of those rules does. Luckily, opening the actual source code and the swift file responsible for each particular rule, each rule class seems to have a handy docc comment explaining what that rule does, including both what to expect from linting, and from formatting with that rule.
I think it would be great if
dump-configuration
also rendered some short version of that explanation in an inline-comment, maybe just 1-2 line, before each rule.How would you feel about adding that? If the idea seems reasonable, I would be happy to explore a way to make that and keep that up to date.
UPD:
DumpConfiguration.swift
fetches the defaultConfiguration()
and then encodes it into json, which means it's very elegant and short, but less obvious how to inject comments into it.The text was updated successfully, but these errors were encountered: