This actually has nothing to do with lists, but headings. Notice that if you remove the heading # Examples:
, or just the #
character, the markdown is rendered as expected.
For some reason, Xcode ignores all the text after it encounters a heading of any kind in a documentation comment.
See this example from this very old answer. It apparently worked back then!
/// Text like this appears in "Description".
///
/// Leave a blank line to separate further text into paragraphs.
///
/// You can use bulleted lists (use `-`, `+` or `*`):
///
/// - Text can be _emphasised_
/// - Or **strong**
///
/// Or numbered lists:
///
/// 7. The numbers you use make no difference
/// 0. The list will still be ordered, starting from 1
/// 5. But be sensible and just use 1, 2, 3 etc…
///
/// ---
///
/// More Stuff
/// ==========
///
/// Code
/// ----
///
/// Use backticks for inline `code()`. Indentations of 4 spaces or more will create a code block, handy for example usage:
///
/// // Create an integer, and do nothing with it
/// let myInt = 42
/// doNothing(myInt)
///
/// // Also notice that code blocks scroll horizontally instead of wrapping.
///
/// Links & Images
/// --------------
///
/// Include [links](https://en.wikipedia.org/wiki/Hyperlink), and even images:
///
/// 
///
/// - note: That "Note:" is written in bold.
/// - requires: A basic understanding of Markdown.
/// - seealso: `Error`, for a description of the errors that can be thrown.
///
/// - parameters:
/// - int: A pointless `Int` parameter.
/// - bool: This `Bool` isn't used, but its default value is `false` anyway…
/// - throws: A `BadLuck` error, if you're unlucky.
/// - returns: Nothing useful.
public func doNothing(int: Int, bool: Bool = false) throws -> String {
return "Totally contrived."
}
Xcode's "discussion" part stops before the first heading,

(Try deleting the headings and see what happens!)
The parameters and returns seem to be rendered fine though.
On the other hand, if I use a documentation generator like jazzy
like the linked answer suggests, the headings and all the other text are rendered properly:

There is no Swift Logo because I didn't download one to my local machine :) Your documentation for formattedString
function is also generated properly by jazzy
, without needing to change anything.
As another alternative, AppCode generates documentation for both your formattedString
function and the above example correctly too.
So I think this is a just a quirk/bug in Xcode. Documentation generators can still properly generate documentations from these comments.