Skip to content

Commit 6a90652

Browse files
authored
DocC setup (#22)
1 parent 94642d2 commit 6a90652

File tree

10 files changed

+130
-28
lines changed

10 files changed

+130
-28
lines changed

Package.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version:5.6
22

33
import PackageDescription
44

@@ -7,7 +7,9 @@ let package = Package(
77
products: [
88
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]),
99
],
10-
dependencies: [],
10+
dependencies: [
11+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
12+
],
1113
targets: [
1214
.target(name: "AWSLambdaEvents", dependencies: []),
1315
.testTarget(name: "AWSLambdaEventsTests", dependencies: ["AWSLambdaEvents"]),

[email protected]

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// swift-tools-version:5.4
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-aws-lambda-events",
7+
products: [
8+
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]),
9+
],
10+
dependencies: [],
11+
targets: [
12+
.target(name: "AWSLambdaEvents", dependencies: []),
13+
.testTarget(name: "AWSLambdaEventsTests", dependencies: ["AWSLambdaEvents"]),
14+
]
15+
)

[email protected]

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// swift-tools-version:5.4
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-aws-lambda-events",
7+
products: [
8+
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]),
9+
],
10+
dependencies: [],
11+
targets: [
12+
.target(name: "AWSLambdaEvents", dependencies: []),
13+
.testTarget(name: "AWSLambdaEventsTests", dependencies: ["AWSLambdaEvents"]),
14+
]
15+
)

Sources/AWSLambdaEvents/ALB.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import class Foundation.JSONEncoder
1616

