Skip to content

Commit f3808af

Browse files
author
Clément Le Provost
committed
Generate HTML documentation via Jazzy
NOTE: The documentation is not published so far. - I had to move the definition of `CompletionHandler` so that it was picked up by Jazzy. - I improved/added comments when necessary.
1 parent 367e1a3 commit f3808af

File tree

9 files changed

+124
-67
lines changed

9 files changed

+124
-67
lines changed

.jazzy.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
output: build/doc
2+
# Avoid putting the DocSet within the HTML docs.
3+
# WARNING: The path is relative to the output directory.
4+
docset_path: ../docset
5+
hide_documentation_coverage: true
6+
skip_undocumented: true

AlgoliaSearch.xcodeproj/project.pbxproj

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
5DB251581AAD9F2700945339 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D7495A01A8E277400B0263F /* Client.swift */; };
2424
5DB251591AAD9F2A00945339 /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D7495A61A8E499B00B0263F /* Query.swift */; };
2525
5DB2515A1AAD9F2D00945339 /* Index.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DECA2D91A960BC5001A6088 /* Index.swift */; };
26-
5DB2515B1AAD9F2F00945339 /* Type.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF8C1301A9CA354006E107B /* Type.swift */; };
2726
5DB2515C1AAD9F3300945339 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D74959F1A8E277400B0263F /* Helpers.swift */; };
2827
5DB2515D1AAD9F3B00945339 /* IndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D8FFA391AAB0AB80078869E /* IndexTests.swift */; };
2928
5DB2515E1AAD9F3F00945339 /* ClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D8FFA371AAB08830078869E /* ClientTests.swift */; };
3029
5DECA2DA1A960BC5001A6088 /* Index.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DECA2D91A960BC5001A6088 /* Index.swift */; };
31-
5DF8C1311A9CA354006E107B /* Type.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF8C1301A9CA354006E107B /* Type.swift */; };
3230
BC01E66D1CA43CEE0067670B /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC01E66C1CA43CEE0067670B /* Request.swift */; };
3331
BC01E66E1CA43CEE0067670B /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC01E66C1CA43CEE0067670B /* Request.swift */; };
3432
BC09F7771CAE743900ABB395 /* BrowseIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC09F7761CAE743900ABB395 /* BrowseIterator.swift */; };
@@ -56,7 +54,6 @@
5654
BCD1F5681CC61D160006E227 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D09E1DB1AC0773A00B799A6 /* Network.swift */; };
5755
BCD1F5691CC61D1A0006E227 /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D7495A61A8E499B00B0263F /* Query.swift */; };
5856
BCD1F56A1CC61D1D0006E227 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC01E66C1CA43CEE0067670B /* Request.swift */; };
59-
BCD1F56B1CC61D200006E227 /* Type.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF8C1301A9CA354006E107B /* Type.swift */; };
6057
BCD1F56C1CC61D2D0006E227 /* BrowseIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC09F7761CAE743900ABB395 /* BrowseIterator.swift */; };
6158
BCD1F56D1CC61DB30006E227 /* BrowseIteratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC09F7791CAE7FDF00ABB395 /* BrowseIteratorTests.swift */; };
6259
BCD1F56E1CC61DB80006E227 /* CancelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4A7F3B1CB5373E00AF1DCB /* CancelTests.swift */; };
@@ -112,7 +109,6 @@
112109
5DB2513D1AAD9EE300945339 /* AlgoliaSearch.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AlgoliaSearch.framework; sourceTree = BUILT_PRODUCTS_DIR; };
113110
5DB251471AAD9EE400945339 /* AlgoliaSearch iOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "AlgoliaSearch iOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
114111
5DECA2D91A960BC5001A6088 /* Index.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Index.swift; sourceTree = "<group>"; };
115-
5DF8C1301A9CA354006E107B /* Type.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Type.swift; sourceTree = "<group>"; };
116112
BC01E66C1CA43CEE0067670B /* Request.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = "<group>"; };
117113
BC09F7761CAE743900ABB395 /* BrowseIterator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrowseIterator.swift; sourceTree = "<group>"; };
118114
BC09F7791CAE7FDF00ABB395 /* BrowseIteratorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrowseIteratorTests.swift; sourceTree = "<group>"; };
@@ -214,7 +210,6 @@
214210
5D09E1DB1AC0773A00B799A6 /* Network.swift */,
215211
5D7495A61A8E499B00B0263F /* Query.swift */,
216212
BC01E66C1CA43CEE0067670B /* Request.swift */,
217-
5DF8C1301A9CA354006E107B /* Type.swift */,
218213
BC09F7751CAE742800ABB395 /* Helpers */,
219214
BC0A015F1C9BEDE000CD4A7C /* Offline */,
220215
5D7495811A8E25A600B0263F /* Supporting Files */,
@@ -508,7 +503,6 @@
508503
BC68BC571CB69776007F9655 /* IndexQuery.swift in Sources */,
509504
5D67400F1B4AA22600B326EC /* Cache.swift in Sources */,
510505
BC4A7F391CB5308100AF1DCB /* AsyncOperation.swift in Sources */,
511-
5DF8C1311A9CA354006E107B /* Type.swift in Sources */,
512506
5DECA2DA1A960BC5001A6088 /* Index.swift in Sources */,
513507
5D09E1DC1AC0773A00B799A6 /* Network.swift in Sources */,
514508
5D7495A21A8E277400B0263F /* Client.swift in Sources */,
@@ -548,7 +542,6 @@
548542
5DB251581AAD9F2700945339 /* Client.swift in Sources */,
549543
5DB2515A1AAD9F2D00945339 /* Index.swift in Sources */,
550544
BC01E66E1CA43CEE0067670B /* Request.swift in Sources */,
551-
5DB2515B1AAD9F2F00945339 /* Type.swift in Sources */,
552545
BC09F7781CAE743900ABB395 /* BrowseIterator.swift in Sources */,
553546
);
554547
runOnlyForDeploymentPostprocessing = 0;
@@ -578,7 +571,6 @@
578571
BCD1F56C1CC61D2D0006E227 /* BrowseIterator.swift in Sources */,
579572
BCD1F5681CC61D160006E227 /* Network.swift in Sources */,
580573
BCD1F5661CC61D100006E227 /* Index.swift in Sources */,
581-
BCD1F56B1CC61D200006E227 /* Type.swift in Sources */,
582574
BCD1F5611CC61CFE0006E227 /* AsyncOperation.swift in Sources */,
583575
BCD1F5651CC61D0D0006E227 /* Helpers.swift in Sources */,
584576
BCD1F56A1CC61D1D0006E227 /* Request.swift in Sources */,
@@ -996,6 +988,7 @@
996988
BCD1F55C1CC61C8D0006E227 /* Release */,
997989
);
998990
defaultConfigurationIsVisible = 0;
991+
defaultConfigurationName = Release;
999992
};
1000993
BCD1F5601CC61C8D0006E227 /* Build configuration list for PBXNativeTarget "AlgoliaSearch tvOS Tests" */ = {
1001994
isa = XCConfigurationList;
@@ -1004,6 +997,7 @@
1004997
BCD1F55E1CC61C8D0006E227 /* Release */,
1005998
);
1006999
defaultConfigurationIsVisible = 0;
1000+
defaultConfigurationName = Release;
10071001
};
10081002
/* End XCConfigurationList section */
10091003
};

