Xcode 文档注释格式

objc 格式

参考链接:https://stackoverflow.com/a/19169271/16991379
/** First line text.

 Putting \\n doesn't create a new line.\n One way to create a newline is by making sure nothing is on that line. Not even a single space character!

 @a Italic text @em with @@a or @@em.

 @b Bold text with @@b.

 @p Typewritter font @c with @@p or @@c.

 Backslashes and must be escaped: C:\\foo.

 And so do @@ signs: user@@example.com

 Some more text.
 @brief brief text
 @attention attention text
 @author author text
 @bug bug text
 @copyright copyright text
 @date date text
 @invariant invariant text
 @note note text
 @post post text
 @pre pre text
 @remarks remarks text
 @sa sa text
 @see see text
 @since since text
 @todo todo text
 @version version text
 @warning warning text

 @result result text
 @return return text
 @returns returns text


 @code
// code text
while (someCondition) {
    NSLog(@"Hello");
    doSomething();
}@endcode
 Last line text.

 @param param param text
 @tparam tparam tparam text
 */
- (void)myMethod {}

效果图:

img

Swift 格式

官方链接:https://developer.apple.com/documentation/xcode/writing-symbol-documentation-in-your-source-files

参考链接:

  • https://stackoverflow.com/a/27766320/16991379
  • https://nshipster.cn/swift-documentation/

Swift 文档注释是差不多可以按照 markdown 格式走的,输入 /// 或者 /** */ 就可以了。也支持类似 NoteAttention 这样的关键字。

/// text
///
/// - Attention: attentionText
var maxWidth: CGFloat = 375