From 3511925bd3089031db6767b017a9b8996b721f0e Mon Sep 17 00:00:00 2001 From: Franklin Schrans Date: Tue, 10 Dec 2024 09:45:23 +0000 Subject: [PATCH] fixup! Allow `@Metadata` directives in doc comments --- .../Semantics/SymbolTests.swift | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Tests/SwiftDocCTests/Semantics/SymbolTests.swift b/Tests/SwiftDocCTests/Semantics/SymbolTests.swift index aab28f085..09d3d9c2a 100644 --- a/Tests/SwiftDocCTests/Semantics/SymbolTests.swift +++ b/Tests/SwiftDocCTests/Semantics/SymbolTests.swift @@ -492,7 +492,7 @@ class SymbolTests: XCTestCase { XCTAssertEqual(withRedirectInArticle.redirects, nil) XCTAssertEqual(problems.first?.diagnostic.identifier, "org.swift.docc.UnsupportedDocCommentDirective") - XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.line, 15) + XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.line, 3) XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.column, 1) } @@ -1225,6 +1225,7 @@ class SymbolTests: XCTestCase { @Metadata """, + docCommentLineOffset: 12, articleContent: nil, diagnosticEngineFilterLevel: .information ) @@ -1247,6 +1248,7 @@ class SymbolTests: XCTestCase { @Available("Platform from doc comment", introduced: 1.2.3) } """, + docCommentLineOffset: 12, articleContent: """ # Title @@ -1354,6 +1356,7 @@ class SymbolTests: XCTestCase { func makeDocumentationNodeForSymbol( docComment: String, + docCommentLineOffset: Int = 0, articleContent: String?, diagnosticEngineFilterLevel: DiagnosticSeverity = .warning, file: StaticString = #file, @@ -1363,21 +1366,15 @@ class SymbolTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: url.appendingPathComponent("mykit-iOS.symbols.json"))) - let newDocComment = SymbolGraph.LineList( - docComment - .components(separatedBy: .newlines) - .enumerated() - .map { arg -> SymbolGraph.LineList.Line in - var (index, line) = arg - index += 12 // Add an arbitrary offset - let range = SymbolGraph.LineList.SourceRange( - start: .init(line: index, character: 0), - end: .init(line: index, character: line.utf8.count) - ) - return .init(text: line, range: range) - }, - uri: "file:///tmp/File.swift" + let newDocComment = self.makeLineList( + docComment: docComment, + startOffset: .init( + line: docCommentLineOffset, + character: 0 + ), + url: URL(string: "file:///tmp/File.swift")! ) + // The `guard` statement` below will handle the `nil` case by failing the test and graph.symbols[myFunctionUSR]?.docComment = newDocComment