Skip to content

Commit 5d9202f

Browse files
zkiralyZsolt Kiraly
andauthored
Part 2 of the PackageDescription DocC documentation update (#4277)
* Part 2 of the documentation update. * Adopted some of the comments from the companion PR #4276. * A few minor edits to the DocC documentation comments. * More minor edits. * Another minor edit. * Removed some unwanted blank-space. * Changed "apply" to 3rd person present tense. * Removed blank-space. * Fixed a typo/ * Added back the Since docs that were deleted. Co-authored-by: Zsolt Kiraly <[email protected]>
1 parent 911556a commit 5d9202f

36 files changed

+955
-261
lines changed

Sources/PackageDescription/BuildSettings.swift

Lines changed: 92 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,31 @@ public struct BuildConfiguration: Encodable {
2828
/// A condition that limits the application of a build setting.
2929
///
3030
/// By default, build settings are applicable for all platforms and build
31-
/// configurations. Use the ``when(platforms:configuration:)`` modifier to define a build
32-
/// setting for a specific condition. Invalid usage of `.when` emits an error during
33-
/// manifest parsing. For example, it's invalid to specify a `.when` condition with
34-
/// both parameters as `nil`.
31+
/// configurations. Use the `.when` modifier to define a build setting for a
32+
/// specific condition. Invalid usage of `.when` emits an error during manifest
33+
/// parsing. For example, it's invalid to specify a `.when` condition with both
34+
/// parameters as `nil`.
3535
///
36-
/// The following example shows how to use build setting conditions with various APIs:
36+
/// The following example shows how to use build setting conditions with various
37+
/// APIs:
3738
///
38-
/// ...
39-
/// .target(
40-
/// name: "MyTool",
41-
/// dependencies: ["Utility"],
42-
/// cSettings: [
43-
/// .headerSearchPath("path/relative/to/my/target"),
44-
/// .define("DISABLE_SOMETHING", .when(platforms: [.iOS], configuration: .release)),
45-
/// ],
46-
/// swiftSettings: [
47-
/// .define("ENABLE_SOMETHING", .when(configuration: .release)),
48-
/// ],
49-
/// linkerSettings: [
50-
/// .linkedLibrary("openssl", .when(platforms: [.linux])),
51-
/// ]
52-
/// ),
39+
/// ```swift
40+
/// ...
41+
/// .target(
42+
/// name: "MyTool",
43+
/// dependencies: ["Utility"],
44+
/// cSettings: [
45+
/// .headerSearchPath("path/relative/to/my/target"),
46+
/// .define("DISABLE_SOMETHING", .when(platforms: [.iOS], configuration: .release)),
47+
/// ],
48+
/// swiftSettings: [
49+
/// .define("ENABLE_SOMETHING", .when(configuration: .release)),
50+
/// ],
51+
/// linkerSettings: [
52+
/// .linkLibrary("openssl", .when(platforms: [.linux])),
53+
/// ]
54+
/// ),
55+
/// ```
5356
public struct BuildSettingCondition: Encodable {
5457

5558
private let platforms: [Platform]?
@@ -125,10 +128,10 @@ public struct CSetting: Encodable {
125128
///
126129
/// The path must be a directory inside the package.
127130
///
128-
/// - Since: First available in PackageDescription 5.0
131+
/// - Since: First available in PackageDescription 5.0.
129132
///
130133
/// - Parameters:
131-
/// - path: The path of the directory that contains the headers. The path is relative to the target's directory.
134+
/// - path: The path of the directory that contains the headers. The path is relative to the target's directory.
132135
/// - condition: A condition that restricts the application of the build setting.
133136
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CSetting {
134137
return CSetting(name: "headerSearchPath", value: [path], condition: condition)
@@ -138,12 +141,13 @@ public struct CSetting: Encodable {
138141
///
139142
/// If you don't specify a value, the macro's default value is 1.
140143
///
141-
/// - Since: First available in PackageDescription 5.0
144+
/// - Since: First available in PackageDescription 5.0.
142145
///
143146
/// - Parameters:
144147
/// - name: The name of the macro.
145148
/// - value: The value of the macro.
146-
/// - condition: A condition that restricts the application of the build setting.
149+
/// - condition: A condition that restricts the application of the build
150+
/// setting.
147151
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CSetting {
148152
var settingValue = name
149153
if let value = value {
@@ -152,22 +156,23 @@ public struct CSetting: Encodable {
152156
return CSetting(name: "define", value: [settingValue], condition: condition)
153157
}
154158

155-
/// Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool.
159+
/// Sets unsafe flags to pass arbitrary command-line flags to the
160+
/// corresponding build tool.
156161
///
157-
/// As the usage of the word "unsafe" implies, the Swift Package Manager
158-
/// can't safely determine if the build flags have any negative
159-
/// side effect on the build since certain flags can change the behavior of
160-
/// how it performs a build.
162+
/// As the usage of the word “unsafe” implies, Swift Package Manager can't safely determine
163+
/// if the build flags have any negative side effect on the build since
164+
/// certain flags can change the behavior of how it performs a build.
161165
///
162166
/// As some build flags can be exploited for unsupported or malicious
163-
/// behavior, the use of unsafe flags make the products containing this
167+
/// behavior, the use of unsafe flags makes the products containing this
164168
/// target ineligible for use by other packages.
165169
///
166-
/// - Since: First available in PackageDescription 5.0
170+
/// - Since: First available in PackageDescription 5.0.
167171
///
168172
/// - Parameters:
169173
/// - flags: The unsafe flags to set.
170-
/// - condition: A condition that restricts the application of the build setting.
174+
/// - condition: A condition that restricts the application of the build
175+
/// setting.
171176
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CSetting {
172177
return CSetting(name: "unsafeFlags", value: flags, condition: condition)
173178
}
@@ -189,10 +194,10 @@ public struct CXXSetting: Encodable {
189194
///
190195
/// The path must be a directory inside the package.
191196
///
192-
/// - Since: First available in PackageDescription 5.0
197+
/// - Since: First available in PackageDescription 5.0.
193198
///
194199
/// - Parameters:
195-
/// - path: The path of the directory that contains the headers. The path is relative to the target's directory.
200+
/// - path: The path of the directory that contains the headers. The path is
196201
/// - condition: A condition that restricts the application of the build setting.
197202
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting {
198203
return CXXSetting(name: "headerSearchPath", value: [path], condition: condition)
@@ -202,12 +207,13 @@ public struct CXXSetting: Encodable {
202207
///
203208
/// If you don't specify a value, the macro's default value is 1.
204209
///
205-
/// - Since: First available in PackageDescription 5.0
210+
/// - Since: First available in PackageDescription 5.0.
206211
///
207212
/// - Parameters:
208213
/// - name: The name of the macro.
209214
/// - value: The value of the macro.
210-
/// - condition: A condition that restricts the application of the build setting.
215+
/// - condition: A condition that restricts the application of the build
216+
/// setting.
211217
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting {
212218
var settingValue = name
213219
if let value = value {
@@ -216,21 +222,22 @@ public struct CXXSetting: Encodable {
216222
return CXXSetting(name: "define", value: [settingValue], condition: condition)
217223
}
218224

219-
/// Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool.
225+
/// Sets unsafe flags to pass arbitrary command-line flags to the
226+
/// corresponding build tool.
220227
///
221-
/// As the usage of the word "unsafe" implies, the Swift Package Manager
222-
/// can't safely determine if the build flags have any negative
223-
/// side effect on the build since certain flags can change the behavior of
224-
/// how a build is performed.
228+
/// As the usage of the word “unsafe” implies, Swift Package Manager can't safely determine
229+
/// if the build flags have any negative side effect on the build since
230+
/// certain flags can change the behavior of how it performs a build.
225231
///
226232
/// As some build flags can be exploited for unsupported or malicious
227-
/// behavior, a product can't be used as a dependency in another package if one of its targets uses unsafe flags.
233+
/// behavior, you can't use products with unsafe build flags as dependencies in another package.
228234
///
229-
/// - Since: First available in PackageDescription 5.0
235+
/// - Since: First available in PackageDescription 5.0.
230236
///
231237
/// - Parameters:
232238
/// - flags: The unsafe flags to set.
233-
/// - condition: A condition that restricts the application of the build setting.
239+
/// - condition: A condition that restricts the application of the build
240+
/// setting.
234241
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CXXSetting {
235242
return CXXSetting(name: "unsafeFlags", value: flags, condition: condition)
236243
}
@@ -246,41 +253,46 @@ public struct SwiftSetting: Encodable {
246253

247254
/// Defines a compilation condition.
248255
///
249-
/// Use compilation conditions to only compile statements if a certain condition is true.
250-
/// For example, the Swift compiler will only compile the
256+
/// Use compilation conditions to only compile statements if a certain
257+
/// condition is true. For example, the Swift compiler will only compile the
251258
/// statements inside the `#if` block when `ENABLE_SOMETHING` is defined:
252259
///
253-
/// #if ENABLE_SOMETHING
254-
/// ...
255-
/// #endif
260+
/// ```swift
261+
/// #if ENABLE_SOMETHING
262+
/// ...
263+
/// #endif
264+
/// ```
256265
///
257-
/// Unlike macros in C/C++, compilation conditions don't have an
258-
/// associated value.
266+
/// Unlike macros in C/C++, compilation conditions don't have an associated
267+
/// value.
259268
///
260-
/// - Since: First available in PackageDescription 5.0
269+
/// - Since: First available in PackageDescription 5.0.
261270
///
262271
/// - Parameters:
263272
/// - name: The name of the macro.
264-
/// - condition: A condition that restricts the application of the build setting.
273+
/// - condition: A condition that restricts the application of the build
274+
/// setting.
265275
public static func define(_ name: String, _ condition: BuildSettingCondition? = nil) -> SwiftSetting {
266276
return SwiftSetting(name: "define", value: [name], condition: condition)
267277
}
268278

269-
/// Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool.
279+
/// Set unsafe flags to pass arbitrary command-line flags to the
280+
/// corresponding build tool.
270281
///
271-
/// As the usage of the word "unsafe" implies, the Swift Package Manager
272-
/// can't safely determine if the build flags have any negative
273-
/// side effect on the build since certain flags can change the behavior of
274-
/// how a build is performed.
282+
/// As the usage of the word “unsafe” implies, Swift Package Manager can't safely determine
283+
/// if the build flags have any negative side effect on the build since
284+
/// certain flags can change the behavior of how it performs a build.
275285
///
276286
/// As some build flags can be exploited for unsupported or malicious
277-
/// behavior, a product can't be used as a dependency in another package if one of its targets uses unsafe flags.
287+
/// behavior, the use of unsafe flags makes the products containing this
288+
/// target ineligible for use by other packages.
278289
///
279-
/// - Since: First available in PackageDescription 5.0
290+
/// - Since: First available in PackageDescription 5.0.
280291
///
281292
/// - Parameters:
282293
/// - flags: The unsafe flags to set.
283-
/// - condition: A condition that restricts the application of the build setting..
294+
/// - condition: A condition that restricts the application of the build
295+
/// setting.
284296
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> SwiftSetting {
285297
return SwiftSetting(name: "unsafeFlags", value: flags, condition: condition)
286298
}
@@ -297,48 +309,50 @@ public struct LinkerSetting: Encodable {
297309
/// Declares linkage to a system library.
298310
///
299311
/// This setting is most useful when the library can't be linked
300-
/// automatically, such as C++ based libraries and non-modular
301-
/// libraries.
312+
/// automatically, such as C++ based libraries and non-modular libraries.
302313
///
303-
/// - Since: First available in PackageDescription 5.0
314+
/// - Since: First available in PackageDescription 5.0.
304315
///
305316
/// - Parameters:
306317
/// - library: The library name.
307-
/// - condition: A condition that restricts the application of the build setting.
318+
/// - condition: A condition that restricts the application of the build
319+
/// setting.
308320
public static func linkedLibrary(_ library: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
309321
return LinkerSetting(name: "linkedLibrary", value: [library], condition: condition)
310322
}
311323

312324
/// Declares linkage to a system framework.
313325
///
314326
/// This setting is most useful when the framework can't be linked
315-
/// automatically, such as C++ based frameworks and non-modular
316-
/// frameworks.
327+
/// automatically, such as C++ based frameworks and non-modular frameworks.
317328
///
318-
/// - Since: First available in PackageDescription 5.0
329+
/// - Since: First available in PackageDescription 5.0.
319330
///
320331
/// - Parameters:
321332
/// - framework: The framework name.
322-
/// - condition: A condition that restricts the application of the build setting.
333+
/// - condition: A condition that restricts the application of the build
334+
/// setting.
323335
public static func linkedFramework(_ framework: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
324336
return LinkerSetting(name: "linkedFramework", value: [framework], condition: condition)
325337
}
326-
327-
/// Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool.
338+
339+
/// Sets unsafe flags to pass arbitrary command-line flags to the
340+
/// corresponding build tool.
328341
///
329-
/// As the usage of the word "unsafe" implies, the Swift Package Manager
330-
/// can't safely determine if the build flags have any negative
331-
/// side effect on the build since certain flags can change the behavior of
332-
/// how a build is performed.
342+
/// As the usage of the word “unsafe” implies, Swift Package Manager can't safely determine
343+
/// if the build flags have any negative side effect on the build since
344+
/// certain flags can change the behavior of how it performs a build.
333345
///
334346
/// As some build flags can be exploited for unsupported or malicious
335-
/// behavior, a product can't be used as a dependency in another package if one of its targets uses unsafe flags.
347+
/// behavior, the use of unsafe flags makes the products containing this
348+
/// target ineligible for use by other packages.
336349
///
337-
/// - Since: First available in PackageDescription 5.0
350+
/// - Since: First available in PackageDescription 5.0.
338351
///
339352
/// - Parameters:
340353
/// - flags: The unsafe flags to set.
341-
/// - condition: A condition that restricts the application of the build setting.
354+
/// - condition: A condition that restricts the application of the build
355+
/// setting.
342356
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
343357
return LinkerSetting(name: "unsafeFlags", value: flags, condition: condition)
344358
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ``PackageDescription/BuildConfiguration``
2+
3+
## Topics
4+
5+
### Describing Build Configurations
6+
7+
- ``debug``
8+
- ``release``
9+
10+
### Encoding and Decoding
11+
12+
- ``encode(to:)``
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ``PackageDescription/BuildSettingCondition``
2+
3+
## Topics
4+
5+
### Checking for a Build Condition
6+
7+
- ``when(platforms:)``
8+
- ``when(configuration:)``
9+
- ``when(platforms:configuration:)-2991l``
10+
- ``when(platforms:configuration:)-475co``
11+
12+
### Encoding and Decoding
13+
14+
- ``encode(to:)``
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ``PackageDescription/CSetting``
2+
3+
## Topics
4+
5+
### Configuring C Settings
6+
7+
- ``define(_:to:_:)``
8+
- ``headerSearchPath(_:_:)``
9+
- ``unsafeFlags(_:_:)``
10+
11+
### Encoding and Decoding
12+
13+
- ``encode(to:)``
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ``PackageDescription/CXXSetting``
2+
3+
## Topics
4+
5+
### Configuring CXX Settings
6+
7+
- ``define(_:to:_:)``
8+
- ``headerSearchPath(_:_:)``
9+
- ``unsafeFlags(_:_:)``
10+
11+
### Encoding and Decoding
12+
13+
- ``encode(to:)``
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ``PackageDescription/Product/Library/LibraryType/hash(into:)``
2+
3+
@Metadata {
4+
@DocumentationExtension(mergeBehavior: override)
5+
}
6+
7+
Hashes the essential components of this value by feeding them into the given hasher.
8+
9+
Implement this method to conform to the Hashable protocol. The components used for hashing must be the same as the components compared in your type’s == operator implementation. Call hasher.combine(_:) with each of these components.
10+
11+
> Important:
12+
> Never call finalize() on hasher. Doing so may become a compile-time error in the future.
13+
14+
- Parameter into: The hasher to use when combining the components of this instance.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ``PackageDescription/Product/Library/LibraryType/hashValue``
2+
3+
@Metadata {
4+
@DocumentationExtension(mergeBehavior: override)
5+
}
6+
7+
The library type’s hash value.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ``PackageDescription/Product/Library/LibraryType/init(rawValue:)``
2+
3+
@Metadata {
4+
@DocumentationExtension(mergeBehavior: override)
5+
}
6+
7+
Creates a new instance with the specified raw value.
8+
9+
- Parameter rawValue: The raw value to use for the new instance.
10+
11+
If there is no value of the type that corresponds with the specified raw value, this initializer returns `nil`.

0 commit comments

Comments
 (0)