Skip to content

Commit

Permalink
add docc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdeem committed Jul 26, 2024
1 parent 11fbe3c commit a0b2a55
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [EnvironmentDecoder]
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ disabled_rules:
- file_length

opt_in_rules:
# - missing_docs
- missing_docs

included:

Expand Down
24 changes: 24 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"originHash" : "f9dd70f40d8a36ca304b84a45f9f357e57d2c0708ffe79b8bb090797742b8601",
"pins" : [
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
"version" : "1.3.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 3
}
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ let package = Package(
name: "EnvironmentDecoder",
targets: ["EnvironmentDecoder"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
.target(
name: "EnvironmentDecoder"),
Expand Down
9 changes: 9 additions & 0 deletions Sources/EnvironmentDecoder/EnvironmentDecoder.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import Foundation

/// `EnvironmentDecoder` facilitates the decoding of environment variables into semantic `Decodable` types.
public final class EnvironmentDecoder {
/// Initializes `self` with default configuration.
public init() {}

/// Decodes a top-level value of the given type from the given environment representation.
/// - Parameters:
/// - type: The type of the value to decode.
/// - environment: The environment dictionary to decode from, defaults to `ProcessInfo.processInfo.environment`
/// - Returns: A value of the requested type.
/// - Throws: `DecodingError` if an error occurs during decoding
/// - Throws: An error if any value throws an error during decoding
public func decode<T: Decodable>(_ type: T.Type, from environment: [String: String] = ProcessInfo.processInfo.environment) throws -> T {
let decoder = EnvironmentDecoderImpl(environment: environment, codingPathNode: .root)
return try type.init(from: decoder)
Expand Down

0 comments on commit a0b2a55

Please sign in to comment.