@@ -36,6 +36,14 @@ extension GenerateDoccReferenceError: CustomStringConvertible {
36
36
}
37
37
}
38
38
39
+ /// The flavor of generated markdown to emit.
40
+ enum OutputStyle : String , EnumerableFlag , ExpressibleByArgument {
41
+ /// DocC-supported markdown
42
+ case docc
43
+ /// GitHub-flavored markdown
44
+ case github
45
+ }
46
+
39
47
@main
40
48
struct GenerateDoccReference : ParsableCommand {
41
49
static let configuration = CommandConfiguration (
@@ -53,7 +61,7 @@ struct GenerateDoccReference: ParsableCommand {
53
61
@Option (
54
62
name: . shortAndLong,
55
63
help: " Use docc flavored markdown for the generated output. " )
56
- var doccFlavored : Bool = false
64
+ var style : OutputStyle = . github
57
65
58
66
func validate( ) throws {
59
67
if outputDirectory != " - " {
@@ -112,12 +120,12 @@ struct GenerateDoccReference: ParsableCommand {
112
120
do {
113
121
if self . outputDirectory == " - " {
114
122
try self . generatePages (
115
- from: toolInfo. command, savingTo: nil , doccFlavored : doccFlavored )
123
+ from: toolInfo. command, savingTo: nil , flavor : style )
116
124
} else {
117
125
try self . generatePages (
118
126
from: toolInfo. command,
119
127
savingTo: URL ( fileURLWithPath: outputDirectory) ,
120
- doccFlavored : doccFlavored )
128
+ flavor : style )
121
129
}
122
130
} catch {
123
131
throw GenerateDoccReferenceError . failedToGenerateDoccReference (
@@ -129,14 +137,14 @@ struct GenerateDoccReference: ParsableCommand {
129
137
/// - Parameters:
130
138
/// - command: The command to parse into a markdown output.
131
139
/// - directory: The directory to save the generated markdown file, printing it if `nil`.
132
- /// - doccFlavored: A Boolean value the indicates whether to generate docc-flavored markdown .
140
+ /// - flavor: The flavor of markdown to use when generating the content .
133
141
/// - Throws: An error if the markdown file cannot be generated or saved.
134
142
func generatePages(
135
- from command: CommandInfoV0 , savingTo directory: URL ? , doccFlavored : Bool
143
+ from command: CommandInfoV0 , savingTo directory: URL ? , flavor : OutputStyle
136
144
)
137
145
throws
138
146
{
139
- let page = command. toMarkdown ( [ ] , doccFlavored : doccFlavored )
147
+ let page = command. toMarkdown ( [ ] , markdownStyle : style )
140
148
141
149
if let directory = directory {
142
150
let fileName = command. doccReferenceFileName
0 commit comments