Skip to content

Issue with docComments rule: converts /// to // #2308

@MaxenceMottard

Description

@MaxenceMottard

Summary

When running SwiftFormat 0.58.7 with the docComments rule enabled, many /// doc comments are converted into // line comments. This breaks DocC/public symbol documentation.

Environment

  • SwiftFormat version: 0.58.7
  • Swift version: 5.7 (configured)
  • Command: swiftformat . --config .config/.swiftformat

Config

Relevant excerpt from .swiftformat:

--disable all
--enable ...
--enable docComments
--header strip

(full config available if needed)

Reproduction

  1. Create a Swift file like this:
/// Protocol for providing authentication challenges.
public protocol ChallengeProvider {
    func refreshChallenge()
}
  1. Run SwiftFormat 0.58.7 with the docComments rule enabled.

Actual result

The /// comment becomes:

// Protocol for providing authentication challenges.
public protocol ChallengeProvider {
    func refreshChallenge()
}

Expected result

/// doc comments should be preserved (or at least not downgraded to //).

Notes

This happens across multiple files in our codebase once the rule is enabled. We’ve disabled the rule temporarily as a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in developbug/feature resolved in the develop branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions