Skip to content

Commit 68273e2

Browse files
committed
Merge branch 'apple-main'
2 parents 5c54633 + 037f0bc commit 68273e2

File tree

424 files changed

+22952
-6070
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+22952
-6070
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# This source file is part of the Swift.org open source project
22
#
3-
# Copyright (c) 2021 Apple Inc. and the Swift project authors
3+
# Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
66
# See https://swift.org/LICENSE.txt for license information
77
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
FROM swift:5.5
9+
FROM swift:5.9-focal
1010

1111
# Set up the current build user in the same way done in the Swift.org CI system:
1212
# https://github.com/apple/swift-docker/blob/main/swift-ci/master/ubuntu/20.04/Dockerfile.

Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"location" : "https://github.com/apple/swift-docc-symbolkit",
6161
"state" : {
6262
"branch" : "main",
63-
"revision" : "3889b9673fcf1f1e9651b9143289b6ede462c958"
63+
"revision" : "a6ac00f3534293eeec73c37a396a1bac27816094"
6464
}
6565
},
6666
{
@@ -78,7 +78,7 @@
7878
"location" : "https://github.com/apple/swift-markdown.git",
7979
"state" : {
8080
"branch" : "main",
81-
"revision" : "e5ab90941a8415304b4a4e403253bd59fef00b5a"
81+
"revision" : "75bd31951f69b9df43d433b75152d8add1692378"
8282
}
8383
},
8484
{

Package.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.9
22
/*
33
This source file is part of the Swift.org open source project
44

5-
Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
66
Licensed under Apache License v2.0 with Runtime Library Exception
77

88
See https://swift.org/LICENSE.txt for license information
@@ -90,6 +90,7 @@ let package = Package(
9090
.target(
9191
name: "SwiftDocCTestUtilities",
9292
dependencies: [
93+
.target(name: "SwiftDocC"),
9394
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
9495
],
9596
swiftSettings: swiftSettings

Sources/SwiftDocC/Benchmark/Benchmark.swift

+29-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -94,38 +94,48 @@ private extension Benchmark {
9494
}
9595

9696
/// Logs a one-off metric value.
97-
/// - Parameter event: The metric to add to the log.
98-
public func benchmark<E>(add event: @autoclosure () -> E, benchmarkLog log: Benchmark = .main) where E: BenchmarkMetric {
97+
/// - Parameters:
98+
/// - metric: The one-off metric
99+
/// - log: The log to add the metric to.
100+
public func benchmark<E>(add metric: @autoclosure () -> E, benchmarkLog log: Benchmark = .main) where E: BenchmarkMetric {
99101
guard log.shouldLogMetricType(E.self) else { return }
100102

101-
log.metrics.append(event())
103+
log.metrics.append(metric())
102104
}
103105

104-
/// Starts the given metric.
105-
/// - Parameter event: The metric to start.
106-
public func benchmark<E>(begin event: @autoclosure () -> E, benchmarkLog log: Benchmark = .main) -> E? where E: BenchmarkBlockMetric {
106+
/// Begins the given metric.
107+
/// - Parameters:
108+
/// - metric: The metric to begin measuring.
109+
/// - log: The log that may filter out the metric.
110+
public func benchmark<E>(begin metric: @autoclosure () -> E, benchmarkLog log: Benchmark = .main) -> E? where E: BenchmarkBlockMetric {
107111
guard log.shouldLogMetricType(E.self) else { return nil }
108112

109-
let event = event()
110-
event.begin()
111-
return event
113+
let metric = metric()
114+
metric.begin()
115+
return metric
112116
}
113117

114118
/// Ends the given metric and adds it to the log.
115-
/// - Parameter event: The metric to end and log.
116-
public func benchmark<E>(end event: @autoclosure () -> E?, benchmarkLog log: Benchmark = .main) where E: BenchmarkBlockMetric {
117-
guard log.shouldLogMetricType(E.self), let event = event() else { return }
119+
/// - Parameters:
120+
/// - metric: The metric to end and log.
121+
/// - log: The log to add the metric to.
122+
public func benchmark<E>(end metric: @autoclosure () -> E?, benchmarkLog log: Benchmark = .main) where E: BenchmarkBlockMetric {
123+
guard log.shouldLogMetricType(E.self), let metric = metric() else { return }
118124

119-
event.end()
120-
log.metrics.append(event)
125+
metric.end()
126+
log.metrics.append(metric)
121127
}
122128

123-
/// Ends the given metric and adds it to the log.
124-
/// - Parameter event: The metric to end and log.
125129
@discardableResult
126-
public func benchmark<E, Result>(wrap event: @autoclosure () -> E, benchmarkLog log: Benchmark = .main, body: () throws -> Result) rethrows -> Result where E: BenchmarkBlockMetric {
130+
/// Measures a metric around the given closure.
131+
/// - Parameters:
132+
/// - metric: The metric to measure and log.
133+
/// - log: The log to add the metric to.
134+
/// - body: The closure around which to measure the metric.
135+
/// - Returns: The return value from the closure.
136+
public func benchmark<E, Result>(wrap metric: @autoclosure () -> E, benchmarkLog log: Benchmark = .main, body: () throws -> Result) rethrows -> Result where E: BenchmarkBlockMetric {
127137
if log.shouldLogMetricType(E.self) {
128-
let event = event()
138+
let event = metric()
129139
event.begin()
130140
let result = try body()
131141
event.end()

Sources/SwiftDocC/Benchmark/Metrics/ExternalTopicsHash.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -11,19 +11,18 @@
1111
import Foundation
1212

1313
extension Benchmark {
14-
/// A hash metric produced off the externally resolved links and symbols.
14+
/// A hash metric produced off the externally resolved links.
1515
///
16-
/// Use this metric to verify that your code changes
17-
/// did not affect external resolving.
16+
/// Use this metric to verify that your code changes did not affect external link resolution.
1817
public class ExternalTopicsHash: BenchmarkMetric {
1918
public static let identifier = "external-topics-hash"
2019
public static let displayName = "External Topics Checksum"
2120

22-
/// Creates a new metric and stores the checksum of the given documentation context external topics.
23-
/// - Parameter context: A documentation context.
21+
/// Creates a new metric that stores the checksum of the successfully externally resolved links.
22+
/// - Parameter context: A documentation context that the external links were resolved in.
2423
public init(context: DocumentationContext) {
2524
// If there are no externally resolved topics return quickly.
26-
guard !context.externallyResolvedLinks.isEmpty || !context.externallyResolvedSymbols.isEmpty else {
25+
guard !context.externallyResolvedLinks.isEmpty else {
2726
return
2827
}
2928

@@ -37,7 +36,6 @@ extension Benchmark {
3736
return nil
3837
}
3938
}).sorted().joined()
40-
+ context.externallyResolvedSymbols.map({ $0.absoluteString }).sorted().joined()
4139

4240
result = .checksum(Checksum.md5(of: Data(sourceString.utf8)))
4341
}

0 commit comments

Comments
 (0)