Skip to content

Commit

Permalink
Add links to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Feb 6, 2024
1 parent 7e9a056 commit 81d113c
Showing 1 changed file with 68 additions and 7 deletions.
75 changes: 68 additions & 7 deletions Tests/SwiftDocCTests/Semantics/DoxygenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class DoxygenTests: XCTestCase {
let documentationLines: [SymbolGraph.LineList.Line] = """
This is an abstract.
@discussion This is a discussion.
@discussion This is a discussion linking to ``AnotherClass`` and ``AnotherClass/prop``.
@note This is a note.
@note This is a note linking to ``Class3`` and ``Class3/prop2``.
"""
.splitByNewlines
.enumerated()
Expand All @@ -46,7 +46,43 @@ class DoxygenTests: XCTestCase {
accessLevel: .public,
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
mixins: [:]
)
),
SymbolGraph.Symbol(
identifier: .init(precise: "another-class-id", interfaceLanguage: SourceLanguage.swift.id),
names: .init(title: "AnotherClass", navigator: nil, subHeading: nil, prose: nil),
pathComponents: ["AnotherClass"],
docComment: nil,
accessLevel: .public,
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
mixins: [:]
),
SymbolGraph.Symbol(
identifier: .init(precise: "another-class-prop-id", interfaceLanguage: SourceLanguage.swift.id),
names: .init(title: "prop", navigator: nil, subHeading: nil, prose: nil),
pathComponents: ["AnotherClass", "prop"],
docComment: nil,
accessLevel: .public,
kind: .init(parsedIdentifier: .property, displayName: "Kind Display Name"),
mixins: [:]
),
SymbolGraph.Symbol(
identifier: .init(precise: "class3-id", interfaceLanguage: SourceLanguage.swift.id),
names: .init(title: "Class3", navigator: nil, subHeading: nil, prose: nil),
pathComponents: ["Class3"],
docComment: nil,
accessLevel: .public,
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
mixins: [:]
),
SymbolGraph.Symbol(
identifier: .init(precise: "class3-prop-id", interfaceLanguage: SourceLanguage.swift.id),
names: .init(title: "prop", navigator: nil, subHeading: nil, prose: nil),
pathComponents: ["Class3", "prop"],
docComment: nil,
accessLevel: .public,
kind: .init(parsedIdentifier: .property, displayName: "Kind Display Name"),
mixins: [:]
),
]
)),
])
Expand All @@ -60,7 +96,10 @@ class DoxygenTests: XCTestCase {
let symbol = try XCTUnwrap(node.semantic as? Symbol)

XCTAssertEqual(symbol.abstract?.format(), "This is an abstract.")
XCTAssertEqual(symbol.discussion?.content.map { $0.format() }, [#"\discussion This is a discussion."#, #"\note This is a note."#])
XCTAssertEqual(symbol.discussion?.content.map { $0.format() }, [
#"\discussion This is a discussion linking to ``doc://unit-test/documentation/ModuleName/AnotherClass`` and ``doc://unit-test/documentation/ModuleName/AnotherClass/prop``."#,
#"\note This is a note linking to ``doc://unit-test/documentation/ModuleName/Class3`` and ``Class3/prop2``."#
])

// Verify the expected content in the render model
var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference, source: nil)
Expand All @@ -71,17 +110,39 @@ class DoxygenTests: XCTestCase {

let overviewSection = try XCTUnwrap(renderNode.primaryContentSections.first as? ContentRenderSection)
XCTAssertEqual(overviewSection.content.count, 3)

XCTAssertEqual(overviewSection.content, [
.heading(.init(level: 2, text: "Overview", anchor: "overview")),

.paragraph(.init(inlineContent: [
.text("This is a discussion.")
.text("This is a discussion linking to "),
.reference(
identifier: .init("doc://unit-test/documentation/ModuleName/AnotherClass"),
isActive: true,
overridingTitle: nil,
overridingTitleInlineContent: nil
),
.text(" and "),
.reference(
identifier: .init("doc://unit-test/documentation/ModuleName/AnotherClass/prop"),
isActive: true,
overridingTitle: nil,
overridingTitleInlineContent: nil
),
.text(".")
])),

.aside(.init(style: .init(asideKind: .note), content: [
.paragraph(.init(inlineContent: [
.text("This is a note.")
.text("This is a note linking to "),
.reference(
identifier: .init("doc://unit-test/documentation/ModuleName/Class3"),
isActive: true,
overridingTitle: nil,
overridingTitleInlineContent: nil
),
.text(" and "),
.codeVoice(code: "Class3/prop2"),
.text(".")
]))
])),
])
Expand Down

0 comments on commit 81d113c

Please sign in to comment.