Skip to content

Commit f746d75

Browse files
committed
Fix links in Mentioned In section
1 parent 2df6b8d commit f746d75

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Sources/DocCHTML/MarkdownRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ package struct MarkdownRenderer<Provider: LinkProvider> {
248248
)
249249
}
250250

251-
func path(to other: URL) -> String {
251+
package func path(to other: URL) -> String {
252252
let from = path
253253
let to = other
254254

Sources/SwiftDocC/Model/Rendering/HTML/HTMLRenderer.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,16 @@ struct HTMLRenderer {
451451
let mentions = context.articleSymbolMentions.articlesMentioning(reference)
452452
if !mentions.isEmpty {
453453
articleElement.addChildren(
454+
// FIXME: Create a dedicated MarkdownRenderer method for the "Mentioned In" section
454455
renderer.selfReferencingSection(named: "Mentioned In", content: [
455456
.element(named: "ul", children: mentions.compactMap { reference in
456-
context.documentationCache[reference].map { .element(named: "li", children: [.text($0.name.description)]) }
457+
context.documentationCache[reference].map {
458+
.element(named: "li", children: [
459+
.element(named: "a", children: [.text($0.name.description)], attributes: [
460+
"href": renderer.path(to: $0.reference.url) + "/index.html"
461+
])
462+
])
463+
}
457464
})
458465
])
459466
)

Tests/SwiftDocCUtilitiesTests/FileWritingHTMLContentConsumerTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
254254
</section>
255255
<h2>Mentioned In</h2>
256256
<ul>
257-
<li>Some article</li>
257+
<li>
258+
<a href="../somearticle/index.html">Some article</a>
259+
</li>
258260
</ul>
259261
<h2>Topics</h2>
260262
<h3>Instance Methods</h3>

0 commit comments

Comments
 (0)