From 761264652ffadc7356febcf455677e3a9a311d9a Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Thu, 6 Mar 2025 14:38:17 -0800 Subject: [PATCH] Enable the verify documentation GitHub Action check And remove the corresponding subcommand from `swift-syntax-dev-utils`. Fixes #2987 --- .github/workflows/pull_request.yml | 3 +- .../SwiftSyntaxDevUtils.swift | 1 - .../commands/VerifyDocumentation.swift | 90 ------------------- 3 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1b755b0b4ac..871778448c2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -13,8 +13,7 @@ jobs: uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: api_breakage_check_allowlist_path: "Release Notes/api-breakages.txt" - # https://github.com/swiftlang/swift-syntax/issues/2987 - docs_check_enabled: false + docs_check_additional_arguments: "--disable-parameters-and-returns-validation" verify_source_code: name: Validate generated code runs-on: ubuntu-latest diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift index 15f1e3f4269..a138e89c3dd 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift @@ -29,7 +29,6 @@ struct SwiftSyntaxDevUtils: ParsableCommand { GenerateSourceCode.self, LocalPrPrecheck.self, Test.self, - VerifyDocumentation.self, VerifySourceCode.self, ] ) diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift deleted file mode 100644 index 15efc2fa2fd..00000000000 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifyDocumentation.swift +++ /dev/null @@ -1,90 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import ArgumentParser -import Foundation -import RegexBuilder - -struct VerifyDocumentation: ParsableCommand { - static var configuration: CommandConfiguration { - CommandConfiguration( - abstract: "Verify that the docc documentation builds without warnings or errors." - ) - } - - @Flag(help: "Enable verbose logging.") - var verbose: Bool = false - - func targetsInSwiftPackageIndexManifest() throws -> [String] { - let extractTargetRegex = Regex { - #/^ - /# - Capture(ZeroOrMore(.word)) - #/$/# - } - let spiYmlFile = Paths.packageDir.appendingPathComponent(".spi.yml") - let spiYmlFileContents = try String(contentsOf: spiYmlFile) - return - spiYmlFileContents - .components(separatedBy: "\n") - .filter({ !$0.matches(of: extractTargetRegex).isEmpty }) - .map { $0.replacing(extractTargetRegex) { $0.1 } } - .sorted() - } - - func run() throws { - for target in try targetsInSwiftPackageIndexManifest() { - try buildDocumentation(product: target) - } - } - - 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: [ - "docbuild", - "-workspace", - Paths.packageDir.path, - "-scheme", - product, - "-destination", "platform=macOS", - "OTHER_DOCC_FLAGS=\(otherDoccFlags.joined(separator: " "))", - ] - ).run(captureStdout: false, captureStderr: false, verbose: self.verbose) - } -}