Skip to content

Commit

Permalink
CBL-5613: Swift API docs for Scope using Obj-c reference (#3284)
Browse files Browse the repository at this point in the history
* fix obj-c ref in swift api

* fix some other mistakes or spacing within Swift API Docs
  • Loading branch information
velicuvlad authored May 15, 2024
1 parent b78033e commit 986803e
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Swift/Collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import CouchbaseLiteSwift_Private
/// - Cannot start with _ or %.
/// - Both scope and collection names are case sensitive.
///
/// ## CBLCollection Lifespan
/// ## Collection Lifespan
/// A `Collection` object and its reference remain valid until either
/// the database is closed or the collection itself is deleted, in that case it will
/// throw an NSError with the CBLError.notOpen code while accessing the collection APIs.
Expand Down
6 changes: 3 additions & 3 deletions Swift/Database+Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension Database : QueryFactory {
/// Creates a Query object from the given query string.
///
/// - Parameters:
/// - query Query string
/// - query: Query string.
/// - Returns: A query created by the given query string.
/// - Throws: An error on when the given query string is invalid.
public func createQuery(_ query: String) throws -> Query {
Expand Down Expand Up @@ -53,8 +53,8 @@ extension Database : QueryFactory {
/// will replace the old index. Creating the same index with the same name will be no-ops.
///
/// - Parameters:
/// - config: The index configuration
/// - name: The index name.
/// - config: The index configuration
/// - name: The index name.
/// - Throws: An error on a failure.
@available(*, deprecated, message: "Use database.defaultCollection().createIndex(:name:) instead.")
public func createIndex(_ config: IndexConfiguration, name: String) throws {
Expand Down
4 changes: 2 additions & 2 deletions Swift/From.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public final class From: Query, JoinRouter, WhereRouter, GroupByRouter, OrderByR
return self.limit(limit, offset: nil)
}

/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
///
/// - Parameters:
/// - limit: The limit expression.
Expand Down
12 changes: 7 additions & 5 deletions Swift/FullTextFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public final class FullTextFunction {

/// Creates a full-text match expression with the given full-text index name and the query text
///
/// - Parameter indexName: The index name.
/// - Parameter query: The query string.
/// - Parameters:
/// - indexName: The index name.
/// - query: The query string.
/// - Returns: The full-text match function expression.
@available(*, deprecated, message: "Use FullTextFunction.match(withIndex:query) instead.")
public static func match(indexName: String, query: String) -> ExpressionProtocol {
Expand All @@ -59,10 +60,11 @@ public final class FullTextFunction {
return QueryExpression(CBLQueryFullTextFunction.rank(withIndex: i.toImpl()))
}

/// Creates a full-text match() function with the given full-text index expression and the query text
/// Creates a full-text match() function with the given full-text index expression and the query text
///
/// - Parameter index: The full-text index expression.
/// - Parameter query: The query string.
/// - Parameters:
/// - indexName: TThe full-text index expression.
/// - query: The query string.
/// - Returns: The full-text match() function expression.
public static func match(_ index: IndexExpressionProtocol, query: String) -> ExpressionProtocol {
guard let i = index as? FullTextIndexExpression else {
Expand Down
2 changes: 1 addition & 1 deletion Swift/Function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public final class Function {
/// Creates a TAN(expr) function that returns the tangent of the given numeric expression.
///
/// - Parameter expression: The numeric expression.
/// - Returns: The TAN(expr) function.
/// - Returns: The TAN(expr) function.
public static func tan(_ expression: ExpressionProtocol) -> ExpressionProtocol {
return QueryExpression(CBLQueryFunction.tan(expression.toImpl()))
}
Expand Down
4 changes: 2 additions & 2 deletions Swift/GroupBy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public final class GroupBy: Query, HavingRouter, OrderByRouter, LimitRouter {
return self.limit(limit, offset: nil)
}

/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
///
/// - Parameters:
/// - limit: The limit expression.
Expand Down
4 changes: 2 additions & 2 deletions Swift/Having.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public final class Having: Query, OrderByRouter, LimitRouter {
return self.limit(limit, offset: nil)
}

/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
///
/// - Parameters:
/// - limit: The limit expression.
Expand Down
6 changes: 6 additions & 0 deletions Swift/Index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public protocol Index { }
/// A value index for regular queries.
public final class ValueIndex: Index, CBLIndexConvertible {

// MARK: Internal

private let impl: CBLIndex

init(items: [ValueIndexItem]) {
Expand Down Expand Up @@ -135,12 +137,16 @@ public class FullTextIndexItem {

protocol CBLIndexConvertible {

// MARK: Internal

func toImpl() -> CBLIndex

}

extension Index {

// MARK: Internal

func toImpl() -> CBLIndex {
if let index = self as? CBLIndexConvertible {
return index.toImpl()
Expand Down
6 changes: 3 additions & 3 deletions Swift/IndexBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class IndexBuilder {
/// Create a value index with the given index items. The index items are a list of
/// the properties or expressions to be indexed.
///
/// - Parameter: items The index items.
/// - Parameter items: The index items.
/// - Returns: The ValueIndex.
public static func valueIndex(items: ValueIndexItem...) -> ValueIndex {
return valueIndex(items: items);
Expand All @@ -44,7 +44,7 @@ public class IndexBuilder {
/// the index items are the properties that are used to perform the
/// match operation against with.
///
/// - Parameter: items The index items.
/// - Parameter items: The index items.
/// - Returns: The FullTextIndex.
public static func fullTextIndex(items: FullTextIndexItem...) -> FullTextIndex {
return fullTextIndex(items: items)
Expand All @@ -54,7 +54,7 @@ public class IndexBuilder {
/// the index items are the properties that are used to perform the
/// match operation against with.
///
/// - Parameter: items The index items.
/// - Parameter items: The index items.
/// - Returns: The FullTextIndex.
public static func fullTextIndex(items: [FullTextIndexItem]) -> FullTextIndex {
return FullTextIndex(items: items)
Expand Down
2 changes: 1 addition & 1 deletion Swift/Indexable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public protocol Indexable {
/// Create an index with the index name and config.
func createIndex(withName name: String, config: IndexConfiguration) throws

/// Create an index with the index name and index.
/// Create an index with the index and index name.
func createIndex(_ index: Index, name: String) throws;

/// Delete an index by name.
Expand Down
4 changes: 2 additions & 2 deletions Swift/Joins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public final class Joins: Query, WhereRouter, OrderByRouter, LimitRouter {
return self.limit(limit, offset: nil)
}

/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
///
/// - Parameters:
/// - limit: The limit expression.
Expand Down
3 changes: 1 addition & 2 deletions Swift/MutableDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public final class MutableDocument : Document, MutableDictionaryProtocol {

/// Initializes a new MutableDocument object with the JSON data.
///
/// - Parameters:
/// - json: The JSON string with data.
/// - Parameter json: The JSON string with data.
/// - Throws: An error on a failure.
public convenience init(json: String) throws {
self.init(CBLMutableDocument())
Expand Down
4 changes: 2 additions & 2 deletions Swift/OrderBy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public final class OrderBy: Query, LimitRouter {
return self.limit(limit, offset: nil)
}

/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
/// Creates and chains a Limit object to skip the returned results for the given offset
/// position and to limit the number of results to not more than the given limit value.
///
/// - Parameters:
/// - limit: The limit expression.
Expand Down
6 changes: 3 additions & 3 deletions Swift/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ public class Query {
/// - Parameters:
/// - database: The database to query.
/// - json: JSON data encoding the query. This can be obtained from a Query object's
// JSONRepresentation property.
/// JSONRepresentation property.
init(database: Database, JSONRepresentation json: Data) {
self.database = database
queryImpl = CBLQuery(database: database.impl, jsonRepresentation: json)
}

/// Creates a query, given the query string, as from the expression property.
/// - Parameters:
/// - database The database to query.
/// - expressions String representing the query expression.
/// - database: The database to query.
/// - expressions: String representing the query expression.
init(database: Database, expressions: String) throws {
self.database = database
queryImpl = try database.impl.createQuery(expressions)
Expand Down
3 changes: 1 addition & 2 deletions Swift/QueryFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import Foundation
public protocol QueryFactory {
/// Creates a Query object from the given query string.
///
/// - Parameters:
/// - query Query string
/// - Parameter query: Query string
/// - Returns: A query created by the given query string.
/// - Throws: An error on when the given query string is invalid.
func createQuery(_ query: String) throws -> Query
Expand Down
16 changes: 9 additions & 7 deletions Swift/Replicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public final class Replicator {

/// Activity level of a replicator.
///
/// - stopped: The replicator is finished or hit a fatal error.
/// - offline: The replicator is offline as the remote host is unreachable.
/// - connecting: The replicator is connecting to the remote host.
/// - idle: The replicator is inactive waiting for changes or offline.
/// - busy: The replicator is actively transferring data.
/// - Note:
/// - stopped: The replicator is finished or hit a fatal error.
/// - offline: The replicator is offline as the remote host is unreachable.
/// - connecting: The replicator is connecting to the remote host.
/// - idle: The replicator is inactive waiting for changes or offline.
/// - busy: The replicator is actively transferring data.
public enum ActivityLevel : UInt8 {
case stopped = 0
case offline
Expand Down Expand Up @@ -231,8 +232,9 @@ public final class Replicator {
/// Check whether the document in the given collection is pending to push or not. If the given collection
/// is not part of the replicator, an Invalid Parameter Exception will be thrown.
///
/// - Parameter collection The collection where the document belongs
/// - Parameter documentID: The ID of the document to check
/// - Parameters:
/// - collection: The collection where the document belongs.
/// - documentID: The ID of the document to check.
/// - Returns: true if the document has one or more revisions pending, false otherwise
public func isDocumentPending(_ documentID: String, collection: Collection) throws -> Bool {
var error: NSError?
Expand Down
10 changes: 5 additions & 5 deletions Swift/ReplicatorConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import Foundation
import CouchbaseLiteSwift_Private

/// Replicator type.
///
/// - pushAndPull: Bidirectional; both push and pull
/// - push: Pushing changes to the target
/// - pull: Pulling changes from the target
/// - Note:
/// - pushAndPull: Bidirectional; both push and pull
/// - push: Pushing changes to the target
/// - pull: Pulling changes from the target
public enum ReplicatorType: UInt8 {
case pushAndPull = 0
case push
Expand Down Expand Up @@ -120,7 +120,7 @@ public struct ReplicatorConfiguration {
/// Note: channels that are not accessible to the user will be ignored by
/// Sync Gateway.
///
/// - Note:Channels are not supported in Peer-to-Peer and Database-to-Database replication.
/// - Note: Channels are not supported in Peer-to-Peer and Database-to-Database replication.
@available(*, deprecated, message: """
Use init(target:) and config.addCollection(config:) with a CollectionConfiguration
object instead
Expand Down
9 changes: 6 additions & 3 deletions Swift/Scope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import Foundation
import CouchbaseLiteSwift_Private

/// A CBLScope represents a scope or namespace of the collections.
/// A Scope represents a scope or namespace of the collections.
///
/// The scope implicitly exists when there is at least one collection created under the scope.
/// The default scope is exceptional in that it will always exists even there are no collections
/// under it.
///
/// `CBLScope` Lifespan
/// A `CBLScope` object remain valid until either the database is closed or
/// `Scope` Lifespan
/// A `Scope` object remain valid until either the database is closed or
/// the scope itself is invalidated as all collections in the scope have been deleted.
public final class Scope {

Expand All @@ -50,6 +50,9 @@ public final class Scope {
}

/// Get a collection in the scope by name. If the collection doesn't exist, a nil value will be returned.
/// - Parameter name: Collection name as String.
/// - Returns: Collection object or nil if it doesn't exist.
/// - Throws: An error on when database object is not available.
public func collection(name: String) throws -> Collection? {
return try self.database.collection(name: name, scope: impl.name)
}
Expand Down

0 comments on commit 986803e

Please sign in to comment.