Skip to content

Commit 62c4d26

Browse files
Make ConfigSchemaGen as a subcommand of sourcekit-lsp-dev-utils
1 parent f298dbe commit 62c4d26

File tree

11 files changed

+62
-38
lines changed

11 files changed

+62
-38
lines changed

SourceKitLSPDevUtils/Package.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "SourceKitLSPDevUtils",
7+
platforms: [.macOS(.v10_15)],
8+
products: [
9+
.executable(name: "sourcekit-lsp-dev-utils", targets: ["SourceKitLSPDevUtils"]),
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
13+
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
14+
],
15+
targets: [
16+
.executableTarget(name: "SourceKitLSPDevUtils", dependencies: [
17+
"ConfigSchemaGen",
18+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
19+
]),
20+
.target(
21+
name: "ConfigSchemaGen",
22+
dependencies: [
23+
.product(name: "SwiftSyntax", package: "swift-syntax"),
24+
.product(name: "SwiftParser", package: "swift-syntax"),
25+
]
26+
)
27+
]
28+
)

SourceKitLSPDevUtils/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# sourcekit-lsp-dev-utils
2+
3+
This directory contains utilities for developing SourceKit-LSP.

Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/ConfigSchemaGen.swift renamed to SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import Foundation
22
import SwiftParser
33
import SwiftSyntax
44

5-
@main
6-
struct ConfigSchemaGen {
5+
/// The main entry point for generating a JSON schema and Markdown documentation
6+
/// for the SourceKit-LSP configuration file format
7+
/// (`.sourcekit-lsp/config.json`) from the Swift type definitions in
8+
/// `SKOptions` Swift module.
9+
public struct ConfigSchemaGen {
710
static let projectRoot = URL(fileURLWithPath: #filePath)
811
.deletingLastPathComponent()
912
.deletingLastPathComponent()
1013
.deletingLastPathComponent()
1114
.deletingLastPathComponent()
12-
.deletingLastPathComponent()
1315
static let sourceDir =
1416
projectRoot
1517
.appendingPathComponent("Sources")
@@ -22,7 +24,7 @@ struct ConfigSchemaGen {
2224
.appendingPathComponent("Documentation")
2325
.appendingPathComponent("Configuration File.md")
2426

25-
static func main() throws {
27+
public static func generate() throws {
2628
let sourceFiles = FileManager.default.enumerator(at: sourceDir, includingPropertiesForKeys: nil)!
2729
let typeNameResolver = TypeDeclResolver()
2830

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import ArgumentParser
2+
import ConfigSchemaGen
3+
4+
struct GenerateConfigSchema: ParsableCommand {
5+
static let configuration = CommandConfiguration(
6+
commandName: "generate-config-schema",
7+
abstract: "Generate a JSON schema and documentation for the SourceKit-LSP configuration file"
8+
)
9+
10+
func run() throws {
11+
try ConfigSchemaGen.generate()
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ArgumentParser
2+
3+
@main
4+
struct SourceKitLSPDevUtils: ParsableCommand {
5+
static let configuration = CommandConfiguration(
6+
commandName: "sourcekit-lsp-dev-utils",
7+
abstract: "Utilities for developing SourceKit-LSP",
8+
subcommands: [
9+
GenerateConfigSchema.self,
10+
]
11+
)
12+
}

Utilities/ConfigSchemaGen/Package.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)