Skip to content

Commit 4fc891b

Browse files
committed
Add links to the test
1 parent bf8eef5 commit 4fc891b

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

Tests/SwiftDocCTests/Semantics/DoxygenTests.swift

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class DoxygenTests: XCTestCase {
2020
let documentationLines: [SymbolGraph.LineList.Line] = """
2121
This is an abstract.
2222
23-
@discussion This is a discussion.
23+
@discussion This is a discussion linking to ``AnotherClass`` and ``AnotherClass/prop``.
2424
25-
@note This is a note.
25+
@note This is a note linking to ``Class3`` and ``Class3/prop2``.
2626
"""
2727
.splitByNewlines
2828
.enumerated()
@@ -46,7 +46,43 @@ class DoxygenTests: XCTestCase {
4646
accessLevel: .public,
4747
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
4848
mixins: [:]
49-
)
49+
),
50+
SymbolGraph.Symbol(
51+
identifier: .init(precise: "another-class-id", interfaceLanguage: SourceLanguage.swift.id),
52+
names: .init(title: "AnotherClass", navigator: nil, subHeading: nil, prose: nil),
53+
pathComponents: ["AnotherClass"],
54+
docComment: nil,
55+
accessLevel: .public,
56+
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
57+
mixins: [:]
58+
),
59+
SymbolGraph.Symbol(
60+
identifier: .init(precise: "another-class-prop-id", interfaceLanguage: SourceLanguage.swift.id),
61+
names: .init(title: "prop", navigator: nil, subHeading: nil, prose: nil),
62+
pathComponents: ["AnotherClass", "prop"],
63+
docComment: nil,
64+
accessLevel: .public,
65+
kind: .init(parsedIdentifier: .property, displayName: "Kind Display Name"),
66+
mixins: [:]
67+
),
68+
SymbolGraph.Symbol(
69+
identifier: .init(precise: "class3-id", interfaceLanguage: SourceLanguage.swift.id),
70+
names: .init(title: "Class3", navigator: nil, subHeading: nil, prose: nil),
71+
pathComponents: ["Class3"],
72+
docComment: nil,
73+
accessLevel: .public,
74+
kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
75+
mixins: [:]
76+
),
77+
SymbolGraph.Symbol(
78+
identifier: .init(precise: "class3-prop-id", interfaceLanguage: SourceLanguage.swift.id),
79+
names: .init(title: "prop", navigator: nil, subHeading: nil, prose: nil),
80+
pathComponents: ["Class3", "prop"],
81+
docComment: nil,
82+
accessLevel: .public,
83+
kind: .init(parsedIdentifier: .property, displayName: "Kind Display Name"),
84+
mixins: [:]
85+
),
5086
]
5187
)),
5288
])
@@ -60,7 +96,10 @@ class DoxygenTests: XCTestCase {
6096
let symbol = try XCTUnwrap(node.semantic as? Symbol)
6197

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

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

72111
let overviewSection = try XCTUnwrap(renderNode.primaryContentSections.first as? ContentRenderSection)
73112
XCTAssertEqual(overviewSection.content.count, 3)
74-
75113
XCTAssertEqual(overviewSection.content, [
76114
.heading(.init(level: 2, text: "Overview", anchor: "overview")),
77115

78116
.paragraph(.init(inlineContent: [
79-
.text("This is a discussion.")
117+
.text("This is a discussion linking to "),
118+
.reference(
119+
identifier: .init("doc://unit-test/documentation/ModuleName/AnotherClass"),
120+
isActive: true,
121+
overridingTitle: nil,
122+
overridingTitleInlineContent: nil
123+
),
124+
.text(" and "),
125+
.reference(
126+
identifier: .init("doc://unit-test/documentation/ModuleName/AnotherClass/prop"),
127+
isActive: true,
128+
overridingTitle: nil,
129+
overridingTitleInlineContent: nil
130+
),
131+
.text(".")
80132
])),
81133

82134
.aside(.init(style: .init(asideKind: .note), content: [
83135
.paragraph(.init(inlineContent: [
84-
.text("This is a note.")
136+
.text("This is a note linking to "),
137+
.reference(
138+
identifier: .init("doc://unit-test/documentation/ModuleName/Class3"),
139+
isActive: true,
140+
overridingTitle: nil,
141+
overridingTitleInlineContent: nil
142+
),
143+
.text(" and "),
144+
.codeVoice(code: "Class3/prop2"),
145+
.text(".")
85146
]))
86147
])),
87148
])

0 commit comments

Comments
 (0)