Skip to content
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

[SR-2373] Trailing doc comment should not be attached to the next declaration #44980

Open
rintaro mannequin opened this issue Aug 17, 2016 · 7 comments
Open

[SR-2373] Trailing doc comment should not be attached to the next declaration #44980

rintaro mannequin opened this issue Aug 17, 2016 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 17, 2016

Previous ID SR-2373
Radar rdar://problem/45962451
Original Reporter @rintaro
Type Bug
Environment

Xcode Version 8.0 beta 6 (8S201h)

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee None
Priority Medium

md5: 81805e4a3595d7dec2f0cb6dbd2cedff

relates to:

  • SR-9616 SwiftSyntax is not following trivia rule

Issue Description:

Printing interface of this:

public class C {
    public var i: Int = 1 /// FOO
    public var j: Int = 1 /** BAR */
    public var k: Int = 1
}

results:

public class C {

    public var i: Int

    /// FOO
    public var j: Int

    /** BAR */
    public var k: Int
}

I believe this is not a result the author intended.

@belkadan
Copy link
Contributor

Doxygen has syntax for this—///<—but we can probably figure it out on our own.

@belkadan
Copy link
Contributor

cc @bitjammer, @akyrtzi

@akyrtzi
Copy link
Member

akyrtzi commented Aug 17, 2016

To quote @gribozavr from rdar://26982593: "It was a deliberate decision to not add “trailing comments” in Swift, because when I was implementing this feature for Clang, we found a ton of nasty corner-cases and non-intuitive behavior."

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Aug 18, 2016

How about just ignoring trailing comments, for now?

Definition of "trailing comments": Comment which is not isAtStartOfLine

Example:

decl1 /**
   trailing
*/ /** not trailing, attached to `decl2` */ decl2 /** trailing */ /// trailing
/// not trailing, attached to `decl3`

decl3

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 4, 2018

Comment by Yasuhiro Inami (JIRA)

I personally prefer:

public class C {
    public var i: Int = 1 /// FOO
    public var j: Int = 1 /** BAR */
    public var k: Int = 1
}

or

// Extra newline is added after trailing doc-comment
public class C {
    public var i: Int = 1
    /// FOO

    public var j: Int = 1
    /** BAR */

    public var k: Int = 1
}

be equivalent to this:

public class C {
    /// FOO
    public var i: Int

    /** BAR */
    public var j: Int

    public var k: Int
}

And using extra symbol e.g. `///<` seems redundant to me.

cf. https://twitter.com/inamiy/status/1058957674086260737

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Nov 5, 2018

@swift-ci create

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 9, 2019

Comment by Yasuhiro Inami (JIRA)

Related: SR-9616

My previous comment in #comment-41118 should be modified that:

// Extra newline is added after trailing doc-comment
public class C {
    public var i: Int = 1
    /// FOO

    public var j: Int = 1
    /** BAR */

    public var k: Int = 1
}

will NOT be the case of trailing-doc-comment
because when thinking about SR-9616 syntax's trivia rule, `/// FOO` should still be owned by `public var j ...`'s leadingTrivia.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

3 participants