Skip to content

Add support for abstract Headerdoc tag #1215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we avoid updating all the dependencies? Maybe we should just update the one new version of swift-markdown below. Or do we typically run swift package update and update everything when possible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually with a paired PR like this, we should only run swift package update swift-markdown to only pull in Swift-Markdown specifically, and leave the other dependencies alone.

"version" : "1.5.0"
}
},
{
"identity" : "swift-asn1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6",
"version" : "1.3.0"
"revision" : "a54383ada6cecde007d374f58f864e29370ba5c3",
"version" : "1.3.2"
}
},
{
Expand All @@ -33,34 +33,34 @@
"location" : "https://github.com/swiftlang/swift-cmark.git",
"state" : {
"branch" : "gfm",
"revision" : "2c47322cb32cbed555f13bf5cbfaa488cc30a785"
"revision" : "b97d09472e847a416629f026eceae0e2afcfad65"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "3d2dc41a01f9e49d84f0a3925fb858bed64f702d",
"version" : "1.1.2"
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
"version" : "1.1.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "06dc63c6d8da54ee11ceb268cde1fa68161afc96",
"version" : "3.9.1"
"revision" : "e8d6eba1fef23ae5b359c46b03f7d94be2f41fed",
"version" : "3.12.3"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-plugin.git",
"state" : {
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
"version" : "1.3.0"
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
Expand All @@ -69,7 +69,7 @@
"location" : "https://github.com/swiftlang/swift-docc-symbolkit.git",
"state" : {
"branch" : "main",
"revision" : "96bce1cfad4f4d7e265c1eb46729ebf8a7695f4b"
"revision" : "ddacb655e2087fd722cb5ca2bcc49953ee267e37"
}
},
{
Expand All @@ -78,34 +78,34 @@
"location" : "https://github.com/swiftlang/swift-lmdb.git",
"state" : {
"branch" : "main",
"revision" : "c42582487fe84f72a4d417dd2d8493757bd4d072"
"revision" : "1ad9a2d80b6fcde498c2242f509bd1be7d667ff8"
}
},
{
"identity" : "swift-markdown",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-markdown.git",
"location" : "https://github.com/binamaniar/swift-markdown.git",
"state" : {
"branch" : "main",
"revision" : "d21714073e0d16ba78eebdf36724863afc36871d"
"branch" : "support_abstract_headerdoc",
"revision" : "3d4d4196d9e1f3acc216755c542e71430f752984"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "fc79798d5a150d61361a27ce0c51169b889e23de",
"version" : "2.68.0"
"revision" : "0f54d58bb5db9e064f332e8524150de379d1e51c",
"version" : "2.82.1"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "6a9e38e7bd22a3b8ba80bddf395623cf68f57807",
"version" : "1.3.1"
"revision" : "a34201439c74b53f0fd71ef11741af7e7caf01e1",
"version" : "1.4.2"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// Building standalone, so fetch all dependencies remotely.
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
.package(url: "https://github.com/swiftlang/swift-markdown.git", branch: "main"),
.package(url: "https://github.com/binamaniar/swift-markdown.git", branch: "support_abstract_headerdoc"),
.package(url: "https://github.com/swiftlang/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
.package(url: "https://github.com/swiftlang/swift-docc-symbolkit.git", branch: "main"),
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/SwiftDocCTests/Semantics/DoxygenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand Down Expand Up @@ -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``."#
])
Expand All @@ -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.")])),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to actually parse @abstract as an abstract? I feel like it would stay true to the use of the command.

On the other hand, we probably shouldn't add too much Doxygen/HeaderDoc support, since we really want to push people to using Markdown... 😅 I'm fine either way on this, though i'm curious what the workgroup (or just the rest of our team) thinks.

.paragraph(.init(inlineContent: [
.text("This is a discussion linking to "),
.reference(
Expand Down