Skip to content

Commit

Permalink
Merge branch 'main' into day/s3200
Browse files Browse the repository at this point in the history
  • Loading branch information
dayaffe authored Aug 6, 2024
2 parents 03a6b3a + a453825 commit 50d4f23
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
11 changes: 11 additions & 0 deletions AWSSDKSwiftCLI/Sources/AWSCLIUtils/FileManager+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public extension FileManager {
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of AWS runtime modules within `Sources/Core`
///
/// - Returns: The list of AWS runtime modules.
func getAWSRuntimeModules() throws -> [String] {
try FileManager.default
.contentsOfDirectory(atPath: "Sources/Core")
.sorted()
.filter { $0 != "AWSSDKForSwift" } // Ignore documentation module
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of integration tests.
///
/// - Returns: The list of integration tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ struct GenerateDocIndexCommand: ParsableCommand {
/// - Returns: The contents of the generated doc index.
func generateDocIndexContents() throws -> String {
let services = try resolveServices()
let awsRuntimeModules = try resolveAWSRuntimeModules()
log("Creating doc index contents...")
let contents = try DocIndexBuilder(services: services).build()
let contents = try DocIndexBuilder(services: services, awsRuntimeModules: awsRuntimeModules).build()
log("Successfully created doc index contents")
return contents
}
Expand Down Expand Up @@ -68,4 +69,16 @@ struct GenerateDocIndexCommand: ParsableCommand {
log("Resolved list of services: \(resolvedServices.count)")
return resolvedServices
}

/// Returns the list of AWS runtime modules within `Sources/Core` to include in the doc index.
///
/// - Returns: The list of AWS runtime moduls to include in the doc index
func resolveAWSRuntimeModules() throws -> [String] {
log("Resolving AWS runtime modules...")
let resolvedAWSRuntimeModules: [String]
log("Using list of AWS runtime modules that exist within Sources/Core")
resolvedAWSRuntimeModules = try FileManager.default.getAWSRuntimeModules()
log("Resolved list of AWS runtime modules: \(resolvedAWSRuntimeModules.count)")
return resolvedAWSRuntimeModules
}
}
22 changes: 19 additions & 3 deletions AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/DocIndexBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ struct DocIndexBuilder {
}

let services: [String]
let awsRuntimeModules: [String]
let baseDocIndexContents: () throws -> String

init(services: [String]) {
init(services: [String], awsRuntimeModules: [String]) {
self.services = services
self.awsRuntimeModules = awsRuntimeModules
self.baseDocIndexContents = {
// Returns the contents of the base doc index stored in the bundle at `Resources/DocIndex.Base.md`
let basePackageName = "DocIndex.Base"
Expand Down Expand Up @@ -56,19 +58,33 @@ struct DocIndexBuilder {
/// Builds all the generated package manifest content
private func buildGeneratedContent() -> String {
let contents = [
buildAWSRuntimeModuleIndex(),
"",
buildServiceIndex(),
""
]
return contents.joined(separator: .newline)
}

/// Returns markdown links to AWS module documentations
///
/// - Returns: List of markdown links to AWS module documentations
private func buildAWSRuntimeModuleIndex() -> String {
let header = "## AWS Runtime Module Documentation\n\n"
return header + awsRuntimeModules.map { module in
let urlModule = module.lowercased(with: Locale(identifier: "en_US_POSIX"))
return "[\(module)](../../../../../swift/api/\(urlModule)/latest)\n"
}.joined(separator: "\n")
}

/// Returns a pragma mark comment to provide separation between the non-generated (base) and generated content
///
/// - Returns: A pragma mark comment to provide separation between the non-generated (base) and generated content
private func buildServiceIndex() -> String {
return services.map { service in
let header = "## Service Documentation\n\n"
return header + services.map { service in
let urlService = service.lowercased(with: Locale(identifier: "en_US_POSIX"))
return "[\(service)](../../../../../swift/api/\(urlService)/latest)\n"
}.joined(separator: "\n")
}.joined(separator: "\n")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ A pure-Swift SDK for accessing all published AWS services.
**The AWS SDK for Swift is currently in developer preview and is intended strictly for feedback purposes only. Do not use this SDK for production workloads. Refer to the SDK [stability guidelines](docs/stability.md) for more detail.**

This SDK is open-source. Code is available on Github [here](https://github.com/awslabs/aws-sdk-swift).

## Service Documentation

0 comments on commit 50d4f23

Please sign in to comment.