Skip to content

Commit 62cbdbc

Browse files
sichanyooSichan Yoo
andauthored
feat: New API reference docs index page (#2021)
Co-authored-by: Sichan Yoo <[email protected]>
1 parent c2bfd7a commit 62cbdbc

File tree

11 files changed

+1204
-6
lines changed

11 files changed

+1204
-6
lines changed

AWSSDKSwiftCLI/Sources/AWSCLIUtils/FileManager+Utils.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public extension FileManager {
6868
.contentsOfDirectory(atPath: "Sources/Core")
6969
.sorted()
7070
.filter { $0 != "AWSSDKForSwift" } // Ignore documentation module
71+
.filter { $0 != "SDKForSwift" } // Ignore new documentation module
7172
.filter { !$0.hasPrefix(".") }
7273
}
7374

AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/GenerateDocIndex.swift

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,26 @@ struct GenerateDocIndexCommand: ParsableCommand {
2323
func run() throws {
2424
try FileManager.default.changeWorkingDirectory(repoPath)
2525
let contents = try generateDocIndexContents()
26-
try saveDocIndex(contents)
26+
let docIndexFileName = "Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md"
27+
try saveDocIndex(contents, docIndexFileName)
28+
// New doc index page for internal build hosted docs.
29+
let newDocIndexFileName = "Sources/Core/SDKForSwift/Documentation.docc/SDKForSwift.md"
30+
try saveDocIndex(convertToNewFormat(contents), newDocIndexFileName)
2731
}
2832

2933
// MARK: - Helpers
3034

35+
/// Converts old format relative links to new format
36+
func convertToNewFormat(_ content: String) -> String {
37+
return content.replacingOccurrences(
38+
of: "../../../../../swift/api/",
39+
with: "../../../../../sdk-for-swift/latest/api/"
40+
).replacingOccurrences(
41+
of: "/latest)",
42+
with: ")"
43+
)
44+
}
45+
3146
/// Returns the contents of the generated doc index.
3247
/// This determines the versions of the dependencies and the list of services to include and then generates the doc index with those values.
3348
///
@@ -50,15 +65,14 @@ struct GenerateDocIndexCommand: ParsableCommand {
5065
/// If no file exists, then this will create a new file. Otherwise, this will overwrite the existing file.
5166
///
5267
/// - Parameter contents: The contents of the doc index.
53-
func saveDocIndex(_ contents: String) throws {
54-
let docIndexFileName = "Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md"
55-
log("Saving doc index to \(docIndexFileName)...")
68+
func saveDocIndex(_ contents: String, _ destination: String) throws {
69+
log("Saving doc index to \(destination)...")
5670
try contents.write(
57-
toFile: docIndexFileName,
71+
toFile: destination,
5872
atomically: true,
5973
encoding: .utf8
6074
)
61-
log("Successfully saved doc index to \(docIndexFileName)")
75+
log("Successfully saved doc index to \(destination)")
6276
}
6377

6478
/// Returns the list of services to include in the doc index.

AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Resources/Package.Base.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ private var runtimeTargets: [Target] {
116116
path: "Sources/Core/AWSSDKForSwift",
117117
exclude: ["Documentation.docc/AWSSDKForSwift.md"]
118118
),
119+
.target(
120+
name: "SDKForSwift",
121+
path: "Sources/Core/SDKForSwift",
122+
exclude: ["Documentation.docc/SDKForSwift.md"]
123+
),
119124
.target(
120125
name: "AWSClientRuntime",
121126
dependencies: [

Package.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ private var runtimeTargets: [Target] {
560560
path: "Sources/Core/AWSSDKForSwift",
561561
exclude: ["Documentation.docc/AWSSDKForSwift.md"]
562562
),
563+
.target(
564+
name: "SDKForSwift",
565+
path: "Sources/Core/SDKForSwift",
566+
exclude: ["Documentation.docc/SDKForSwift.md"]
567+
),
563568
.target(
564569
name: "AWSClientRuntime",
565570
dependencies: [

0 commit comments

Comments
 (0)