Fix docComments with Note: prefix

This commit is contained in:
Nick Lockwood
2023-09-28 07:50:21 +01:00
parent 7d60342368
commit 31a41ef53a
2 changed files with 30 additions and 1 deletions
+2 -1
View File
@@ -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("//")
}
}
+28
View File
@@ -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