Skip to content

Commit 735b41f

Browse files
authored
Check more package manifest versions, inject the plugin into all found manifests, revise DocC plugin arguments for latest Swift
1 parent 9ddd686 commit 735b41f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

generate-package-api-docs.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func run() throws {
4040
}
4141

4242
func ensurePluginAvailable() throws {
43-
for manifestName in ["[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "Package.swift"] {
43+
var foundAtLeastOne = false
44+
for manifestName in ["6.2", "6.1", "6.0", "5.10", "5.9", "5.8", "5.7"].map({ "Package@swift-\($0).swift" }) + ["Package.swift"] {
4445
print("⚙️ Checking for manifest \(manifestName)")
4546
let manifestUrl = URL.currentDirectory().appending(component: manifestName)
4647
var manifestContents: String
@@ -49,22 +50,24 @@ func ensurePluginAvailable() throws {
4950
catch let error as NSError where error.isPOSIXError(.ENOENT) { continue }
5051

5152
if !manifestContents.contains(".package(url: \"https://github.com/apple/swift-docc-plugin") {
52-
// This is freely admitted to be quick and dirty. When SE-0301 gets into a release, we can use that.
53-
print("🧬 Injecting missing DocC plugin dependency")
53+
// This is freely admitted to be quick and dirty. Unfortunately, swift package add-dependency doesn't understand version-tagged manifests.
54+
print("🧬 Injecting DocC plugin dependency into \(manifestName)")
5455
guard let depsArrayRange = manifestContents.firstRange(of: "dependencies: [") else {
5556
print("❌ ERROR: Can't inject swift-docc-plugin dependency (can't find deps array).")
5657
exit(1)
5758
}
5859
manifestContents.insert(
59-
contentsOf: "\n.package(url: \"https://github.com/apple/swift-docc-plugin.git\", from: \"1.3.0\"),\n",
60+
contentsOf: "\n.package(url: \"https://github.com/apple/swift-docc-plugin.git\", from: \"1.4.0\"),\n",
6061
at: depsArrayRange.upperBound
6162
)
6263
try manifestContents.write(to: manifestUrl, atomically: true, encoding: .utf8)
6364
}
64-
return
65+
foundAtLeastOne = true
66+
}
67+
guard foundAtLeastOne else {
68+
print("❌ ERROR: Can't inject swift-docc-plugin dependency (no usable manifest found).")
69+
exit(1)
6570
}
66-
print("❌ ERROR: Can't inject swift-docc-plugin dependency (no usable manifest found).")
67-
exit(1)
6871
}
6972

7073
func generateDocs(module: String) throws {
@@ -99,10 +102,9 @@ func generateDocs(module: String) throws {
99102
"--target", module,
100103
"--disable-indexing",
101104
"--experimental-skip-synthesized-symbols",
102-
"--fallback-display-name", module,
103-
"--fallback-bundle-identifier", "codes.vapor.\(packageName.lowercased()).\(module.lowercased())",
104-
"--fallback-bundle-version", "1.0.0",
105-
"--transform-for-static-hosting",
105+
"--enable-inherited-docs",
106+
"--enable-experimental-overloaded-symbol-presentation",
107+
"--enable-experimental-mentioned-in",
106108
"--hosting-base-path", "/\(module.lowercased())",
107109
"--output-path", publicDirectoryUrl.appending(component: "\(module.lowercased())").path,
108110
])

0 commit comments

Comments
 (0)