Skip to content

Commit f5ff722

Browse files
committed
Added fallback option to manual parsing
1 parent c6648d0 commit f5ff722

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Sources/ModuleInterface/Commands/Generate.swift

+11-4
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,24 @@ struct GenerateCommand: CommandProtocol {
114114
return try interfaceForModule(module.name, compilerArguments: module.compilerArguments)
115115
}
116116

117+
fileprivate func documentate(_ sourcetext: String, module: String, options: GenerateCommandOptions) throws {
118+
let output = sourcetext
119+
try createDirectory(path: options.outputFolder)
120+
try write(to: options.outputFolder, module: module, documentation: output)
121+
}
122+
117123
private func generateDocumentation(docs: [String: SourceKitRepresentable], options: GenerateCommandOptions, module: String) throws {
118124
if options.clean {
119125
try CleanCommand.removeModuleInterface(path: options.outputFolder, module: module)
120126
}
121-
guard let sourcetext = docs["key.sourcetext"] as? String else {
127+
if let sourcetext = docs["key.sourcetext"] as? String {
128+
try documentate(sourcetext, module: module, options: options)
129+
} else if let dictionary = docs["key.annotations"] as? SwiftDoc, let sourcetext = process(dictionary: dictionary, options: options) {
130+
try documentate(sourcetext, module: module, options: options)
131+
} else {
122132
let message = "Unable to parse module named \(module)"
123133
throw ModuleInterface.Error.default(message)
124134
}
125-
let output = sourcetext
126-
try createDirectory(path: options.outputFolder)
127-
try write(to: options.outputFolder, module: module, documentation: output)
128135
}
129136

130137
private func write(to path: String, module: String, documentation: String) throws {

0 commit comments

Comments
 (0)