Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c77e1c
Rename context "bundle" property to "inputs"
d-ronnqvist Sep 30, 2025
c4a9f77
Remove redundant "bundle" parameter from RenderHierarchyTranslator
d-ronnqvist Sep 30, 2025
3d11235
Remove redundant "bundle" parameter from RenderContentCompiler
d-ronnqvist Sep 30, 2025
a8f6248
Update test to avoid using inputs that don't belong to the context
d-ronnqvist Sep 30, 2025
c2c2196
Remove redundant "bundle" parameter from MarkupReferenceResolver
d-ronnqvist Sep 30, 2025
98492d0
Remove redundant "bundle" parameter from ReferenceResolver
d-ronnqvist Sep 30, 2025
e386863
Remove redundant "bundle" parameter from DocumentationContentRenderer
d-ronnqvist Sep 30, 2025
9bacbbd
Remove redundant "bundle" parameter from RenderNodeTranslator
d-ronnqvist Sep 30, 2025
9d08393
Remove redundant "bundle" parameter from DocumentationNodeConverter
d-ronnqvist Sep 30, 2025
4922a76
Remove redundant "bundle" parameter from DocumentationContextConverter
d-ronnqvist Sep 30, 2025
8bfd711
Remove redundant "bundle" parameter from GeneratedDocumentationTopics
d-ronnqvist Sep 30, 2025
c4bdf0b
Remove redundant "bundle" parameter from ConvertActionConverter
d-ronnqvist Sep 30, 2025
b50bc1a
Remove redundant "bundle" parameter from AutomaticCuration.seeAlso
d-ronnqvist Sep 30, 2025
a657d32
Remove redundant "bundle" parameter from RenderNodeTranslator.default…
d-ronnqvist Sep 30, 2025
faaa649
Remove redundant "bundle" parameter from DocumentationCurator
d-ronnqvist Sep 30, 2025
5898c48
Remove unused DocumentationContext.unregister method
d-ronnqvist Sep 30, 2025
061e1db
Remove redundant "bundle" parameter from PathHierarchyBasedLinkResolv…
d-ronnqvist Sep 30, 2025
299719a
Remove redundant "bundle" parameters from various private Documentati…
d-ronnqvist Sep 30, 2025
73ed112
Merge branch 'main' into remove-redundant-bundle-params
d-ronnqvist Oct 3, 2025
83fe89f
Merge branch 'main' into remove-redundant-bundle-params
d-ronnqvist Oct 7, 2025
d6f0c50
Merge branch 'main' into remove-redundant-bundle-params
d-ronnqvist Oct 10, 2025
e1c04b7
Remove to local "bundle" variables
d-ronnqvist Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Sources/SwiftDocC/Converter/DocumentationContextConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public class DocumentationContextConverter {
/// The context the converter uses to resolve references it finds in the documentation node's content.
let context: DocumentationContext

/// The bundle that contains the content from which the documentation node originated.
let bundle: DocumentationBundle

/// A context that contains common pre-rendered pieces of content.
let renderContext: RenderContext

Expand All @@ -43,12 +40,11 @@ public class DocumentationContextConverter {
/// The remote source control repository where the documented module's source is hosted.
let sourceRepository: SourceRepository?

/// Creates a new node converter for the given bundle and context.
/// Creates a new node converter for the given context.
///
/// The converter uses bundle and context to resolve references to other documentation and describe the documentation hierarchy.
///
/// - Parameters:
/// - bundle: The bundle that contains the content from which the documentation node originated.
/// - context: The context that the converter uses to to resolve references it finds in the documentation node's content.
/// - renderContext: A context that contains common pre-rendered pieces of content.
/// - emitSymbolSourceFileURIs: Whether the documentation converter should include
Expand All @@ -61,22 +57,39 @@ public class DocumentationContextConverter {
/// - sourceRepository: The source repository where the documentation's sources are hosted.
/// - symbolIdentifiersWithExpandedDocumentation: A list of symbol IDs that have version of their documentation page with more content that a renderer can link to.
public init(
bundle: DocumentationBundle,
context: DocumentationContext,
renderContext: RenderContext,
emitSymbolSourceFileURIs: Bool = false,
emitSymbolAccessLevels: Bool = false,
sourceRepository: SourceRepository? = nil,
symbolIdentifiersWithExpandedDocumentation: [String]? = nil
) {
self.bundle = bundle
self.context = context
self.renderContext = renderContext
self.shouldEmitSymbolSourceFileURIs = emitSymbolSourceFileURIs
self.shouldEmitSymbolAccessLevels = emitSymbolAccessLevels
self.sourceRepository = sourceRepository
self.symbolIdentifiersWithExpandedDocumentation = symbolIdentifiersWithExpandedDocumentation
}
@available(*, deprecated, renamed: "init(context:renderContext:emitSymbolSourceFileURIs:emitSymbolAccessLevels:sourceRepository:symbolIdentifiersWithExpandedDocumentation:)", message: "Use 'init(context:renderContext:emitSymbolSourceFileURIs:emitSymbolAccessLevels:sourceRepository:symbolIdentifiersWithExpandedDocumentation:)' instead. This deprecated API will be removed after 6.4 is released.")
public convenience init(
bundle _: DocumentationBundle,
context: DocumentationContext,
renderContext: RenderContext,
emitSymbolSourceFileURIs: Bool = false,
emitSymbolAccessLevels: Bool = false,
sourceRepository: SourceRepository? = nil,
symbolIdentifiersWithExpandedDocumentation: [String]? = nil
) {
self.init(
context: context,
renderContext: renderContext,
emitSymbolSourceFileURIs: emitSymbolSourceFileURIs,
emitSymbolAccessLevels: emitSymbolAccessLevels,
sourceRepository: sourceRepository,
symbolIdentifiersWithExpandedDocumentation: symbolIdentifiersWithExpandedDocumentation
)
}

/// Converts a documentation node to a render node.
///
Expand All @@ -91,7 +104,6 @@ public class DocumentationContextConverter {

var translator = RenderNodeTranslator(
context: context,
bundle: bundle,
identifier: node.reference,
renderContext: renderContext,
emitSymbolSourceFileURIs: shouldEmitSymbolSourceFileURIs,
Expand Down
17 changes: 8 additions & 9 deletions Sources/SwiftDocC/Converter/DocumentationNodeConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ public struct DocumentationNodeConverter {
/// The context the converter uses to resolve references it finds in the documentation node's content.
let context: DocumentationContext

/// The bundle that contains the content from which the documentation node originated.
let bundle: DocumentationBundle

/// Creates a new node converter for the given bundle and context.
/// Creates a new node converter for the given context.
///
/// The converter uses bundle and context to resolve references to other documentation and describe the documentation hierarchy.
/// The converter uses context to resolve references to other documentation and describe the documentation hierarchy.
///
/// - Parameters:
/// - bundle: The bundle that contains the content from which the documentation node originated.
/// - context: The context that the converter uses to to resolve references it finds in the documentation node's content.
public init(bundle: DocumentationBundle, context: DocumentationContext) {
self.bundle = bundle
public init(context: DocumentationContext) {
self.context = context
}
@available(*, deprecated, renamed: "init(context:)", message: "Use 'init(context:)' instead. This deprecated API will be removed after 6.4 is released.")
public init(bundle _: DocumentationBundle, context: DocumentationContext) {
self.init(context: context)
}

/// Converts a documentation node to a render node.
///
Expand All @@ -37,7 +36,7 @@ public struct DocumentationNodeConverter {
/// - node: The documentation node to convert.
/// - Returns: The render node representation of the documentation node.
public func convert(_ node: DocumentationNode) -> RenderNode {
var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference)
var translator = RenderNodeTranslator(context: context, identifier: node.reference)
return translator.visit(node.semantic) as! RenderNode
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public struct ConvertService: DocumentationService {
let context = try await DocumentationContext(bundle: bundle, dataProvider: dataProvider, configuration: configuration)

// Precompute the render context
let renderContext = RenderContext(documentationContext: context, bundle: bundle)
let renderContext = RenderContext(documentationContext: context)

let symbolIdentifiersMeetingRequirementsForExpandedDocumentation: [String]? = request.symbolIdentifiersWithExpandedDocumentation?.compactMap { identifier, expandedDocsRequirement in
guard let documentationNode = context.documentationCache[identifier] else {
Expand All @@ -168,7 +168,6 @@ public struct ConvertService: DocumentationService {
return documentationNode.meetsExpandedDocumentationRequirements(expandedDocsRequirement) ? identifier : nil
}
let converter = DocumentationContextConverter(
bundle: bundle,
context: context,
renderContext: renderContext,
emitSymbolSourceFileURIs: request.emitSymbolSourceFileURIs,
Expand Down Expand Up @@ -243,9 +242,9 @@ public struct ConvertService: DocumentationService {
.compactMap { (value, isDocumentationExtensionContent) -> (ResolvedTopicReference, RenderReferenceStore.TopicContent)? in
let (topicReference, article) = value

let bundle = context.bundle
let bundle = context.inputs
guard bundle.id == topicReference.bundleID else { return nil }
let renderer = DocumentationContentRenderer(documentationContext: context, bundle: bundle)
let renderer = DocumentationContentRenderer(context: context)

let documentationNodeKind: DocumentationNode.Kind = isDocumentationExtensionContent ? .unknownSymbol : .article
let overridingDocumentationNode = DocumentationContext.documentationNodeAndTitle(for: article, kind: documentationNodeKind, in: bundle)?.node
Expand Down
15 changes: 6 additions & 9 deletions Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ package enum ConvertActionConverter {
static package let signposter = NoOpSignposterShim()
#endif

/// Converts the documentation bundle in the given context and passes its output to a given consumer.
/// Converts the documentation in the given context and passes its output to a given consumer.
///
/// - Parameters:
/// - bundle: The documentation bundle to convert.
/// - context: The context that the bundle is a part of.
/// - outputConsumer: The consumer that the conversion passes outputs of the conversion to.
/// - sourceRepository: The source repository where the documentation's sources are hosted.
/// - emitDigest: Whether the conversion should pass additional metadata output––such as linkable entities information, indexing information, or asset references by asset type––to the consumer.
/// - documentationCoverageOptions: The level of experimental documentation coverage information that the conversion should pass to the consumer.
/// - Returns: A list of problems that occurred during the conversion (excluding the problems that the context already encountered).
package static func convert(
bundle: DocumentationBundle,
context: DocumentationContext,
outputConsumer: some ConvertOutputConsumer & ExternalNodeConsumer,
sourceRepository: SourceRepository?,
Expand Down Expand Up @@ -61,15 +59,14 @@ package enum ConvertActionConverter {

// Precompute the render context
let renderContext = signposter.withIntervalSignpost("Build RenderContext", id: signposter.makeSignpostID()) {
RenderContext(documentationContext: context, bundle: bundle)
RenderContext(documentationContext: context)
}
try outputConsumer.consume(renderReferenceStore: renderContext.store)

// Copy images, sample files, and other static assets.
try outputConsumer.consume(assetsInBundle: bundle)
try outputConsumer.consume(assetsInBundle: context.inputs)

let converter = DocumentationContextConverter(
bundle: bundle,
context: context,
renderContext: renderContext,
sourceRepository: sourceRepository
Expand Down Expand Up @@ -109,7 +106,7 @@ package enum ConvertActionConverter {
// Here we're associating the external node with the **current** bundle's bundle ID.
// This is needed because nodes are only considered children if the parent and child's bundle ID match.
// Otherwise, the node will be considered as a separate root node and displayed separately.
let externalRenderNode = ExternalRenderNode(externalEntity: externalLink.value, bundleIdentifier: bundle.id)
let externalRenderNode = ExternalRenderNode(externalEntity: externalLink.value, bundleIdentifier: context.inputs.id)
try outputConsumer.consume(externalRenderNode: externalRenderNode)
}

Expand Down Expand Up @@ -192,7 +189,7 @@ package enum ConvertActionConverter {
if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled {
signposter.withIntervalSignpost("Serialize link hierarchy", id: signposter.makeSignpostID()) {
do {
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id)
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: context.inputs.id)
try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation)

if !emitDigest {
Expand Down Expand Up @@ -225,7 +222,7 @@ package enum ConvertActionConverter {
break
}

try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleID: bundle.id))
try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: context.inputs.displayName, bundleID: context.inputs.id))

// Log the finalized topic graph checksum.
benchmark(add: Benchmark.TopicGraphHash(context: context))
Expand Down
Loading