Skip to content

Commit

Permalink
Use new Identifier type in SerializableLinkResolutionInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ronnqvist committed Oct 25, 2024
1 parent 414ef9c commit 61cc5e2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ package enum ConvertActionConverter {

if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled {
do {
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue)
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id)
try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation)

if !emitDigest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public struct DocumentationConverter: DocumentationConverterProtocol {

if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled {
do {
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.identifier)
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id)
try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation)

if !emitDigest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ final class ExternalPathHierarchyResolver {
continue
}
let identifier = identifiers[index]
self.resolvedReferences[identifier] = ResolvedTopicReference(id: .init(rawValue: fileRepresentation.bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift)
self.resolvedReferences[identifier] = ResolvedTopicReference(id: fileRepresentation.bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift)
}
}
// Finally, the Identifier -> Symbol mapping can be constructed by iterating over the nodes and looking up the reference for each USR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public struct SerializableLinkResolutionInformation: Codable {
// This type is public so that it can be an argument to a function in `ConvertOutputConsumer`

var version: SemanticVersion
var bundleID: String
var bundleID: DocumentationBundle.Identifier
var pathHierarchy: PathHierarchy.FileRepresentation
// Separate storage of node data because the path hierarchy doesn't know the resolved references for articles.
var nonSymbolPaths: [Int: String]
Expand All @@ -158,7 +158,7 @@ extension PathHierarchyBasedLinkResolver {
/// Create a file representation of the link resolver.
///
/// The file representation can be decoded in later documentation builds to resolve external links to the content where the link resolver was originally created for.
func prepareForSerialization(bundleID: String) throws -> SerializableLinkResolutionInformation {
func prepareForSerialization(bundleID: DocumentationBundle.Identifier) throws -> SerializableLinkResolutionInformation {
var nonSymbolPaths: [Int: String] = [:]
let hierarchyFileRepresentation = PathHierarchy.FileRepresentation(pathHierarchy) { identifiers in
nonSymbolPaths.reserveCapacity(identifiers.count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5285,7 +5285,7 @@ let expected = """

return entity.externallyLinkableElementSummaries(context: context, renderNode: renderNode, includeTaskGroups: false)
}
let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue)
let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id)

return (linkResolutionInformation, linkSummaries)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase {

return entity.externallyLinkableElementSummaries(context: dependencyContext, renderNode: renderNode, includeTaskGroups: false)
}
let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.id.rawValue)
let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.id)

XCTAssertEqual(linkResolutionInformation.pathHierarchy.nodes.count - linkResolutionInformation.nonSymbolPaths.count, 5 /* 4 symbols & 1 module */)
XCTAssertEqual(linkSummaries.count, 5 /* 4 symbols & 1 module */)
Expand Down Expand Up @@ -995,7 +995,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase {

let localResolver = try XCTUnwrap(context.linkResolver.localResolver)

let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.id.rawValue)
let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.id)
let resolverData = try JSONEncoder().encode(resolverInfo)
let roundtripResolverInfo = try JSONDecoder().decode(SerializableLinkResolutionInformation.self, from: resolverData)

Expand Down

0 comments on commit 61cc5e2

Please sign in to comment.