mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
d2643db495
* Add `.jazzy.yaml` configuration file * Update `swiftlint generate-docs` to write docs to a directory rather than a single file * Add jazzy to the Gemfile * Run `bundle update` * Add CI job to run jazzy automatically and publish to GitHub Pages 
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
import Commandant
|
|
import Foundation
|
|
import SwiftLintFramework
|
|
|
|
struct GenerateDocsCommand: CommandProtocol {
|
|
let verb = "generate-docs"
|
|
let function = "Generates markdown documentation for all rules"
|
|
|
|
func run(_ options: GenerateDocsOptions) -> Result<(), CommandantError<()>> {
|
|
let docs = RuleListDocumentation(masterRuleList)
|
|
do {
|
|
try docs.write(to: URL(fileURLWithPath: options.path))
|
|
} catch {
|
|
return .failure(.usageError(description: error.localizedDescription))
|
|
}
|
|
|
|
return .success(())
|
|
}
|
|
}
|
|
|
|
struct GenerateDocsOptions: OptionsProtocol {
|
|
let path: String
|
|
|
|
static func create(_ path: String) -> GenerateDocsOptions {
|
|
return self.init(path: path)
|
|
}
|
|
|
|
static func evaluate(_ mode: CommandMode) -> Result<GenerateDocsOptions, CommandantError<CommandantError<()>>> {
|
|
return create
|
|
<*> mode <| Option(key: "path", defaultValue: "rule_docs",
|
|
usage: "the directory where the documentation should be saved. defaults to `rule_docs`.")
|
|
}
|
|
}
|