Skip to content

Commit

Permalink
Removing new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhvorost committed Feb 24, 2024
1 parent b11bbfe commit 5b1a9fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Sources/SwiftSource/SwiftDeclaration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import Foundation
import SwiftSyntax

fileprivate extension String {
func removingNewLines() -> String {
guard self.firstIndex(of: "\n") != nil else {
return self
}
return self
.replacingOccurrences(of: #"\n"#, with: "", options: .regularExpression)
.replacingOccurrences(of: #"\s+"#, with: " ", options: .regularExpression)
}
}


@resultBuilder
fileprivate struct StringBuilder {
Expand Down Expand Up @@ -74,7 +86,7 @@ public struct SwiftDeclaration {
self.comments = decl.comments
self.accessLevel = decl.accessLevel
self.keyword = decl.keyword
self.name = Self.buildName(decl: decl, path: path)
self.name = Self.buildName(decl: decl, path: path).removingNewLines()
self.line = location.line
self.column = location.column
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/swift-doc-coverage/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ struct SwiftDocCoverage: ParsableCommand {
var urls = [URL]()

let regex: NSRegularExpression? = ignoreFilenameRegex.isEmpty
? nil
: try NSRegularExpression(pattern: ignoreFilenameRegex)
? nil
: try NSRegularExpression(pattern: ignoreFilenameRegex)

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

0 comments on commit 5b1a9fc

Please sign in to comment.