From ac44131d62c3d7669ff28f03f645b2992d28f353 Mon Sep 17 00:00:00 2001 From: binamaniar Date: Thu, 29 May 2025 13:41:49 -0700 Subject: [PATCH] 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 --- Package.resolved | 4 ++-- .../SwiftDocC/Model/Rendering/RenderContentCompiler.swift | 4 ++++ Tests/SwiftDocCTests/Semantics/DoxygenTests.swift | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 21a53c4f86..03aed29581 100644 --- a/Package.resolved +++ b/Package.resolved @@ -3,7 +3,7 @@ { "identity" : "swift-argument-parser", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-argument-parser", + "location" : "https://github.com/apple/swift-argument-parser.git", "state" : { "revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b", "version" : "1.4.0" @@ -87,7 +87,7 @@ "location" : "https://github.com/swiftlang/swift-markdown.git", "state" : { "branch" : "release/6.2", - "revision" : "bc668ada42187e6c18eac420d66050a76d4ed764" + "revision" : "3be4e1a09cef425602f11bdb4b4de252e4badd11" } }, { diff --git a/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift b/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift index a8c03b5c26..58fabccede 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift @@ -359,6 +359,10 @@ struct RenderContentCompiler: MarkupVisitor { return renderableDirective.render(blockDirective, with: &self) } + mutating func visitDoxygenAbstract(_ doxygenAbstract: DoxygenAbstract) -> [any RenderContent] { + doxygenAbstract.children.flatMap { self.visit($0)} + } + mutating func visitDoxygenDiscussion(_ doxygenDiscussion: DoxygenDiscussion) -> [any RenderContent] { doxygenDiscussion.children.flatMap { self.visit($0) } } diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 664ce47513..99b7d85950 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -19,6 +19,7 @@ class DoxygenTests: XCTestCase { func testDoxygenDiscussionAndNote() throws { let documentationLines: [SymbolGraph.LineList.Line] = """ This is an abstract. + @abstract This is description with abstract. @discussion This is a discussion linking to ``AnotherClass`` and ``AnotherClass/prop``. @@ -96,6 +97,7 @@ class DoxygenTests: XCTestCase { XCTAssertEqual(symbol.abstract?.format(), "This is an abstract.") XCTAssertEqual(symbol.discussion?.content.map { $0.format() }, [ + #"\abstract This is description with abstract."#, #"\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``."# ]) @@ -108,10 +110,10 @@ class DoxygenTests: XCTestCase { XCTAssertEqual(renderNode.primaryContentSections.count, 1) let overviewSection = try XCTUnwrap(renderNode.primaryContentSections.first as? ContentRenderSection) - XCTAssertEqual(overviewSection.content.count, 3) + XCTAssertEqual(overviewSection.content.count, 4) XCTAssertEqual(overviewSection.content, [ .heading(.init(level: 2, text: "Overview", anchor: "overview")), - + .paragraph(.init(inlineContent: [.text("This is description with abstract.")])), .paragraph(.init(inlineContent: [ .text("This is a discussion linking to "), .reference(