Skip to content

Commit

Permalink
Remove throws for function that doesn't raise any errors. (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ronnqvist authored Dec 3, 2024
1 parent ff4ba14 commit 9b8db28
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftDocC/Converter/DocumentationNodeConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public struct DocumentationNodeConverter {
/// - Parameters:
/// - node: The documentation node to convert.
/// - Returns: The render node representation of the documentation node.
public func convert(_ node: DocumentationNode) throws -> RenderNode {
public func convert(_ node: DocumentationNode) -> RenderNode {
var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference)
return translator.visit(node.semantic) as! RenderNode
}

@available(*, deprecated, renamed: "convert(_:)", message: "Use 'convert(_:)' instead. This deprecated API will be removed after 6.1 is released")
public func convert(_ node: DocumentationNode, at source: URL?) throws -> RenderNode {
return try convert(node)
return convert(node)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DocumentationContextConverterTests: XCTestCase {
for identifier in context.knownPages {
let documentationNode = try XCTUnwrap(try context.entity(with: identifier))

let renderNode1 = try perNodeConverter.convert(documentationNode)
let renderNode1 = perNodeConverter.convert(documentationNode)
let renderNode2 = bulkNodeConverter.renderNode(for: documentationNode)

// Compare the two nodes are identical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase {
// For reach topic encode its render node and verify the references are in alphabetical order.
for reference in context.knownPages {
let node = try context.entity(with: reference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

// Get the encoded JSON as string
let encodedData = try renderNode.encodeToJSON(with: encoder, renderReferenceCache: cache)
Expand Down Expand Up @@ -228,7 +228,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase {
// For reach topic encode its render node and verify the references are in alphabetical order.
for reference in context.knownPages {
let node = try context.entity(with: reference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

// Get the encoded JSON as string
let encodedData = try renderNode.encodeToJSON(with: encoder)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ Root

for identifier in context.knownPages {
let entity = try context.entity(with: identifier)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)
try builder.index(renderNode: renderNode)
}

Expand Down Expand Up @@ -1673,7 +1673,7 @@ Root

for identifier in context.knownPages {
let entity = try context.entity(with: identifier)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)
try builder.index(renderNode: renderNode)
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AnchorSectionTests: XCTestCase {

// Verify collecting section render references
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

let sectionReference = try XCTUnwrap(renderNode.references["doc://org.swift.docc.example/documentation/TechnologyX/Article#Article-Sub-Section"] as? TopicRenderReference)
XCTAssertEqual(sectionReference.title, "Article Sub-Section")
Expand Down Expand Up @@ -125,7 +125,7 @@ class AnchorSectionTests: XCTestCase {

// Verify collecting section render references
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

let sectionReference = try XCTUnwrap(renderNode.references["doc://org.swift.docc.example/documentation/CoolFramework/CoolClass#Symbol-Sub-Section"] as? TopicRenderReference)
XCTAssertEqual(sectionReference.title, "Symbol Sub-Section")
Expand Down Expand Up @@ -183,7 +183,7 @@ class AnchorSectionTests: XCTestCase {

// Verify collecting section render references
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

let sectionReference = try XCTUnwrap(renderNode.references["doc://org.swift.docc.example/documentation/CoolFramework#Module-Sub-Section"] as? TopicRenderReference)
XCTAssertEqual(sectionReference.title, "Module Sub-Section")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3237,7 +3237,7 @@ let expected = """
// Verify that the links are resolved in the render model.
let bundle = try XCTUnwrap(context.bundle)
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

XCTAssertEqual(renderNode.topicSections.map(\.anchor), [
"Another-topic-section"
Expand Down Expand Up @@ -5327,7 +5327,7 @@ let expected = """
let node = try context.entity(with: reference)

let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

let externalReference = "doc://Dependency/documentation/ExternalModuleName"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class DocumentationCuratorTests: XCTestCase {
XCTAssertEqual("doc://com.test.TestBed/documentation/TestBed/MyArticle", symbol.topics?.taskGroups.first?.links.first?.destination)

let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

// Verify the article identifier is included in the task group for the render node.
XCTAssertEqual("doc://com.test.TestBed/documentation/TestBed/MyArticle", renderNode.topicSections.first?.identifiers.first)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
for reference in context.knownPages {
let node = try context.entity(with: reference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
entitySummaries.append(contentsOf: node.externallyLinkableElementSummaries(context: context, renderNode: renderNode, includeTaskGroups: false))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ExternalReferenceResolverTests: XCTestCase {
sourceLanguage: .swift
)
let node = try context.entity(with: sideClassReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

// First assert that the external reference is included in the render node's references
// and is defined as expected.
Expand Down Expand Up @@ -267,7 +267,7 @@ class ExternalReferenceResolverTests: XCTestCase {
"The test content should include a link for the external reference resolver to resolve"
)

let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

guard let symbolRenderReference = renderNode.references[expectedReference] as? TopicRenderReference else {
XCTFail("The external reference should be resolved and included among the Tutorial's references.")
Expand Down Expand Up @@ -310,7 +310,7 @@ class ExternalReferenceResolverTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift))

let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

guard let symbolRenderReference = renderNode.references["doc://com.test.external/path/to/external/symbol"] as? TopicRenderReference else {
XCTFail("The external reference should be resolved and included among the SideClass symbols's references.")
Expand Down Expand Up @@ -355,7 +355,7 @@ class ExternalReferenceResolverTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/article", sourceLanguage: .swift))

let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

XCTAssertEqual(externalResolver.resolvedExternalPaths, ["/path/to/external/symbol"], "The authored link was resolved")

Expand Down Expand Up @@ -402,7 +402,7 @@ class ExternalReferenceResolverTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift))

let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

guard let sampleRenderReference = renderNode.references["doc://com.test.external/path/to/external/sample"] as? TopicRenderReference else {
XCTFail("The external reference should be resolved and included among the SideClass symbols's references.")
Expand Down Expand Up @@ -501,7 +501,7 @@ class ExternalReferenceResolverTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeSample", sourceLanguage: .swift))

let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

XCTAssertEqual(context.assetManagers.keys.sorted(), ["org.swift.docc.sample"],
"The external bundle for the external asset shouldn't have it's own asset manager")
Expand Down Expand Up @@ -770,7 +770,7 @@ class ExternalReferenceResolverTests: XCTestCase {
// Get MyKit symbol
let entity = try context.entity(with: .init(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift))
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let renderNode = try converter.convert(entity)
let renderNode = converter.convert(entity)

let taskGroupLinks = try XCTUnwrap(renderNode.seeAlsoSections.first?.identifiers)
// Verify the unresolved links are not included in the task group.
Expand Down Expand Up @@ -896,7 +896,7 @@ class ExternalReferenceResolverTests: XCTestCase {
sourceLanguage: .swift
)
let node = try context.entity(with: mixedLanguageFrameworkReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
// Topic identifiers in the Swift variant of the `MixedLanguageFramework` symbol
let swiftTopicIDs = renderNode.topicSections.flatMap(\.identifiers)

Expand Down Expand Up @@ -1039,7 +1039,7 @@ class ExternalReferenceResolverTests: XCTestCase {
do {
let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/First", sourceLanguage: .swift)
let node = try context.entity(with: reference)
let rendered = try converter.convert(node)
let rendered = converter.convert(node)

XCTAssertEqual(rendered.seeAlsoSections.count, 1, "The page should only have the automatic See Also section created based on the curation on the Root page.")
let seeAlso = try XCTUnwrap(rendered.seeAlsoSections.first)
Expand All @@ -1053,7 +1053,7 @@ class ExternalReferenceResolverTests: XCTestCase {
do {
let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Second", sourceLanguage: .swift)
let node = try context.entity(with: reference)
let rendered = try converter.convert(node)
let rendered = converter.convert(node)

XCTAssertEqual(rendered.seeAlsoSections.count, 1, "The page should only have the automatic See Also section created based on the curation on the Root page.")
let seeAlso = try XCTUnwrap(rendered.seeAlsoSections.first)
Expand Down Expand Up @@ -1094,7 +1094,7 @@ class ExternalReferenceResolverTests: XCTestCase {
let reference = try XCTUnwrap(context.soleRootModuleReference)
let node = try context.entity(with: reference)
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
let rendered = try converter.convert(node)
let rendered = converter.convert(node)

XCTAssertEqual(rendered.seeAlsoSections.count, 1, "The page should only have the authored See Also section.")
let seeAlso = try XCTUnwrap(rendered.seeAlsoSections.first)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ExternalLinkableTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)

let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift))
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)
let pageSummary = summaries[0]
Expand Down Expand Up @@ -156,7 +156,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "MyClass")
Expand Down Expand Up @@ -200,7 +200,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "MyProtocol")
Expand Down Expand Up @@ -241,7 +241,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "myFunction()")
Expand Down Expand Up @@ -276,7 +276,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "globalFunction(_:considering:)")
Expand Down Expand Up @@ -333,7 +333,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
var summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "myFunction()")
Expand Down Expand Up @@ -438,7 +438,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "Bar")
Expand Down Expand Up @@ -497,7 +497,7 @@ class ExternalLinkableTests: XCTestCase {
do {
let symbolReference = ResolvedTopicReference(bundleID: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)", sourceLanguage: .swift)
let node = try context.entity(with: symbolReference)
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0]

XCTAssertEqual(summary.title, "myStringFunction(_:)")
Expand Down Expand Up @@ -728,7 +728,7 @@ class ExternalLinkableTests: XCTestCase {
let converter = DocumentationNodeConverter(bundle: bundle, context: context)

let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift))
let renderNode = try converter.convert(node)
let renderNode = converter.convert(node)

let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)
let pageSummary = summaries[0]
Expand Down
Loading

0 comments on commit 9b8db28

Please sign in to comment.