Skip to content

Commit 024efc2

Browse files
committed
Remove dependency from SourceKitLSP on swift-docc-symbolkit
This way all dependencies on the `docc` libraries are wrapped inside the `DocCDocumentation` module.
1 parent bbbc93e commit 024efc2

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ var targets: [Target] = [
509509
.product(name: "Crypto", package: "swift-crypto"),
510510
.product(name: "Markdown", package: "swift-markdown"),
511511
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
512-
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
513512
]
514513
+ swiftPMDependency([
515514
.product(name: "SwiftPM-auto", package: "swift-package-manager")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Foundation
2+
import SymbolKit
3+
4+
/// Generates a JSON string that represents an empty symbol graph for the given module name.
5+
package func emptySymbolGraph(forModule moduleName: String) throws -> String? {
6+
let symbolGraph = SymbolGraph(
7+
metadata: SymbolGraph.Metadata(
8+
formatVersion: SymbolGraph.SemanticVersion(major: 0, minor: 0, patch: 0),
9+
generator: "SourceKit-LSP"
10+
),
11+
module: SymbolGraph.Module(name: moduleName, platform: SymbolGraph.Platform()),
12+
symbols: [],
13+
relationships: []
14+
)
15+
let data = try JSONEncoder().encode(symbolGraph)
16+
return String(data: data, encoding: .utf8)
17+
}

Sources/SourceKitLSP/Documentation/DoccDocumentationHandler.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package import LanguageServerProtocol
1919
import Markdown
2020
import SKUtilities
2121
import SemanticIndex
22-
import SymbolKit
2322

2423
extension DocumentationLanguageService {
2524
package func doccDocumentation(_ req: DoccDocumentationRequest) async throws -> DoccDocumentationResponse {
@@ -107,23 +106,9 @@ extension DocumentationLanguageService {
107106
// Create a dummy symbol graph and tell SwiftDocC to convert the module name.
108107
// The version information isn't really all that important since we're creating
109108
// what is essentially an empty symbol graph.
110-
let emptySymbolGraph = String(
111-
data: try JSONEncoder().encode(
112-
SymbolGraph(
113-
metadata: SymbolGraph.Metadata(
114-
formatVersion: SymbolGraph.SemanticVersion(major: 0, minor: 0, patch: 0),
115-
generator: "SourceKit-LSP"
116-
),
117-
module: SymbolGraph.Module(name: moduleName, platform: SymbolGraph.Platform()),
118-
symbols: [],
119-
relationships: []
120-
)
121-
),
122-
encoding: .utf8
123-
)
124109
return try await documentationManager.renderDocCDocumentation(
125110
symbolUSR: moduleName,
126-
symbolGraph: emptySymbolGraph,
111+
symbolGraph: emptySymbolGraph(forModule: moduleName),
127112
markupFile: snapshot.text,
128113
moduleName: moduleName,
129114
catalogURL: catalogURL

0 commit comments

Comments
 (0)