Skip to content

Commit 3511925

Browse files
committed
fixup! Allow @Metadata directives in doc comments
1 parent 9b7cc0d commit 3511925

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

Tests/SwiftDocCTests/Semantics/SymbolTests.swift

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ class SymbolTests: XCTestCase {
492492
XCTAssertEqual(withRedirectInArticle.redirects, nil)
493493

494494
XCTAssertEqual(problems.first?.diagnostic.identifier, "org.swift.docc.UnsupportedDocCommentDirective")
495-
XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.line, 15)
495+
XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.line, 3)
496496
XCTAssertEqual(problems.first?.diagnostic.range?.lowerBound.column, 1)
497497
}
498498

@@ -1225,6 +1225,7 @@ class SymbolTests: XCTestCase {
12251225
12261226
@Metadata
12271227
""",
1228+
docCommentLineOffset: 12,
12281229
articleContent: nil,
12291230
diagnosticEngineFilterLevel: .information
12301231
)
@@ -1247,6 +1248,7 @@ class SymbolTests: XCTestCase {
12471248
@Available("Platform from doc comment", introduced: 1.2.3)
12481249
}
12491250
""",
1251+
docCommentLineOffset: 12,
12501252
articleContent: """
12511253
# Title
12521254
@@ -1354,6 +1356,7 @@ class SymbolTests: XCTestCase {
13541356

13551357
func makeDocumentationNodeForSymbol(
13561358
docComment: String,
1359+
docCommentLineOffset: Int = 0,
13571360
articleContent: String?,
13581361
diagnosticEngineFilterLevel: DiagnosticSeverity = .warning,
13591362
file: StaticString = #file,
@@ -1363,21 +1366,15 @@ class SymbolTests: XCTestCase {
13631366
let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in
13641367
var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: url.appendingPathComponent("mykit-iOS.symbols.json")))
13651368

1366-
let newDocComment = SymbolGraph.LineList(
1367-
docComment
1368-
.components(separatedBy: .newlines)
1369-
.enumerated()
1370-
.map { arg -> SymbolGraph.LineList.Line in
1371-
var (index, line) = arg
1372-
index += 12 // Add an arbitrary offset
1373-
let range = SymbolGraph.LineList.SourceRange(
1374-
start: .init(line: index, character: 0),
1375-
end: .init(line: index, character: line.utf8.count)
1376-
)
1377-
return .init(text: line, range: range)
1378-
},
1379-
uri: "file:///tmp/File.swift"
1369+
let newDocComment = self.makeLineList(
1370+
docComment: docComment,
1371+
startOffset: .init(
1372+
line: docCommentLineOffset,
1373+
character: 0
1374+
),
1375+
url: URL(string: "file:///tmp/File.swift")!
13801376
)
1377+
13811378
// The `guard` statement` below will handle the `nil` case by failing the test and
13821379
graph.symbols[myFunctionUSR]?.docComment = newDocComment
13831380

0 commit comments

Comments
 (0)