Refactor rule list documentation (#4763)
This commit is contained in:
parent
ad29864d7f
commit
ec38c244fd
|
@ -17,6 +17,7 @@
|
||||||
* None.
|
* None.
|
||||||
|
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
||||||
* Add local links to rule descriptions to every rule listed
|
* Add local links to rule descriptions to every rule listed
|
||||||
in `Rule Directory.md`.
|
in `Rule Directory.md`.
|
||||||
[kattouf](https://github.com/kattouf)
|
[kattouf](https://github.com/kattouf)
|
||||||
|
|
|
@ -42,30 +42,32 @@ public struct RuleListDocumentation {
|
||||||
|
|
||||||
## Default Rules
|
## Default Rules
|
||||||
|
|
||||||
\(defaultRuleDocumentations
|
\(defaultRuleDocumentations.map(makeListEntry).joined(separator: "\n"))
|
||||||
.map { "* [`\($0.ruleIdentifier)`](\($0.ruleIdentifier).md): \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
## Opt-In Rules
|
## Opt-in Rules
|
||||||
|
|
||||||
\(optInRuleDocumentations
|
\(optInRuleDocumentations.map(makeListEntry).joined(separator: "\n"))
|
||||||
.map { "* [`\($0.ruleIdentifier)`](\($0.ruleIdentifier).md): \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
## Analyzer Rules
|
## Analyzer Rules
|
||||||
|
|
||||||
\(analyzerRuleDocumentations
|
\(analyzerRuleDocumentations.map(makeListEntry).joined(separator: "\n"))
|
||||||
.map { "* [`\($0.ruleIdentifier)`](\($0.ruleIdentifier).md): \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func makeListEntry(from rule: RuleDocumentation) -> String {
|
||||||
|
"* [`\(rule.ruleIdentifier)`](\(rule.ruleIdentifier).md): \(rule.ruleName)"
|
||||||
|
}
|
||||||
|
|
||||||
private var swiftSyntaxDashboardContents: String {
|
private var swiftSyntaxDashboardContents: String {
|
||||||
let linterRuleDocumentations = ruleDocumentations.filter(\.isLinterRule)
|
let linterRuleDocumentations = ruleDocumentations.filter(\.isLinterRule)
|
||||||
let rulesUsingSourceKit = linterRuleDocumentations.filter(\.usesSourceKit)
|
let rulesUsingSourceKit = linterRuleDocumentations.filter(\.usesSourceKit)
|
||||||
let rulesNotUsingSourceKit = linterRuleDocumentations.filter { !$0.usesSourceKit }
|
let rulesNotUsingSourceKit = linterRuleDocumentations.filter { !$0.usesSourceKit }
|
||||||
let percentUsingSourceKit = Int(rulesUsingSourceKit.count * 100 / linterRuleDocumentations.count)
|
let percentUsingSourceKit = Int(rulesUsingSourceKit.count * 100 / linterRuleDocumentations.count)
|
||||||
|
let enabledSourceKitRules = rulesUsingSourceKit.filter(\.isEnabledByDefault)
|
||||||
|
let disabledSourceKitRules = rulesUsingSourceKit.filter(\.isDisabledByDefault)
|
||||||
|
let enabledSourceKitFreeRules = rulesNotUsingSourceKit.filter(\.isEnabledByDefault)
|
||||||
|
let disabledSourceKitFreeRules = rulesNotUsingSourceKit.filter(\.isDisabledByDefault)
|
||||||
|
|
||||||
return """
|
return """
|
||||||
# Swift Syntax Dashboard
|
# Swift Syntax Dashboard
|
||||||
|
@ -80,35 +82,23 @@ public struct RuleListDocumentation {
|
||||||
|
|
||||||
## Rules Using SourceKit
|
## Rules Using SourceKit
|
||||||
|
|
||||||
### Enabled By Default (\(rulesUsingSourceKit.filter(\.isEnabledByDefault).count))
|
### Default Rules (\(enabledSourceKitRules.count))
|
||||||
|
|
||||||
\(rulesUsingSourceKit
|
\(enabledSourceKitRules.map(makeListEntry).joined(separator: "\n"))
|
||||||
.filter(\.isEnabledByDefault)
|
|
||||||
.map { "* `\($0.ruleIdentifier)`: \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
### Opt-In (\(rulesUsingSourceKit.filter(\.isDisabledByDefault).count))
|
### Opt-in Rules (\(disabledSourceKitRules.count))
|
||||||
|
|
||||||
\(rulesUsingSourceKit
|
\(disabledSourceKitRules.map(makeListEntry).joined(separator: "\n"))
|
||||||
.filter(\.isDisabledByDefault)
|
|
||||||
.map { "* `\($0.ruleIdentifier)`: \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
## Rules Not Using SourceKit
|
## Rules not Using SourceKit
|
||||||
|
|
||||||
### Enabled By Default (\(rulesNotUsingSourceKit.filter(\.isEnabledByDefault).count))
|
### Default Rules (\(enabledSourceKitFreeRules.count))
|
||||||
|
|
||||||
\(rulesNotUsingSourceKit
|
\(enabledSourceKitFreeRules.map(makeListEntry).joined(separator: "\n"))
|
||||||
.filter(\.isEnabledByDefault)
|
|
||||||
.map { "* `\($0.ruleIdentifier)`: \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
### Opt-In (\(rulesNotUsingSourceKit.filter(\.isDisabledByDefault).count))
|
### Opt-in Rules (\(disabledSourceKitFreeRules.count))
|
||||||
|
|
||||||
\(rulesNotUsingSourceKit
|
\(disabledSourceKitFreeRules.map(makeListEntry).joined(separator: "\n"))
|
||||||
.filter(\.isDisabledByDefault)
|
|
||||||
.map { "* `\($0.ruleIdentifier)`: \($0.ruleName)" }
|
|
||||||
.joined(separator: "\n"))
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue