Skip to content

Commit

Permalink
Fix missing documentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KaQuMiQ authored Sep 1, 2022
1 parent c753e70 commit f1cca02
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/MQ/Errors/Cancelled.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct Cancelled: TheError {
/// - message: Message associated with this error.
/// Default value is "Cancelled".
/// - displayableMessage: Message which can be displayed
/// to the end user. Default is "Cancelled".
/// to the end user. Default value is based on ``TheErrorDisplayableMessages``.
/// - file: Source code file identifier.
/// Filled automatically based on compile time constants.
/// - line: Line in given source code file.
Expand Down
2 changes: 1 addition & 1 deletion Sources/MQ/Errors/InternalInconsistency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct InternalInconsistency: TheError {
/// - Parameters:
/// - message: Message associated with this error.
/// - displayableMessage: Message which can be displayed
/// to the end user. Default is "Internal inconsistency error".
/// to the end user. Default value is based on ``TheErrorDisplayableMessages``.
/// - file: Source code file identifier.
/// Filled automatically based on compile time constants.
/// - line: Line in given source code file.
Expand Down
2 changes: 2 additions & 0 deletions Sources/MQ/Errors/StringEncodingFailure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public struct StringEncodingFailure: TheError {
/// This value will not be collected in release builds.
/// - message: Message associated with this error.
/// Default value is "StringEncodingFailure".
/// - displayableMessage: Custom message that could be
/// displayed to the end user. Default value is based on ``TheErrorDisplayableMessages``.
/// - file: Source code file identifier.
/// Filled automatically based on compile time constants.
/// - line: Line in given source code file.
Expand Down
23 changes: 20 additions & 3 deletions Sources/MQ/Errors/TheErrorDisplayableMessages.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// Container for displayable error messages.
///
/// ``TheErrorDisplayableMessages`` is a container
/// holding default ``DisplayableMessage`` for errors
/// based on the error type.
Expand Down Expand Up @@ -29,8 +31,11 @@ public enum TheErrorDisplayableMessages {
/// In orded to customize messages use
/// ``TheErrorDisplayableMessages.setMessage(_:for:)`` or
/// ``TheErrorDisplayableMessages.setMessage(_:forGroup:)``.
///
/// - Parameter errorType: Type of the error used to request
/// displayable message.
@inlinable @Sendable public static func message<ErrorType>(
for _: ErrorType.Type
for errorType: ErrorType.Type
) -> DisplayableString
where ErrorType: TheError {
self.storage.access { (messages: inout Dictionary<AnyHashable, DisplayableString>) -> DisplayableString in
Expand Down Expand Up @@ -63,13 +68,18 @@ public enum TheErrorDisplayableMessages {
/// Message can be set only once and only
/// if it was not requested before.
///
/// - Parameters:
/// - message: Message to be assigned to the error type.
/// - errorType: Type of the error which will
/// be associated with the message.
///
/// - Note: Assigned message will be cached
/// and reused. Make sure that it does not
/// provide dynamic value that is expected
/// to be changing over time.
@inlinable @Sendable public static func setMessage<ErrorType>(
_ message: DisplayableString,
for _: ErrorType.Type
for errorType: ErrorType.Type
) where ErrorType: TheError {
self.storage.access { (messages: inout Dictionary<AnyHashable, DisplayableString>) -> Void in
runtimeAssert(
Expand All @@ -88,6 +98,11 @@ public enum TheErrorDisplayableMessages {
/// to use customized message.
/// Message can be set only once.
///
/// - Parameters:
/// - message: Message to be assigned to the error group identifier.
/// - groupIdentifier: Group identifier which will be
/// associated with the message.
///
/// - Note: Assigned message will be cached
/// and reused. Make sure that it does not
/// provide dynamic value that is expected
Expand All @@ -105,13 +120,15 @@ public enum TheErrorDisplayableMessages {
}
}

/// Set the default message for errors.
/// Set the default message for all errors.
///
/// Associate message with the default error group.
/// If default message is not set error type will be
/// used as the message.
/// Message can be set only once.
///
/// - Parameter message: Message to be assigned as default message for all errors.
///
/// - Note: Assigned message will be cached
/// and reused. Make sure that it does not
/// provide dynamic value that is expected
Expand Down
20 changes: 20 additions & 0 deletions Sources/MQ/Errors/TheErrorGroup.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/// Group of errors.
///
/// ``TheErrorGroup`` is a structure used to tag
/// errors to allow easier grouping and hadling
/// of similar or related errors.
///
/// - Note: ``TheErrorGroup`` can be defined using
/// more than one identifier. Order of identifiers
/// mattrers. It is used i.e. to find matching
/// messages from ``TheErrorDisplayableMessages``.
public struct TheErrorGroup {

private var identifiers: Array<Identifier>
}

extension TheErrorGroup {

/// Identifier of error group.
public struct Identifier {

private let identifier: StaticString
Expand All @@ -13,6 +24,7 @@ extension TheErrorGroup {

extension TheErrorGroup.Identifier: Hashable {}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
extension TheErrorGroup.Identifier: ExpressibleByStringLiteral {

public init(
Expand All @@ -24,6 +36,7 @@ extension TheErrorGroup.Identifier: ExpressibleByStringLiteral {

extension TheErrorGroup: Hashable {}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
extension TheErrorGroup: ExpressibleByStringLiteral {

public init(
Expand All @@ -33,6 +46,7 @@ extension TheErrorGroup: ExpressibleByStringLiteral {
}
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
extension TheErrorGroup: ExpressibleByArrayLiteral {

public init(
Expand All @@ -44,7 +58,13 @@ extension TheErrorGroup: ExpressibleByArrayLiteral {

extension TheErrorGroup {

/// Default error group.
///
/// All errors are implicitly matching this group.
public static let `default`: Self = .init()
}

extension TheErrorGroup {

@usableFromInline internal func firstMatchingIdentifier(
_ matches: (Identifier) -> Bool
Expand Down
2 changes: 1 addition & 1 deletion Sources/MQ/Synchronization/CriticalSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where State: Sendable {

/// Initialize ``CriticalSection`` with given initial state.
///
/// - Properties:
/// - Parameters:
/// - state: Initial state.
/// - cleanup: Code executed on deallocation.
public init(
Expand Down
2 changes: 1 addition & 1 deletion Sources/MQ/Utilities/IID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public var wrappedValue: IID { self }

/// Create new instance of IID
/// Create new instance of IID.
public init() {}
}

Expand Down

0 comments on commit f1cca02

Please sign in to comment.