Source/Client.swift

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,24 @@
2424
import Foundation
2525

2626

27+
/// Signature of most completion handlers used by this library.
28+
///
29+
/// - parameter content: The JSON response (in case of success) or `nil` (in case of error).
30+
/// - parameter error: The encountered error (in case of error) or `nil` (in case of success).
31+
///
32+
/// + Note: `content` and `error` are mutually exclusive: only one will be non-nil.
33+
///
34+
public typealias CompletionHandler = (content: [String: AnyObject]?, error: NSError?) -> Void
35+
36+
2737
/// A version of a software library.
2838
/// Used to construct the `User-Agent` header.
2939
///
3040
@objc public class LibraryVersion: NSObject {
41+
/// Library name.
3142
@objc public let name: String
43+
44+
/// Version string.
3245
@objc public let version: String
3346

3447
@objc public init(name: String, version: String) {
@@ -46,22 +59,23 @@ public func ==(lhs: LibraryVersion, rhs: LibraryVersion) -> Bool {
4659
public let ErrorDomain = "AlgoliaSearch"
4760

4861

49-
/// Entry point in the Swift API.
62+
/// Entry point into the Swift API.
5063
///
51-
/// You should instantiate a Client object with your AppID, ApiKey and Hosts
52-
/// to start using Algolia Search API.
5364
@objc public class Client : NSObject {
5465
// MARK: Constants
5566

5667
/// Error domain used for errors raised by this module.
57-
/// + NOTE: This shortcut is provided for Objective-C bridging. See the top-level `ErrorDomain` constant.
68+
///
69+
/// + Note: This shortcut is provided for Objective-C bridging. See the top-level `ErrorDomain` constant.
70+
///
5871
@objc public static let ErrorDomain = AlgoliaSearch.ErrorDomain
5972

6073
// MARK: Properties
6174

6275
/// HTTP headers that will be sent with every request.
6376
@objc public var headers = [String:String]()
64-
77+
78+
/// Algolia API key.
6579
@objc public var apiKey: String {
6680
didSet {
6781
updateHeadersFromAPIKey()
@@ -74,7 +88,7 @@ public let ErrorDomain = "AlgoliaSearch"
7488
/// The list of libraries used by this client, passed in the `User-Agent` HTTP header of every request.
7589
/// It is initially set to contain only this API Client, but may be overridden to include other libraries.
7690
///
77-
/// * WARNING: The user agent is crucial to proper statistics in your Algolia dashboard. Please leave it as is.
91+
/// + WARNING: The user agent is crucial to proper statistics in your Algolia dashboard. Please leave it as is.
7892
/// This field is publicly exposed only for the sake of other Algolia libraries.
7993
///
8094
@objc public var userAgents: [LibraryVersion] = [] {
@@ -86,18 +100,19 @@ public let ErrorDomain = "AlgoliaSearch"
86100
headers["User-Agent"] = userAgents.map({ return "\($0.name) (\($0.version))"}).joinWithSeparator("; ")
87101
}
88102

89-
/// Default timeout for network requests. Default: 30".
103+
/// Default timeout for network requests. Default: 30 seconds.
90104
@objc public let timeout: NSTimeInterval = 30
91105

92-
/// Timeout for search requests. Default: 5".
106+
/// Timeout for search requests. Default: 5 seconds.
93107
@objc public let searchTimeout: NSTimeInterval = 5
94108

109+
/// Algolia application ID.
95110
@objc public let appID: String
96111

97112
/// Hosts for read queries, in priority order.
98113
/// The first host will always be used, then subsequent hosts in case of retry.
99114
///
100-
/// WARNING: The default values should be appropriate for most use cases.
115+
/// + Warning: The default values should be appropriate for most use cases.
101116
/// Change them only if you know what you are doing.
102117
///
103118
@objc public var readHosts: [String] {
@@ -109,7 +124,7 @@ public let ErrorDomain = "AlgoliaSearch"
109124
/// Hosts for write queries, in priority order.
110125
/// The first host will always be used, then subsequent hosts in case of retry.
111126
///
112-
/// WARNING: The default values should be appropriate for most use cases.
127+
/// + Warning: The default values should be appropriate for most use cases.
113128
/// Change them only if you know what you are doing.
114129
///
115130
@objc public var writeHosts: [String] {
@@ -118,15 +133,11 @@ public let ErrorDomain = "AlgoliaSearch"
118133
}
119134
}
120135

121-
/// Set read and write hosts to the same value (convenience method).
122-
@objc public func setHosts(hosts: [String]) {
123-
readHosts = hosts
124-
writeHosts = hosts
125-
}
126-
127136
// NOTE: Not constant only for the sake of mocking during unit tests.
128137
var session: URLSession
129138

139+
// MARK: Initialization
140+
130141
/// Create a new Algolia Search client.
131142
///
132143
/// - parameter appID: The application ID (available in your Algolia Dashboard).
@@ -170,23 +181,33 @@ public let ErrorDomain = "AlgoliaSearch"
170181
updateHeadersFromUserAgents()
171182
}
172183

184+
/// Set read and write hosts to the same value (convenience method).
185+
///
186+
/// + Warning: The default values should be appropriate for most use cases.
187+
/// Change them only if you know what you are doing.
188+
///
189+
@objc public func setHosts(hosts: [String]) {
190+
readHosts = hosts
191+
writeHosts = hosts
192+
}
193+
173194
/// Set an HTTP header that will be sent with every request.
174195
///
175-
/// NOTE: You may also use the `headers` property directly.
196+
/// + Note: You may also use the `headers` property directly.
176197
///
177198
/// - parameter name: Header name.
178-
/// - parameter value: Value for the header. If nil, the header will be removed.
199+
/// - parameter value: Value for the header. If `nil`, the header will be removed.
179200
///
180-
@objc public func setHeader(name: String!, value: String) {
201+
@objc public func setHeader(name: String, value: String?) {
181202
headers[name] = value
182203
}
183204

184205
/// Get an HTTP header.
185206
///
186-
/// NOTE: You may also use the `headers` property directly.
207+
/// + Note: You may also use the `headers` property directly.
187208
///
188209
/// - parameter name: Header name.
189-
/// - returns: The header's value, or nil if the header does not exist.
210+
/// - returns: The header's value, or `nil` if the header does not exist.
190211
///
191212
@objc public func getHeader(name: String) -> String? {
192213
return headers[name]
@@ -266,7 +287,7 @@ public let ErrorDomain = "AlgoliaSearch"
266287
return Index(client: self, indexName: indexName)
267288
}
268289

269-
/// Strategy when running multiple queries. See `Client.multipleQueries()`.
290+
/// Strategy when running multiple queries. See `Client.multipleQueries(...)`.
270291
///
271292
public enum MultipleQueriesStrategy: String {
272293
/// Execute the sequence of queries until the end.

Source/Error.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,39 @@ import Foundation
2525

2626

2727
/// Status codes.
28-
/// NOTE: Only those likely to be used by Algolia's servers and SDK are listed here.
28+
///
29+
/// + Note: Only those likely to be used by Algolia's servers and SDK are listed here.
2930
///
3031
public enum StatusCode: Int {
3132
// MARK: Regular HTTP status codes
3233

34+
/// Success.
3335
case OK = 200
36+
37+
/// Invalid parameters.
3438
case BadRequest = 400
39+
40+
/// Invalid authentication.
3541
case Unauthorized = 401
42+
43+
/// Operation unauthorized with the provided credentials.
3644
case Forbidden = 403
45+
46+
/// The HTTP method used in the request is not supported for the targeted endpoint.
47+
///
48+
/// + Note: Should never occur when using this library.
49+
///
3750
case MethodNotAllowed = 405
51+
52+
/// The server has encountered a fatal internal error.
3853
case InternalServerError = 500
54+
55+
/// The server is temporarily down.
3956
case ServiceUnavailable = 503
4057

4158
// MARK: Custom status codes
4259

60+
/// Unknown error.
4361
case Unknown = -1
4462

4563
/// The server replied ill-formed JSON (syntax error).
@@ -48,14 +66,17 @@ public enum StatusCode: Int {
4866
/// The server replied an invalid response (grammar error).
4967
case InvalidResponse = 601
5068

69+
/// Test whether a status code represents success.
5170
public static func isSuccess(statusCode: Int) -> Bool {
5271
return statusCode >= 200 && statusCode < 300
5372
}
5473

74+
/// Test whether a status code represents a client error.
5575
public static func isClientError(statusCode: Int) -> Bool {
5676
return statusCode >= 400 && statusCode < 500
5777
}
5878

79+
/// Test whether a status code represents a server error.
5980
public static func isServerError(statusCode: Int) -> Bool {
6081
return statusCode >= 500 && statusCode < 600
6182
}

Source/Index.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,37 @@ import Foundation
2525

2626
/// A proxy to an Algolia index.
2727
///
28-
/// You cannot construct this class directly. Please use `Client.getIndex()` to obtain an instance.
28+
/// + Note: You cannot construct this class directly. Please use `Client.getIndex(_:)` to obtain an instance.
2929
///
3030
@objc public class Index : NSObject {
31+
// MARK: Properties
32+
33+
/// This index's name.
3134
@objc public let indexName: String
35+
36+
/// API client used by this index.
3237
@objc public let client: Client
38+
3339
let urlEncodedIndexName: String
3440

3541
var searchCache: ExpiringCache?
3642

43+
// MAR: - Initialization
44+
45+
/// Create a new index proxy.
3746
@objc init(client: Client, indexName: String) {
3847
self.client = client
3948
self.indexName = indexName
4049
urlEncodedIndexName = indexName.urlEncodedPathComponent()
4150
}
4251

43-
// MARK: - Utils
44-
4552
override public var description: String {
4653
get {
4754
return "Index{\"\(indexName)\"}"
4855
}
4956
}
5057

51-
// MARK: - Core API operations
58+
// MARK: - Operations
5259

5360
/// Add an object to this index.
5461
///
@@ -566,7 +573,7 @@ import Foundation
566573
}
567574

568575
/// Run multiple queries on this index.
569-
/// This method is a variant of `Client.multipleQueries()` where the targeted index is always the receiver.
576+
/// This method is a variant of `Client.multipleQueries(...)` where the targeted index is always the receiver.
570577
///
571578
/// - parameter queries: The queries to run.
572579
/// - parameter completionHandler: Completion handler to be notified of the request's outcome.
@@ -581,7 +588,7 @@ import Foundation
581588
}
582589

583590
/// Run multiple queries on this index.
584-
/// This method is a variant of `Client.multipleQueries()` where the targeted index is always the receiver.
591+
/// This method is a variant of `Client.multipleQueries(...)` where the targeted index is always the receiver.
585592
///
586593
/// - parameter queries: The queries to run.
587594
/// - parameter strategy: The strategy to use.

Source/IndexQuery.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@ import Foundation
2727
/// A search query targeting a specific index.
2828
///
2929
@objc public class IndexQuery: NSObject {
30+
/// Name of the targeted index.
3031
@objc public let indexName: String
32+
33+
/// Query.
3134
@objc public let query: Query
3235

36+
/// Create an index query from an index name and a query.
3337
@objc public init(indexName: String, query: Query) {
3438
self.indexName = indexName
3539
self.query = query
3640
}
3741

42+
/// Create an index query from an `Index` instance and a query.
3843
@objc public init(index: Index, query: Query) {
3944
self.indexName = index.indexName
4045
self.query = query

0 commit comments

Comments
 (0)