Skip to content

Commit 3018d48

Browse files
authored
Merge branch 'main' into main
2 parents 8af9261 + 9c79734 commit 3018d48

File tree

20 files changed

+748
-400
lines changed

20 files changed

+748
-400
lines changed

Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -12,17 +12,6 @@ import Foundation
1212

1313
/// A container for a collection of data. Each data can have multiple variants.
1414
struct DataAssetManager {
15-
enum Error: DescribedError {
16-
case invalidImageAsset(URL)
17-
18-
var errorDescription: String {
19-
switch self {
20-
case .invalidImageAsset(let url):
21-
return "The dimensions of the image at \(url.path.singleQuoted) could not be computed because the file is not a valid image."
22-
}
23-
}
24-
}
25-
2615
var storage = [String: DataAsset]()
2716

2817
// A "file name with no extension" to "file name with extension" index
@@ -113,12 +102,10 @@ struct DataAssetManager {
113102
return (reference: dataReference, traits: traitCollection, metadata: metadata)
114103
}
115104

116-
/**
117-
Registers a collection of data and determines their trait collection.
118-
119-
Data objects which have a file name ending with '~dark' are associated to their light variant.
120-
- Throws: Will throw `Error.invalidImageAsset(URL)` if fails to read the size of an image asset (e.g. the file is corrupt).
121-
*/
105+
106+
/// Registers a collection of data and determines their trait collection.
107+
///
108+
/// Data objects which have a file name ending with '~dark' are associated to their light variant.
122109
mutating func register<Datas: Collection>(data datas: Datas, dataProvider: DocumentationContextDataProvider? = nil, bundle documentationBundle: DocumentationBundle? = nil) throws where Datas.Element == URL {
123110
for dataURL in datas {
124111
let meta = try referenceMetaInformationForDataURL(dataURL, dataProvider: dataProvider, bundle: documentationBundle)

Sources/SwiftDocC/Infrastructure/Link Resolution/BidirectionalTree.swift

Lines changed: 0 additions & 168 deletions
This file was deleted.

Sources/SwiftDocC/Infrastructure/Workspace/LocalFileSystemDataProvider+BundleDiscovery.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -176,21 +176,3 @@ fileprivate extension Array where Element == FSNode {
176176
return matches
177177
}
178178
}
179-
180-
/// An issue discovering a bundle in a workspace.
181-
enum WorkspaceError: DescribedError {
182-
/// The bundle was missing an Info.plist file.
183-
case missingInfoPlist(url: URL)
184-
/// The root element of the Info.plist file was an array rather than a dictionary.
185-
case notADictionaryAtRoot(url: URL)
186-
187-
/// A plain-text representation of the error.
188-
var errorDescription: String {
189-
switch self {
190-
case .missingInfoPlist(let url):
191-
return "A bundle was found in the workspace at '\(url)' but it was missing an Info.plist."
192-
case .notADictionaryAtRoot(let url):
193-
return "A bundle was found in the workspace but its Info.plist at '\(url)' was not structured correctly: it contained a root array rather than a root dictionary."
194-
}
195-
}
196-
}

Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,11 @@ public struct RenderNodeTranslator: SemanticVisitor {
493493
}
494494

495495
public mutating func visitVideoMedia(_ videoMedia: VideoMedia) -> RenderTree? {
496-
return createAndRegisterRenderReference(forMedia: videoMedia.source, poster: videoMedia.poster)
496+
return createAndRegisterRenderReference(
497+
forMedia: videoMedia.source,
498+
poster: videoMedia.poster,
499+
altText: videoMedia.altText
500+
)
497501
}
498502

499503
public mutating func visitChapter(_ chapter: Chapter) -> RenderTree? {

Sources/SwiftDocC/Model/Rendering/Variants/RenderNodeVariantOverridesApplier.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -43,11 +43,9 @@ public struct RenderNodeVariantOverridesApplier {
4343
var variantOverrides: VariantOverrides?
4444
}
4545

46-
/// An error that occured while applying overrides in a render node.
46+
@available(*, deprecated, message: "This error is never raised. This deprecated API will be removed after 5.11 is released")
4747
public enum Error: DescribedError {
48-
/// An error indicating that the error node is corrupted or malformed.
4948
case corruptedRenderNode
50-
5149
public var errorDescription: String {
5250
switch self {
5351
case .corruptedRenderNode:

Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -15,18 +15,6 @@ import SwiftDocC
1515
///
1616
/// The render node writer writes the JSON files into a hierarchy of folders and subfolders based on the relative URL for each node.
1717
class JSONEncodingRenderNodeWriter {
18-
/// Errors that may occur while writing render node JSON files.
19-
enum Error: DescribedError {
20-
/// A file already exist at this path.
21-
case fileExists(String)
22-
/// The absolute path to the file is too long.
23-
public var errorDescription: String {
24-
switch self {
25-
case .fileExists(let path): return "File already exists at: '\(path)'"
26-
}
27-
}
28-
}
29-
3018
private let renderNodeURLGenerator: NodeURLGenerator
3119
private let targetFolder: URL
3220
private let transformForStaticHostingIndexHTML: URL?
@@ -56,7 +44,6 @@ class JSONEncodingRenderNodeWriter {
5644
/// create those intermediate folders before writing the JSON file.
5745
///
5846
/// - Parameter renderNode: The node which the writer object writes to a JSON file.
59-
/// - Throws: A ``Error/fileExists`` error if a file already exists at the location for this node's JSON file.
6047
func write(_ renderNode: RenderNode) throws {
6148
let fileSafePath = NodeURLGenerator.fileSafeReferencePath(
6249
renderNode.identifier,

Sources/SwiftDocCUtilities/Action/Actions/IndexAction.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -13,16 +13,6 @@ import SwiftDocC
1313

1414
/// An action that creates an index of a documentation bundle.
1515
public struct IndexAction: Action {
16-
enum Error: DescribedError {
17-
case doesNotContainBundle(url: URL)
18-
var errorDescription: String {
19-
switch self {
20-
case .doesNotContainBundle(let url):
21-
return "The directory at '\(url)' and its subdirectories do not contain at least one valid documentation bundle. A documentation bundle is a directory ending in `.docc`."
22-
}
23-
}
24-
}
25-
2616
let rootURL: URL
2717
let outputURL: URL
2818
let bundleIdentifier: String
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import Foundation
12+
import SwiftDocC
13+
14+
struct CatalogTemplate {
15+
16+
let files: [String: String]
17+
let additionalDirectories: [String]
18+
19+
/// Creates a Catalog Template using one of the provided template kinds.
20+
init(_ templateKind: CatalogTemplateKind, title: String) throws {
21+
switch templateKind {
22+
case .articleOnly:
23+
self.files = CatalogTemplateKind.articleOnlyTemplateFiles(title)
24+
self.additionalDirectories = ["Resources"]
25+
case .tutorial:
26+
self.files = CatalogTemplateKind.tutorialTemplateFiles(title)
27+
self.additionalDirectories = ["Resources", "Chapter01/Resources"]
28+
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)