Skip to content

Commit

Permalink
multiline description for object
Browse files Browse the repository at this point in the history
  • Loading branch information
miyashi committed Mar 21, 2020
1 parent f423789 commit 3e64bc5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Sources/Core/Formatter/MultilineFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,19 @@ class MultilineFormatter: PrettyFormatter {
func objectString(
typeName: String, fields: [(String, String)]
) -> String {
let body: String
if fields.count == 1, let field = fields.first {
body = "\(field.0): \(field.1)"
return "\(typeName)(\(field.0): \(field.1))"
} else {
body = fields
let body = fields
.map { label, value in "\(label): \(value.indentTail(size: "\(label): ".count))" }
.joined(separator: ",\n")
.indentTail(size: "\(typeName)".count)
}
.indent(size: "\(typeName)".count)

return """
\(typeName)(
\(body)
)
"""
return """
\(typeName)(
\(body)
)
"""
}
}
}

0 comments on commit 3e64bc5

Please sign in to comment.