Skip to content

Commit 5b1a9fc

Browse files
committed
Removing new lines
1 parent b11bbfe commit 5b1a9fc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Sources/SwiftSource/SwiftDeclaration.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@
2121
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
// THE SOFTWARE.
2323

24+
import Foundation
2425
import SwiftSyntax
2526

27+
fileprivate extension String {
28+
func removingNewLines() -> String {
29+
guard self.firstIndex(of: "\n") != nil else {
30+
return self
31+
}
32+
return self
33+
.replacingOccurrences(of: #"\n"#, with: "", options: .regularExpression)
34+
.replacingOccurrences(of: #"\s+"#, with: " ", options: .regularExpression)
35+
}
36+
}
37+
2638

2739
@resultBuilder
2840
fileprivate struct StringBuilder {
@@ -74,7 +86,7 @@ public struct SwiftDeclaration {
7486
self.comments = decl.comments
7587
self.accessLevel = decl.accessLevel
7688
self.keyword = decl.keyword
77-
self.name = Self.buildName(decl: decl, path: path)
89+
self.name = Self.buildName(decl: decl, path: path).removingNewLines()
7890
self.line = location.line
7991
self.column = location.column
8092
}

Sources/swift-doc-coverage/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ struct SwiftDocCoverage: ParsableCommand {
152152
var urls = [URL]()
153153

154154
let regex: NSRegularExpression? = ignoreFilenameRegex.isEmpty
155-
? nil
156-
: try NSRegularExpression(pattern: ignoreFilenameRegex)
155+
? nil
156+
: try NSRegularExpression(pattern: ignoreFilenameRegex)
157157

158158
let url = URL(fileURLWithPath: path)
159159
let resourceKeys = Set<URLResourceKey>([.nameKey, .isDirectoryKey])

0 commit comments

Comments
 (0)