Skip to content

Commit a0c57b8

Browse files
authored
Add support for abstract Headerdoc tag (#1215)
* Adding support for abstract headerdoc tag so the methods or properties with abstract headerdoc tag retains documentation * changes after merging swift markdown changes
1 parent 471c1f1 commit a0c57b8

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ struct RenderContentCompiler: MarkupVisitor {
359359
return renderableDirective.render(blockDirective, with: &self)
360360
}
361361

362+
mutating func visitDoxygenAbstract(_ doxygenAbstract: DoxygenAbstract) -> [any RenderContent] {
363+
doxygenAbstract.children.flatMap { self.visit($0)}
364+
}
365+
362366
mutating func visitDoxygenDiscussion(_ doxygenDiscussion: DoxygenDiscussion) -> [any RenderContent] {
363367
doxygenDiscussion.children.flatMap { self.visit($0) }
364368
}

Tests/SwiftDocCTests/Semantics/DoxygenTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DoxygenTests: XCTestCase {
1919
func testDoxygenDiscussionAndNote() throws {
2020
let documentationLines: [SymbolGraph.LineList.Line] = """
2121
This is an abstract.
22+
@abstract This is description with abstract.
2223
2324
@discussion This is a discussion linking to ``AnotherClass`` and ``AnotherClass/prop``.
2425
@@ -96,6 +97,7 @@ class DoxygenTests: XCTestCase {
9697

9798
XCTAssertEqual(symbol.abstract?.format(), "This is an abstract.")
9899
XCTAssertEqual(symbol.discussion?.content.map { $0.format() }, [
100+
#"\abstract This is description with abstract."#,
99101
#"\discussion This is a discussion linking to ``doc://unit-test/documentation/ModuleName/AnotherClass`` and ``doc://unit-test/documentation/ModuleName/AnotherClass/prop``."#,
100102
#"\note This is a note linking to ``doc://unit-test/documentation/ModuleName/Class3`` and ``Class3/prop2``."#
101103
])
@@ -108,10 +110,10 @@ class DoxygenTests: XCTestCase {
108110
XCTAssertEqual(renderNode.primaryContentSections.count, 1)
109111

110112
let overviewSection = try XCTUnwrap(renderNode.primaryContentSections.first as? ContentRenderSection)
111-
XCTAssertEqual(overviewSection.content.count, 3)
113+
XCTAssertEqual(overviewSection.content.count, 4)
112114
XCTAssertEqual(overviewSection.content, [
113115
.heading(.init(level: 2, text: "Overview", anchor: "overview")),
114-
116+
.paragraph(.init(inlineContent: [.text("This is description with abstract.")])),
115117
.paragraph(.init(inlineContent: [
116118
.text("This is a discussion linking to "),
117119
.reference(

0 commit comments

Comments
 (0)