Skip to content

Commit

Permalink
More doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
philippzagar committed Dec 7, 2023
1 parent 6eda4f1 commit 641a774
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Sources/Spezi/Dependencies/DependencyCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ public struct DependencyCollection: DependencyDeclaration {
///
/// ### Usage
///
/// The `ExampleDependencyBuilder` enforces certain type constraints (e.g., `SomeTypeConstraint`, more specific than `Module`) during aggregation of ``Module/Dependency``s (``Module``s) via a result builder. The individual dependency expressions within the result builder conforming to `SomeTypeConstraint` are then transformed to a ``DependencyCollection`` via ``DependencyCollection/init(for:singleEntry:)``.
/// The `SomeCustomDependencyBuilder` enforces certain type constraints (e.g., `SomeTypeConstraint`, more specific than ``Module`) during aggregation of ``Module/Dependency``s (``Module``s) via a result builder.
/// The individual dependency expressions within the result builder conforming to `SomeTypeConstraint` are then transformed to a ``DependencyCollection`` via ``DependencyCollection/init(for:singleEntry:)``.
///
/// ```swift
/// @resultBuilder
/// public enum ExampleDependencyBuilder: DependencyCollectionBuilder {
/// public enum SomeCustomDependencyBuilder: DependencyCollectionBuilder {
/// public static func buildExpression<T: SomeTypeConstraint>(_ expression: @escaping @autoclosure () -> T) -> DependencyCollection {
/// DependencyCollection(singleEntry: expression)
/// }
/// }
/// ```
///
/// See `_DependencyPropertyWrapper/init(using:)` for a continued example regarding the usage of the implemented result builder.
public init<Dependency: Module>(for type: Dependency.Type = Dependency.self, singleEntry: @escaping (() -> Dependency)) {
self.init(DependencyContext(for: type, defaultValue: singleEntry))
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Spezi/Dependencies/DependencyCollectionBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/// ```swift
/// static func buildExpression<M: Module>(_ expression: @escaping @autoclosure () -> M) -> DependencyCollection
/// ```
///
/// See ``DependencyCollection/init(for:singleEntry:)`` for an example conformance implementation of the ``DependencyCollectionBuilder``.
public protocol DependencyCollectionBuilder {}


Expand Down
4 changes: 3 additions & 1 deletion Sources/Spezi/Dependencies/DependencyPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extension _DependencyPropertyWrapper: ModuleArrayDependency where Value == [any
/// ### Usage
///
/// The `ExampleModule` is initialized with nested ``Module/Dependency``s (``Module``s) enforcing certain type constraints via the `SomeCustomDependencyBuilder`.
/// Spezi automatically injects declared ``Dependency``s within the passed ``Dependency``s from the initializer, enabling proper nesting of ``Module``s.
/// Spezi automatically injects declared ``Dependency``s within the passed ``Dependency``s in the initializer, enabling proper nesting of ``Module``s.
///
/// ```swift
/// class ExampleModule: Module {
Expand All @@ -116,6 +116,8 @@ extension _DependencyPropertyWrapper: ModuleArrayDependency where Value == [any
/// }
/// }
/// ```
///
/// See ``DependencyCollection/init(for:singleEntry:)`` for a continued example, specifically the implementation of the `SomeCustomDependencyBuilder` result builder.
public convenience init(using dependencies: DependencyCollection) {
self.init(dependencies)
}
Expand Down

0 comments on commit 641a774

Please sign in to comment.