Skip to content

Commit

Permalink
fixup! Allow @Metadata directives in doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinsch committed Dec 10, 2024
1 parent 9b7cc0d commit 3511925
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions Tests/SwiftDocCTests/Semantics/SymbolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -1225,6 +1225,7 @@ class SymbolTests: XCTestCase {
@Metadata
""",
docCommentLineOffset: 12,
articleContent: nil,
diagnosticEngineFilterLevel: .information
)
Expand All @@ -1247,6 +1248,7 @@ class SymbolTests: XCTestCase {
@Available("Platform from doc comment", introduced: 1.2.3)
}
""",
docCommentLineOffset: 12,
articleContent: """
# Title
Expand Down Expand Up @@ -1354,6 +1356,7 @@ class SymbolTests: XCTestCase {

func makeDocumentationNodeForSymbol(
docComment: String,
docCommentLineOffset: Int = 0,
articleContent: String?,
diagnosticEngineFilterLevel: DiagnosticSeverity = .warning,
file: StaticString = #file,
Expand All @@ -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

Expand Down

0 comments on commit 3511925

Please sign in to comment.