mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Fix docComments with Note: prefix
This commit is contained in:
@@ -69,7 +69,8 @@ public extension String {
|
||||
guard parts.count > 1 else {
|
||||
return false
|
||||
}
|
||||
return !parts[0].contains(" ") && !parts[1].hasPrefix("//")
|
||||
let exclude = ["note", "warning"]
|
||||
return !parts[0].contains(" ") && !exclude.contains(parts[0].lowercased()) && !parts[1].hasPrefix("//")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3178,6 +3178,34 @@ class SyntaxTests: RulesTests {
|
||||
testFormatting(for: input, rule: FormatRules.docComments)
|
||||
}
|
||||
|
||||
func testConvertNoteCommentsToDocComments() {
|
||||
let input = """
|
||||
// Does something
|
||||
// Note: not really
|
||||
func doSomething() {}
|
||||
"""
|
||||
let output = """
|
||||
/// Does something
|
||||
/// Note: not really
|
||||
func doSomething() {}
|
||||
"""
|
||||
testFormatting(for: input, output, rule: FormatRules.docComments)
|
||||
}
|
||||
|
||||
func testConvertURLCommentsToDocComments() {
|
||||
let input = """
|
||||
// Does something
|
||||
// http://example.com
|
||||
func doSomething() {}
|
||||
"""
|
||||
let output = """
|
||||
/// Does something
|
||||
/// http://example.com
|
||||
func doSomething() {}
|
||||
"""
|
||||
testFormatting(for: input, output, rule: FormatRules.docComments)
|
||||
}
|
||||
|
||||
func testMultilineDocCommentReplaced() {
|
||||
let input = """
|
||||
// A class
|
||||
|
||||
Reference in New Issue
Block a user