4

I'm using Xcode 10 with Swift 5:

There are a couple of big functions in my code that need a detailed, multi-line description. Example:

/**
This is paragraph 1.

This is paragraph 2.

This is paragraph 3.
*/
func Foo() {
    //Bla
}

What Xcode creates:

enter image description here

Paragraph 2 and 3 are a continuation of paragraph 1, so it's irritating to have them in a different section.

How do I keep all three paragraphes in the same section (I don't care if it's the "summary", "description",... one)?

I'm aware of the documentation documentation here but there's no explanation of how to do this exactly and the only example of a multi-lined comment (scroll down to: "Calling this method increments the"...) is missing exactly this line of text in the screenshot of the "documentation" popup.

Edit: It's even worse if you use a list like this because the title stays behind in the "Summary" section, while the list items are pushed into the "Discussion" section:

/**
List Title:
- Item 1
- Item 2
- Item 3
*/

1 Answer 1

2

Xcode always interprets the first paragraph as a summary and everything after that as Discussion. The Summary will also be used in context with less space. For example as a hint for the code completion. Here is a good blog article about this that helped me: https://sarunw.com/posts/swift-documentation/

Not the answer you're looking for? Browse other questions tagged or ask your own question.