Skip to content

Commit e3b4abf

Browse files
committed
Rename category documentation "path" to "URL"
Since we're creating a hyperlink to it, we want a URL here.
1 parent 1294448 commit e3b4abf

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Sources/SwiftDiagnostics/DiagnosticDecorators/ANSIDiagnosticDecorator.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ extension DiagnosticDecorator where Self == ANSIDiagnosticDecorator {
8484
// Make the category name a link to the documentation, if there is
8585
// documentation.
8686
let categoryName: String
87-
if let documentationPath = category.documentationPath {
88-
categoryName = ANSIAnnotation.hyperlink(category.name, to: documentationPath)
87+
if let documentationURL = category.documentationURL {
88+
categoryName = ANSIAnnotation.hyperlink(category.name, to: "\(documentationURL)")
8989
} else {
9090
categoryName = category.name
9191
}
@@ -240,6 +240,9 @@ private struct ANSIAnnotation {
240240
}
241241

242242
/// Forms a hyperlink to the given URL with the given text.
243+
///
244+
/// This follows the OSC 8 standard for hyperlinks that is supported by
245+
/// a number of different terminals.
243246
static func hyperlink(_ text: String, to url: String) -> String {
244247
"\u{001B}]8;;\(url)\u{001B}\\\(text)\u{001B}]8;;\u{001B}\\"
245248
}

Sources/SwiftDiagnostics/Message.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public struct DiagnosticCategory: Sendable, Hashable {
3939
/// Name that identifies the category, e.g., StrictMemorySafety.
4040
public let name: String
4141

42-
/// Path to a file providing documentation documentation for this category.
43-
public let documentationPath: String?
42+
/// URL providing documentation documentation for this category.
43+
public let documentationURL: String?
4444

45-
public init(name: String, documentationPath: String?) {
45+
public init(name: String, documentationURL: String?) {
4646
self.name = name
47-
self.documentationPath = documentationPath
47+
self.documentationURL = documentationURL
4848
}
4949
}
5050

Tests/SwiftDiagnosticsTest/DiagnosticDecorators/ANSIDiagnosticDecoratorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class ANSIDiagnosticDecoratorTests: XCTestCase {
3838
let decoratedMessageWithCategory = decorator.decorateMessage(
3939
message,
4040
basedOnSeverity: .error,
41-
category: DiagnosticCategory(name: "Filesystem", documentationPath: "http://www.swift.org")
41+
category: DiagnosticCategory(name: "Filesystem", documentationURL: "http://www.swift.org")
4242
)
4343
assertStringsEqualWithDiff(decoratedMessageWithCategory, "\u{1B}[1;31merror: \u{1B}[1;39mFile not found\u{1B}[0;0m [#\u{001B}]8;;http://www.swift.org\u{001B}\\Filesystem\u{001B}]8;;\u{001B}\\]")
4444
}

Tests/SwiftDiagnosticsTest/DiagnosticDecorators/BasicDiagnosticDecoratorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class BasicDiagnosticDecoratorTests: XCTestCase {
3838
let decoratedMessageWithCategory = decorator.decorateMessage(
3939
message,
4040
basedOnSeverity: .error,
41-
category: DiagnosticCategory(name: "Filesystem", documentationPath: "http://www.swift.org")
41+
category: DiagnosticCategory(name: "Filesystem", documentationURL: "http://www.swift.org")
4242
)
4343
assertStringsEqualWithDiff(decoratedMessageWithCategory, "error: File not found [#Filesystem]")
4444
}

0 commit comments

Comments
 (0)