From ced59cc531073ef85ec78d290938c47192e08378 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 10 Feb 2025 09:08:32 -0800 Subject: [PATCH] Do not validate that all parameters have documentation In particular, not all members of syntax nodes have documentation and it is not realistic to add meaningful documentation to all of them in the near future. --- .../commands/VerifyDocumentation.swift | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift index 61874af5563..15efc2fa2fd 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift @@ -46,11 +46,34 @@ struct VerifyDocumentation: ParsableCommand { } } + func xcodeVersion(xcodebuildExec: URL) throws -> (major: Int, minor: Int) { + let result = try ProcessRunner( + executableURL: xcodebuildExec, + arguments: ["-version"] + ).run(captureStdout: true, captureStderr: false, verbose: false) + let xcodeVersionRegex = Regex { + "Xcode " + Capture(OneOrMore(.digit)) + "." + Capture(OneOrMore(.digit)) + } + guard let match = result.stdout.firstMatch(of: xcodeVersionRegex), let major = Int(match.1), + let minor = Int(match.2) + else { + throw ScriptExectutionError(message: "Failed to extract Xcode version to verify documentation") + } + return (major, minor) + } + func buildDocumentation(product: String) throws { guard let xcodebuildExec = try? Paths.xcodebuildExec else { return } logSection("Building documentation for \(product)") + var otherDoccFlags = ["--warnings-as-errors"] + if try xcodeVersion(xcodebuildExec: xcodebuildExec) >= (16, 0) { + otherDoccFlags.append("--disable-parameters-and-returns-validation") + } try ProcessRunner( executableURL: xcodebuildExec, arguments: [ @@ -60,7 +83,7 @@ struct VerifyDocumentation: ParsableCommand { "-scheme", product, "-destination", "platform=macOS", - "OTHER_DOCC_FLAGS='--warnings-as-errors'", + "OTHER_DOCC_FLAGS=\(otherDoccFlags.joined(separator: " "))", ] ).run(captureStdout: false, captureStderr: false, verbose: self.verbose) }