我们不允许提出有关书籍、工具、软件库等方面的建议的问题。您可以编辑问题,以便用事实和引用来回答它。
关闭4年前。
Xcode 5's new features 之一是使用特殊注释语法记录您自己的代码的能力。格式类似于 doxygen,但似乎只支持 those features 的子集。 .
支持哪些命令,哪些不支持?
它们的用法与 doxygen 有什么不同吗?
最佳答案
这是我在 Xcode 5.0.2 中找到的所有选项的示例
这是使用此代码生成的:
/** 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 {}
注意事项:
/** block */
中, /*! block */
, 或以 ///
为前缀或 //!
.@
( headerdoc 样式)或 \
( doxygen 样式) 前缀。 (即 @b
和 \b
都做同样的事情。)@property
文本之前。)它们可以在同一行之后,与 /*!<
一起出现。 , /**<
, //!<
, ///<
.@returns
除外。 .
这将显示简短的文本(没有格式);如果不存在简短文本,它将显示所有文本的串联,直到第一个@block;如果不存在(例如,您以 @return 开头),那么它将连接所有删除所有 @commands 的文本。
(见第一张截图。)
由于 Xcode 5 中的命令与 Doxygen 兼容,您可以下载并使用 Doxygen 生成文档文件。
有关 Doxygen 的一般介绍以及如何记录 Objective-C 代码,this page似乎是一个很好的资源。
部分支持的命令说明:
@brief
: 将在描述字段的开头插入文本,并且是在代码完成期间出现的唯一文本。以下不起作用:
\n
: 不生成换行符。创建换行符的一种方法是确保该行上没有任何内容。一个空格字符都没有!\example
不支持以下内容(它们甚至不显示为深绿色):
Apple 使用的似乎是保留关键字,仅在其文档中有效。尽管它们以深绿色显示,但看起来我们不能像 Apple 那样使用它们。您可以在 AVCaptureOutput.h 等文件中查看 Apple 的使用示例。
以下是其中一些关键字的列表:
在最好的情况下,关键字会在描述字段中产生一个新行(例如@discussion)。在最坏的情况下,关键字及其后面的任何文本都不会出现在快速帮助中(例如@class)。
https://stackoverflow.com/questions/19168423/