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

Merged

Conversation

binamaniar
Copy link
Contributor

@binamaniar binamaniar commented May 9, 2025

Bug/issue #, if applicable: rdar://147920933

Summary

This note adds support for Doxygen @abstract tag. Abstract tags are turned into normal paragraphs.

Dependencies

Swift-markdown dependency swiftlang/swift-markdown#227

Testing

Create a documentation comment containing @abstract

This is an overview.

@abstract this is the content for abstract tag

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • [ yes] Added tests
  • [yes ] Ran the ./bin/test script and it succeeded
  • [ na] Updated documentation if necessary

@binamaniar binamaniar marked this pull request as draft May 9, 2025 01:59
@binamaniar binamaniar changed the title [WIP]rdar://147920933 (Support HeaderDoc tag) [WIP]Support HeaderDoc tag abstract May 9, 2025
@binamaniar binamaniar changed the title [WIP]Support HeaderDoc tag abstract Add support for abstract Headerdoc tag May 9, 2025
@binamaniar
Copy link
Contributor Author

@swift-ci please test

@binamaniar binamaniar marked this pull request as ready for review May 9, 2025 06:39
Copy link
Contributor

@patshaughnessy patshaughnessy left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Nit: A couple of the code files you modify here still have 2024 in their copyright message; pls update the year to 2025. (RenderContentCompiler.swift and DoxygenTests.swift)

Package.resolved Outdated
@@ -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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thank you both. That makes sense.

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

This looks good, though i would prefer if you could reset the Package.resolved and only run swift package resolve or swift package update swift-markdown when you update the branch back, so it only updates Swift-Markdown and swift-cmark.

My other comment is more of a curiosity. I think this PR can land as-is just so the content is properly rendered somehow, even if it's not as an abstract per se.

Package.resolved Outdated
@@ -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.

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.

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.

Copy link
Contributor Author

@binamaniar binamaniar May 26, 2025

Choose a reason for hiding this comment

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

With the thought of having limited Oxygen/HeaderDoc support I thought we should not restrain from parsing @abstract as an abstract. But open to other ideas too and can be convinced otherwise :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should at least explore what it would take for @abstract to become the abstract instead of being a sentence in the discussion.

It might also be good to verify that links in the abstract are resolved. IIRC this doesn't happen automatically for new elements.

…s with abstract headerdoc tag retains documentation
@binamaniar binamaniar force-pushed the 147920933_abstract_headerdoc_tag branch from 13d5c18 to b28f17e Compare May 13, 2025 04:50
Comment on lines +100 to 101
#"\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``."#,
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if these two lines were flipped? If the "abstract" content becomes the second sentence in the discussion section, then I'd argue that it's more important that we actually parse @abstract as an abstract (like Vera pointed our here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be a confusing workflow to support in terms of how the abstract is written while documenting, where the first time without tag is abstract, followed by discussion tag, and if there is a abstract tag post that, we would need to append to the abstract in the first line. It is an interesting scenario to think about but I don't know for sure we should support/facilitate that workflow.

@patshaughnessy
Copy link
Contributor

@swift-ci please test

@patshaughnessy
Copy link
Contributor

Merging as-is; we can file additional issues for the abstract related behavior in the future if needed.

@patshaughnessy patshaughnessy merged commit a0c57b8 into swiftlang:main May 29, 2025
2 checks passed
@d-ronnqvist
Copy link
Contributor

Merging as-is; we can file additional issues for the abstract related behavior in the future if needed.

We do need additional functionality. I filed rdar://152423453 to actually parse the @abstract content as an abstract (and to verify that links in that content are properly resolved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants