Skip to content

Commit 96984a0

Browse files
Update Storage and Functions header comments to Swift markdown (#9706)
* Update Storage header comments to Swift markdown * Update functions headers to use swift markdown * Update FirebaseStorage/Sources/AsyncAwait.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/AsyncAwait.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/AsyncAwait.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/Storage.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/Storage.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/StorageObservableTask.swift Co-authored-by: Nick Cooke <[email protected]> * Update FirebaseStorage/Sources/StorageObservableTask.swift Co-authored-by: Nick Cooke <[email protected]> * run style Co-authored-by: Nick Cooke <[email protected]>
1 parent 41e0d85 commit 96984a0

13 files changed

+278
-232
lines changed

FirebaseFunctions/Sources/Functions.swift

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,29 @@ internal enum FunctionsConstants {
4444

4545
/// The network client to use for http requests.
4646
private let fetcherService: GTMSessionFetcherService
47-
// The projectID to use for all function references.
47+
/// The projectID to use for all function references.
4848
private let projectID: String
49-
// A serializer to encode/decode data and return values.
49+
/// A serializer to encode/decode data and return values.
5050
private let serializer = FUNSerializer()
51-
// A factory for getting the metadata to include with function calls.
51+
/// A factory for getting the metadata to include with function calls.
5252
private let contextProvider: FunctionsContextProvider
5353

54-
// The custom domain to use for all functions references (optional).
54+
/// The custom domain to use for all functions references (optional).
5555
internal let customDomain: String?
5656

57-
// The region to use for all function references.
57+
/// The region to use for all function references.
5858
internal let region: String
5959

6060
// MARK: - Public APIs
6161

6262
/**
63-
* The current emulator origin, or nil if it is not set.
63+
* The current emulator origin, or `nil` if it is not set.
6464
*/
6565
open private(set) var emulatorOrigin: String?
6666

6767
/**
68-
* Creates a Cloud Functions client or returns a pre-existing instance if it already exists.
68+
* Creates a Cloud Functions client using the default or returns a pre-existing instance if it already exists.
69+
* - Returns: A shared Functions instance initialized with the default `FirebaseApp`.
6970
*/
7071
@objc(functions) open class func functions() -> Functions {
7172
return functions(
@@ -78,15 +79,17 @@ internal enum FunctionsConstants {
7879
/**
7980
* Creates a Cloud Functions client with the given app, or returns a pre-existing
8081
* instance if one already exists.
81-
* @param app The app for the Firebase project.
82+
* - Parameter app The app for the Firebase project.
83+
* - Returns: A shared Functions instance initialized with the specified `FirebaseApp`.
8284
*/
8385
@objc(functionsForApp:) open class func functions(app: FirebaseApp) -> Functions {
8486
return functions(app: app, region: FunctionsConstants.defaultRegion, customDomain: nil)
8587
}
8688

8789
/**
8890
* Creates a Cloud Functions client with the default app and given region.
89-
* @param region The region for the http trigger, such as "us-central1".
91+
* - Parameter region The region for the HTTP trigger, such as `us-central1`.
92+
* - Returns: A shared Functions instance initialized with the default `FirebaseApp` and a custom region.
9093
*/
9194
@objc(functionsForRegion:) open class func functions(region: String) -> Functions {
9295
return functions(app: FirebaseApp.app(), region: region, customDomain: nil)
@@ -95,7 +98,8 @@ internal enum FunctionsConstants {
9598
/**
9699
* Creates a Cloud Functions client with the given app and region, or returns a pre-existing
97100
* instance if one already exists.
98-
* @param customDomain A custom domain for the http trigger, such as "https://mydomain.com".
101+
* - Parameter customDomain A custom domain for the HTTP trigger, such as "https://mydomain.com".
102+
* - Returns: A shared Functions instance initialized with the default `FirebaseApp` and a custom HTTP trigger domain.
99103
*/
100104
@objc(functionsForCustomDomain:) open class func functions(customDomain: String) -> Functions {
101105
return functions(app: FirebaseApp.app(),
@@ -105,8 +109,10 @@ internal enum FunctionsConstants {
105109
/**
106110
* Creates a Cloud Functions client with the given app and region, or returns a pre-existing
107111
* instance if one already exists.
108-
* @param app The app for the Firebase project.
109-
* @param region The region for the http trigger, such as "us-central1".
112+
* - Parameters:
113+
* - app: The app for the Firebase project.
114+
* - region: The region for the HTTP trigger, such as `us-central1`.
115+
* - Returns: An instance of `Functions` with a custom app and region.
110116
*/
111117
@objc(functionsForApp:region:) open class func functions(app: FirebaseApp,
112118
region: String) -> Functions {
@@ -116,8 +122,10 @@ internal enum FunctionsConstants {
116122
/**
117123
* Creates a Cloud Functions client with the given app and region, or returns a pre-existing
118124
* instance if one already exists.
119-
* @param app The app for the Firebase project.
120-
* @param customDomain A custom domain for the http trigger, such as "https://mydomain.com".
125+
* - Parameters:
126+
* - app The app for the Firebase project.
127+
* - customDomain A custom domain for the HTTP trigger, such as `https://mydomain.com`.
128+
* - Returns: An instance of `Functions` with a custom app and HTTP trigger domain.
121129
*/
122130
@objc(functionsForApp:customDomain:) open class func functions(app: FirebaseApp,
123131
customDomain: String)
@@ -127,7 +135,7 @@ internal enum FunctionsConstants {
127135

128136
/**
129137
* Creates a reference to the Callable HTTPS trigger with the given name.
130-
* @param name The name of the Callable HTTPS trigger.
138+
* - Parameter name The name of the Callable HTTPS trigger.
131139
*/
132140
@objc(HTTPSCallableWithName:) open func httpsCallable(_ name: String) -> HTTPSCallable {
133141
return HTTPSCallable(functions: self, name: name)
@@ -144,6 +152,7 @@ internal enum FunctionsConstants {
144152
/// - Parameter responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
145153
/// - Parameter encoder: The encoder instance to use to run the encoding.
146154
/// - Parameter decoder: The decoder instance to use to run the decoding.
155+
/// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
147156
open func httpsCallable<Request: Encodable,
148157
Response: Decodable>(_ name: String,
149158
requestAs: Request.Type = Request.self,
@@ -163,6 +172,7 @@ internal enum FunctionsConstants {
163172
/// - Parameter responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
164173
/// - Parameter encoder: The encoder instance to use to run the encoding.
165174
/// - Parameter decoder: The decoder instance to use to run the decoding.
175+
/// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
166176
open func httpsCallable<Request: Encodable,
167177
Response: Decodable>(_ url: URL,
168178
requestAs: Request.Type = Request.self,
@@ -178,8 +188,9 @@ internal enum FunctionsConstants {
178188
/**
179189
* Changes this instance to point to a Cloud Functions emulator running locally.
180190
* See https://firebase.google.com/docs/functions/local-emulator
181-
* @param host The host of the local emulator, such as "localhost".
182-
* @param port The port of the local emulator, for example 5005.
191+
* - Parameters:
192+
* - host: The host of the local emulator, such as "localhost".
193+
* - port: The port of the local emulator, for example 5005.
183194
*/
184195
@objc open func useEmulator(withHost host: String, port: Int) {
185196
let prefix = host.hasPrefix("http") ? "" : "http://"

FirebaseFunctions/Sources/FunctionsError.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ public let FunctionsErrorDetailsKey: String = "details"
102102
}
103103

104104
/**
105-
* Takes an HTTP status code and returns the corresponding FIRFunctionsErrorCode error code.
105+
* Takes an HTTP status code and returns the corresponding `FIRFunctionsErrorCode` error code.
106106
* This is the standard HTTP status code -> error mapping defined in:
107107
* https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
108-
* @param status An HTTP status code.
109-
* @return The corresponding error code, or FIRFunctionsErrorCodeUnknown if none.
108+
* - Parameter status An HTTP status code.
109+
* - Returns: The corresponding error code, or `FIRFunctionsErrorCodeUnknown` if none.
110110
*/
111111
internal func FunctionsCodeForHTTPStatus(_ status: NSInteger) -> FunctionsErrorCode {
112112
switch status {

FirebaseFunctions/Sources/HTTPSCallable.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ open class HTTPSCallableResult: NSObject {
2323
* The data that was returned from the Callable HTTPS trigger.
2424
*
2525
* The data is in the form of native objects. For example, if your trigger returned an
26-
* array, this object would be an NSArray. If your trigger returned a JavaScript object with
27-
* keys and values, this object would be an NSDictionary.
26+
* array, this object would be an `Array<Any>`. If your trigger returned a JavaScript object with
27+
* keys and values, this object would be an instance of `[String: Any]`.
2828
*/
2929
@objc public let data: Any
3030

@@ -34,7 +34,7 @@ open class HTTPSCallableResult: NSObject {
3434
}
3535

3636
/**
37-
* A `HTTPSCallable` is reference to a particular Callable HTTPS trigger in Cloud Functions.
37+
* A `HTTPSCallable` is a reference to a particular Callable HTTPS trigger in Cloud Functions.
3838
*/
3939
@objc(FIRHTTPSCallable)
4040
open class HTTPSCallable: NSObject {
@@ -71,11 +71,11 @@ open class HTTPSCallable: NSObject {
7171
* Executes this Callable HTTPS trigger asynchronously.
7272
*
7373
* The data passed into the trigger can be any of the following types:
74-
* * NSNull
75-
* * NSString
76-
* * NSNumber
77-
* * NSArray<id>, where the contained objects are also one of these types.
78-
* * NSDictionary<NSString, id>, where the values are also one of these types.
74+
* - `nil` or `NSNull`
75+
* - `String`
76+
* - `NSNumber`, or any Swift numeric type bridgeable to `NSNumber`
77+
* - `[Any]`, where the contained objects are also one of these types.
78+
* - `[String: Any]` where the values are also one of these types.
7979
*
8080
* The request to the Cloud Functions backend made by this method automatically includes a
8181
* Firebase Installations ID token to identify the app instance. If a user is logged in with
@@ -85,8 +85,9 @@ open class HTTPSCallable: NSObject {
8585
* regarding the app instance. To stop this, see `Messaging.deleteData()`. It
8686
* resumes with a new FCM Token the next time you call this method.
8787
*
88-
* @param data Parameters to pass to the trigger.
89-
* @param completion The block to call when the HTTPS request has completed.
88+
* - Parameters:
89+
* - data: Parameters to pass to the trigger.
90+
* - completion: The block to call when the HTTPS request has completed.
9091
*/
9192
@objc(callWithObject:completion:) open func call(_ data: Any? = nil,
9293
completion: @escaping (HTTPSCallableResult?,
@@ -115,7 +116,7 @@ open class HTTPSCallable: NSObject {
115116
}
116117

117118
/**
118-
* Executes this Callable HTTPS trigger asynchronously. This API should only be used from Objective C
119+
* Executes this Callable HTTPS trigger asynchronously. This API should only be used from Objective-C.
119120
*
120121
* The request to the Cloud Functions backend made by this method automatically includes a
121122
* Firebase Installations ID token to identify the app instance. If a user is logged in with
@@ -125,7 +126,7 @@ open class HTTPSCallable: NSObject {
125126
* regarding the app instance. To stop this, see `Messaging.deleteData()`. It
126127
* resumes with a new FCM Token the next time you call this method.
127128
*
128-
* @param completion The block to call when the HTTPS request has completed.
129+
* - Parameter completion The block to call when the HTTPS request has completed.
129130
*/
130131
@objc(callWithCompletion:) public func __call(completion: @escaping (HTTPSCallableResult?,
131132
Error?) -> Void) {
@@ -144,8 +145,9 @@ open class HTTPSCallable: NSObject {
144145
* regarding the app instance. To stop this, see `Messaging.deleteData()`. It
145146
* resumes with a new FCM Token the next time you call this method.
146147
*
147-
* @param data Parameters to pass to the trigger.
148-
* @returns The result of the call.
148+
* - Parameter data Parameters to pass to the trigger.
149+
* - Throws: An error if the Cloud Functions invocation failed.
150+
* - Returns: The result of the call.
149151
*/
150152
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
151153
open func call(_ data: Any? = nil) async throws -> HTTPSCallableResult {

FirebaseStorage/Sources/AsyncAwait.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import Foundation
2525
/// - Parameters:
2626
/// - size: The maximum size in bytes to download. If the download exceeds this size,
2727
/// the task will be cancelled and an error will be thrown.
28+
/// - Throws:
29+
/// - An error if the operation failed, for example if the data exceeded `maxSize`.
2830
/// - Returns: Data object.
2931
func data(maxSize: Int64) async throws -> Data {
3032
return try await withCheckedThrowingContinuation { continuation in
@@ -43,6 +45,8 @@ import Foundation
4345
/// - uploadData: The Data to upload.
4446
/// - metadata: Optional StorageMetadata containing additional information (MIME type, etc.)
4547
/// about the object being uploaded.
48+
/// - Throws:
49+
/// - An error if the operation failed, for example if Storage was unreachable.
4650
/// - Returns: StorageMetadata with additional information about the object being uploaded.
4751
func putDataAsync(_ uploadData: Data,
4852
metadata: StorageMetadata? = nil) async throws -> StorageMetadata {
@@ -60,7 +64,9 @@ import Foundation
6064
/// - url: A URL representing the system file path of the object to be uploaded.
6165
/// - metadata: Optional StorageMetadata containing additional information (MIME type, etc.)
6266
/// about the object being uploaded.
63-
/// - Returns: StorageMetadata with additional information about the object being uploaded.
67+
/// - Throws:
68+
/// - An error if the operation failed, for example if no file was present at the specified `url`.
69+
/// - Returns: `StorageMetadata` with additional information about the object being uploaded.
6470
func putFileAsync(from url: URL,
6571
metadata: StorageMetadata? = nil) async throws -> StorageMetadata {
6672
return try await withCheckedThrowingContinuation { continuation in
@@ -75,7 +81,10 @@ import Foundation
7581
///
7682
/// - Parameters:
7783
/// - fileUrl: A URL representing the system file path of the object to be uploaded.
78-
/// - Returns: URL pointing to the file path of the downloaded file.
84+
/// - Throws:
85+
/// - An error if the operation failed, for example if Storage was unreachable
86+
/// or `fileURL` did not reference a valid path on disk.
87+
/// - Returns: A `URL` pointing to the file path of the downloaded file.
7988
func writeAsync(toFile fileURL: URL) async throws -> URL {
8089
return try await withCheckedThrowingContinuation { continuation in
8190
// TODO: Use task to handle progress and cancellation.
@@ -96,8 +105,11 @@ import Foundation
96105
/// - Parameters:
97106
/// - maxResults The maximum number of results to return in a single page. Must be
98107
/// greater than 0 and at most 1000.
108+
/// - Throws:
109+
/// - An error if the operation failed, for example if Storage was unreachable
110+
/// or the storage reference referenced an invalid path.
99111
/// - Returns:
100-
/// - completion A `Result` enum with either the list or an `Error`.
112+
/// - A `StorageListResult` containing the contents of the storage reference.
101113
func list(maxResults: Int64) async throws -> StorageListResult {
102114
typealias ListContinuation = CheckedContinuation<StorageListResult, Error>
103115
return try await withCheckedThrowingContinuation { (continuation: ListContinuation) in
@@ -119,6 +131,9 @@ import Foundation
119131
/// - maxResults The maximum number of results to return in a single page. Must be
120132
/// greater than 0 and at most 1000.
121133
/// - pageToken A page token from a previous call to list.
134+
/// - Throws:
135+
/// - An error if the operation failed, for example if Storage was unreachable
136+
/// or the storage reference referenced an invalid path.
122137
/// - Returns:
123138
/// - completion A `Result` enum with either the list or an `Error`.
124139
func list(maxResults: Int64, pageToken: String) async throws -> StorageListResult {

0 commit comments

Comments
 (0)