1717
// https://github.com/aws/aws-lambda-go/blob/master/events/alb.go
18-
/// ALBTargetGroupRequest contains data originating from the ALB Lambda target group integration
18+
/// `ALBTargetGroupRequest` contains data originating from the ALB Lambda target group integration.
1919
public struct ALBTargetGroupRequest: Codable {
20-
/// ALBTargetGroupRequestContext contains the information to identify the load balancer invoking the lambda
20+
/// `Context` contains information to identify the load balancer invoking the lambda.
2121
public struct Context: Codable {
2222
public let elb: ELBContext
2323
}
@@ -26,14 +26,14 @@ public struct ALBTargetGroupRequest: Codable {
2626
public let path: String
2727
public let queryStringParameters: [String: String]
2828

29-
/// Depending on your configuration of your target group either `headers` or `multiValueHeaders`
29+
/// Depending on your configuration of your target group either ``headers`` or ``multiValueHeaders``
3030
/// are set.
3131
///
3232
/// For more information visit:
3333
/// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers
3434
public let headers: HTTPHeaders?
3535

36-
/// Depending on your configuration of your target group either `headers` or `multiValueHeaders`
36+
/// Depending on your configuration of your target group either ``headers`` or ``multiValueHeaders``
3737
/// are set.
3838
///
3939
/// For more information visit:
@@ -43,7 +43,7 @@ public struct ALBTargetGroupRequest: Codable {
4343
public let isBase64Encoded: Bool
4444
public let body: String?
4545

46-
/// ELBContext contains the information to identify the ARN invoking the lambda
46+
/// `ELBContext` contains information to identify the ARN invoking the lambda.
4747
public struct ELBContext: Codable {
4848
public let targetGroupArn: String
4949
}

Sources/AWSLambdaEvents/APIGateway+V2.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
/// APIGatewayV2Request contains data coming from the new HTTP API Gateway
15+
/// `APIGatewayV2Request` contains data coming from the new HTTP API Gateway.
1616
public struct APIGatewayV2Request: Codable {
17-
/// Context contains the information to identify the AWS account and resources invoking the Lambda function.
17+
/// `Context` contains information to identify the AWS account and resources invoking the Lambda function.
1818
public struct Context: Codable {
1919
public struct HTTP: Codable {
2020
public let method: HTTPMethod
@@ -24,9 +24,9 @@ public struct APIGatewayV2Request: Codable {
2424
public let userAgent: String
2525
}
2626

27-
/// Authorizer contains authorizer information for the request context.
27+
/// `Authorizer` contains authorizer information for the request context.
2828
public struct Authorizer: Codable {
29-
/// JWT contains JWT authorizer information for the request context.
29+
/// `JWT` contains JWT authorizer information for the request context.
3030
public struct JWT: Codable {
3131
public let claims: [String: String]?
3232
public let scopes: [String]?

Sources/AWSLambdaEvents/APIGateway.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import class Foundation.JSONEncoder
1717
// https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html
1818
// https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
1919

20-
/// APIGatewayRequest contains data coming from the API Gateway
20+
/// `APIGatewayRequest` contains data coming from the API Gateway.
2121
public struct APIGatewayRequest: Codable {
2222
public struct Context: Codable {
2323
public struct Identity: Codable {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ``AWSLambdaEvents``
2+
3+
A supporting library for Swift AWS Lambda Runtime.
4+
5+
## Overview
6+
7+
Swift AWS Lambda Runtime was designed to make building Lambda functions in Swift simple and safe. The library is an implementation of the [AWS Lambda Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html) and uses an embedded asynchronous HTTP Client based on [SwiftNIO](http://github.com/apple/swift-nio) that is fine-tuned for performance in the AWS Runtime context. The library provides a multi-tier API that allows building a range of Lambda functions: From quick and simple closures to complex, performance-sensitive event handlers.
8+
9+
Swift AWS Lambda Events is a supporting library for the [Swift AWS Lambda Runtime](http://github.com/swift-server/swift-aws-lambda-runtime) library, providing abstractions for popular AWS events.
10+
11+
## Integration with AWS Platform Events
12+
13+
AWS Lambda functions can be invoked directly from the AWS Lambda console UI, AWS Lambda API, AWS SDKs, AWS CLI, and AWS toolkits. More commonly, they are invoked as a reaction to an events coming from the AWS platform. To make it easier to integrate with AWS platform events, this library includes an `AWSLambdaEvents` target which provides abstractions for many commonly used events. Additional events can be easily modeled when needed following the same patterns set by `AWSLambdaEvents`. Integration points with the AWS Platform include:
14+
15+
* [APIGateway Proxy](https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html)
16+
* [S3 Events](https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html)
17+
* [SES Events](https://docs.aws.amazon.com/lambda/latest/dg/services-ses.html)
18+
* [SNS Events](https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html)
19+
* [SQS Events](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html)
20+
* [CloudWatch Events](https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html)
21+
22+
**Note**: Each one of the integration points mentioned above includes a set of `Codable` structs that mirror AWS' data model for these APIs.
23+
24+
## Getting started
25+
26+
If you have never used AWS Lambda or Docker before, check out this [getting started guide](https://fabianfett.de/getting-started-with-swift-aws-lambda-runtime) which helps you with every step from zero to a running Lambda.
27+
28+
Swift AWS Lambda Events is a supporting library for the [Swift AWS Lambda Runtime](http://github.com/swift-server/swift-aws-lambda-runtime) library, where you can find further documentation and examples.
29+
30+
## Topics
31+
32+
### Events
33+
34+
- ``AppSyncEvent``
35+
- ``CloudwatchEvent``
36+
- ``DynamoDBEvent``
37+
- ``S3Event``
38+
- ``SESEvent``
39+
- ``SNSEvent``
40+
- ``SQSEvent``

Sources/AWSLambdaEvents/DynamoDB.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public struct DynamoDBEvent: Decodable {
5252
}
5353

5454
public enum StreamViewType: String, Codable {
55-
/// the entire item, as it appeared after it was modified.
55+
/// The entire item, as it appeared after it was modified.
5656
case newImage = "NEW_IMAGE"
57-
/// the entire item, as it appeared before it was modified.
57+
/// The entire item, as it appeared before it was modified.
5858
case oldImage = "OLD_IMAGE"
59-
/// both the new and the old item images of the item.
59+
/// Both the new and the old item images of the item.
6060
case newAndOldImages = "NEW_AND_OLD_IMAGES"
61-
/// only the key attributes of the modified item.
61+
/// Only the key attributes of the modified item.
6262
case keysOnly = "KEYS_ONLY"
6363
}
6464

@@ -75,32 +75,32 @@ public struct DynamoDBEvent: Decodable {
7575
public let eventId: String
7676

7777
/// The type of data modification that was performed on the DynamoDB table:
78-
/// * INSERT - a new item was added to the table.
79-
/// * MODIFY - one or more of an existing item's attributes were modified.
80-
/// * REMOVE - the item was deleted from the table
78+
/// * `INSERT` - a new item was added to the table.
79+
/// * `MODIFY` - one or more of an existing item's attributes were modified.
80+
/// * `REMOVE` - the item was deleted from the table.
8181
public let eventName: OperationType
8282

8383
/// The AWS service from which the stream record originated. For DynamoDB Streams,
84-
/// this is aws:dynamodb.
84+
/// this is `aws:dynamodb`.
8585
public let eventSource: String
8686

8787
/// The version number of the stream record format. This number is updated whenever
8888
/// the structure of Record is modified.
8989
///
90-
/// Client applications must not assume that eventVersion will remain at a particular
91-
/// value, as this number is subject to change at any time. In general, eventVersion
90+
/// Client applications must not assume that `eventVersion` will remain at a particular
91+
/// value, as this number is subject to change at any time. In general, `eventVersion`
9292
/// will only increase as the low-level DynamoDB Streams API evolves.
9393
public let eventVersion: String
9494

95-
/// The event source ARN of DynamoDB
95+
/// The event source ARN of DynamoDB.
9696
public let eventSourceArn: String
9797

9898
/// Items that are deleted by the Time to Live process after expiration have
9999
/// the following fields:
100-
/// * Records[].userIdentity.type
100+
/// * `Records[].userIdentity.type`
101101
///
102102
/// "Service"
103-
/// * Records[].userIdentity.principalId
103+
/// * `Records[].userIdentity.principalId`
104104
///
105105
/// "dynamodb.amazonaws.com"
106106
public let userIdentity: UserIdentity?

scripts/preview_docc.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
##===----------------------------------------------------------------------===##
17+
##
18+
## This source file is part of the Swift Distributed Actors open source project
19+
##
20+
## Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
21+
## Licensed under Apache License v2.0
22+
##
23+
## See LICENSE.txt for license information
24+
## See CONTRIBUTORS.md for the list of Swift Distributed Actors project authors
25+
##
26+
## SPDX-License-Identifier: Apache-2.0
27+
##
28+
##===----------------------------------------------------------------------===##
29+
30+
swift package --disable-sandbox preview-documentation --target $1

scripts/soundness.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
##
44
## This source file is part of the SwiftAWSLambdaRuntime open source project
55
##
6-
## Copyright (c) 2017-2018 Apple Inc. and the SwiftAWSLambdaRuntime project authors
6+
## Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
77
## Licensed under Apache License v2.0
88
##
99
## See LICENSE.txt for license information
@@ -19,7 +19,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1919

2020
function replace_acceptable_years() {
2121
# this needs to replace all acceptable forms with 'YEARS'
22-
sed -e 's/2017-2018/YEARS/' -e 's/2017-2020/YEARS/' -e 's/2017-2021/YEARS/' -e 's/2017-2022/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/'
22+
sed -e 's/20[12][78901]-20[12][89012]/YEARS/' -e 's/2019/YEARS/' -e 's/202[012]/YEARS/'
2323
}
2424

2525
printf "=> Checking for unacceptable language... "
@@ -61,7 +61,7 @@ for language in swift-or-c bash dtrace; do
6161
matching_files=( -name '*' )
6262
case "$language" in
6363
swift-or-c)
64-
exceptions=( -name Package.swift )
64+
exceptions=( -name Package.swift -o -name 'Package@*.swift' )
6565
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
6666
cat > "$tmp" <<"EOF"
6767
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)