|
1 | 1 | /*
|
2 | 2 | This source file is part of the Swift.org open source project
|
3 | 3 |
|
4 |
| - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors |
| 4 | + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors |
5 | 5 | Licensed under Apache License v2.0 with Runtime Library Exception
|
6 | 6 |
|
7 | 7 | See https://swift.org/LICENSE.txt for license information
|
@@ -89,21 +89,6 @@ public final class Metadata: Semantic, AutomaticDirectiveConvertible {
|
89 | 89 | "titleHeading" : \Metadata._titleHeading,
|
90 | 90 | ]
|
91 | 91 |
|
92 |
| - /// Creates a metadata object with a given markup, documentation extension, and technology root. |
93 |
| - /// - Parameters: |
94 |
| - /// - originalMarkup: The original markup for this metadata directive. |
95 |
| - /// - documentationExtension: Optional configuration that describes how this documentation extension file merges or overrides the in-source documentation. |
96 |
| - /// - technologyRoot: Optional configuration to make this page root-level documentation. |
97 |
| - /// - displayName: Optional configuration to customize this page's symbol's display name. |
98 |
| - /// - titleHeading: Optional configuration to customize the text of this page's title heading. |
99 |
| - init(originalMarkup: BlockDirective, documentationExtension: DocumentationExtension?, technologyRoot: TechnologyRoot?, displayName: DisplayName?, titleHeading: TitleHeading?) { |
100 |
| - self.originalMarkup = originalMarkup |
101 |
| - self.documentationOptions = documentationExtension |
102 |
| - self.technologyRoot = technologyRoot |
103 |
| - self.displayName = displayName |
104 |
| - self.titleHeading = titleHeading |
105 |
| - } |
106 |
| - |
107 | 92 | @available(*, deprecated, message: "Do not call directly. Required for 'AutomaticDirectiveConvertible'.")
|
108 | 93 | init(originalMarkup: BlockDirective) {
|
109 | 94 | self.originalMarkup = originalMarkup
|
@@ -203,5 +188,76 @@ public final class Metadata: Semantic, AutomaticDirectiveConvertible {
|
203 | 188 |
|
204 | 189 | return true
|
205 | 190 | }
|
| 191 | + |
| 192 | + // MARK: Private API for OutOfProcessReferenceResolver |
| 193 | + |
| 194 | + /// Don't use this outside of ``OutOfProcessReferenceResolver/entity(with:)`` . |
| 195 | + /// |
| 196 | + /// Directives aren't meant to be created from non-markup but the out-of-process resolver needs to create a ``Metadata`` to hold the ``PageImage`` |
| 197 | + /// values that it creates to associate topic images with external pages. This is because DocC renders external content in the local context. (rdar://78718811) |
| 198 | + /// https://github.com/apple/swift-docc/issues/468 |
| 199 | + /// |
| 200 | + /// This is intentionally defined as an underscore prefixed static function instead of an initializer to make it less likely that it's used in other places. |
| 201 | + static func _make( |
| 202 | + originalMarkup: BlockDirective, |
| 203 | + documentationOptions: DocumentationExtension? = nil, |
| 204 | + technologyRoot: TechnologyRoot? = nil, |
| 205 | + displayName: DisplayName? = nil, |
| 206 | + pageImages: [PageImage] = [], |
| 207 | + customMetadata: [CustomMetadata] = [], |
| 208 | + callToAction: CallToAction? = nil, |
| 209 | + availability: [Metadata.Availability] = [], |
| 210 | + pageKind: Metadata.PageKind? = nil, |
| 211 | + supportedLanguages: [SupportedLanguage] = [], |
| 212 | + _pageColor: PageColor? = nil, |
| 213 | + titleHeading: TitleHeading? = nil |
| 214 | + ) -> Metadata { |
| 215 | + // FIXME: https://github.com/apple/swift-docc/issues/468 |
| 216 | + return Metadata( |
| 217 | + originalMarkup: originalMarkup, |
| 218 | + documentationOptions: documentationOptions, |
| 219 | + technologyRoot: technologyRoot, |
| 220 | + displayName: displayName, |
| 221 | + pageImages: pageImages, |
| 222 | + customMetadata: customMetadata, |
| 223 | + callToAction: callToAction, |
| 224 | + availability: availability, |
| 225 | + pageKind: pageKind, |
| 226 | + supportedLanguages: supportedLanguages, |
| 227 | + _pageColor: _pageColor, |
| 228 | + titleHeading: titleHeading |
| 229 | + ) |
| 230 | + } |
| 231 | + |
| 232 | + // This initializer only exists to be called by `_make` above. |
| 233 | + private init( |
| 234 | + originalMarkup: BlockDirective, |
| 235 | + documentationOptions: DocumentationExtension?, |
| 236 | + technologyRoot: TechnologyRoot?, |
| 237 | + displayName: DisplayName?, |
| 238 | + pageImages: [PageImage], |
| 239 | + customMetadata: [CustomMetadata], |
| 240 | + callToAction: CallToAction?, |
| 241 | + availability: [Metadata.Availability], |
| 242 | + pageKind: Metadata.PageKind?, |
| 243 | + supportedLanguages: [SupportedLanguage], |
| 244 | + _pageColor: PageColor?, |
| 245 | + titleHeading: TitleHeading? |
| 246 | + ) { |
| 247 | + self.originalMarkup = originalMarkup |
| 248 | + self.documentationOptions = documentationOptions |
| 249 | + self.technologyRoot = technologyRoot |
| 250 | + self.displayName = displayName |
| 251 | + self.callToAction = callToAction |
| 252 | + self._pageColor = _pageColor |
| 253 | + self.pageKind = pageKind |
| 254 | + self.titleHeading = titleHeading |
| 255 | + // Non-optional child directives need to be set after `super.init()`. |
| 256 | + super.init() |
| 257 | + self.customMetadata = customMetadata |
| 258 | + self.pageImages = pageImages |
| 259 | + self.availability = availability |
| 260 | + self.supportedLanguages = supportedLanguages |
| 261 | + } |
206 | 262 | }
|
207 | 263 |
|
0 commit comments