Xcode:显示我的自定义类的文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6958413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode: show documentation for my custom classes
提问by Peter ?tibrany
How can I force Xcode to show my own documentation for custom classes, methods, etc.? I'm used to Java and Eclipse, which shows me documentation for my classes as shown here:
如何强制 Xcode 显示我自己的自定义类、方法等文档?我习惯了 Java 和 Eclipse,它们向我展示了我的类的文档,如下所示:


How can I achieve the same in Xcode? Are there special comments that Xcode can recognize and display?
如何在 Xcode 中实现相同的目标?是否有 Xcode 可以识别和显示的特殊注释?


采纳答案by cbowns
As of Xcode 5.0, Doxygen and HeaderDoc formatting for variables and methods is automatically parsed and rendered in the Quick Help popover. More information about it here, but here's some key bits:
从 Xcode 5.0 开始,变量和方法的 Doxygen 和 HeaderDoc 格式会自动解析并在快速帮助弹出窗口中呈现。关于它的更多信息在这里,但这里有一些关键位:
/**
* Add a data point to the data source.
* (Removes the oldest data point if the data source contains kMaxDataPoints objects.)
*
* @param aDataPoint An instance of ABCDataPoint.
* @return The oldest data point, if any.
*/
- (ABCDataPoint *)addDataToDataSource:(ABCDataPoint *)aDataPoint;
renders in Xcode as:
在 Xcode 中呈现为:


As for properties, it's as easy as:
至于属性,它很简单:
/// Base64-encoded data.
@property (nonatomic, strong) NSData *data;
When option-clicked, this lovely popover appears:
单击选项时,会出现这个可爱的弹出窗口:


回答by Deboroh88
Well, it seems that for the classes the question hasn't still been answered, so I'll post my suggestions.
好吧,对于课程来说,问题似乎还没有得到解答,所以我会发布我的建议。
Just before the @interface MyClass : NSObjectline in the MyClass.h file you use the comment like you did in your example, but adding some tags to display the text. For example the code below:
就在@interface MyClass : NSObjectMyClass.h 文件中的行之前,您像在示例中一样使用注释,但添加了一些标签来显示文本。例如下面的代码:
/**
* @class GenericCell
* @author Average Joe
* @date 25/11/13
*
* @version 1.0
*
* @discussion This class is used for the generic lists
*/
will produce the following output: the output of the code above http://imageshack.com/a/img18/2194/kdi0.png
将产生以下输出: http://imageshack.com/a/img18/2194/kdi0.png 上面代码的输出
回答by DougW
Appledocis the best option for generating xcode documentation at the moment. Doxygen is great, but it does not generate docsets that work very well for the popups you're talking about. Appledoc isn't perfect, but we moved over to it and have been really happy with the results.
Appledoc是目前生成 xcode 文档的最佳选择。Doxygen 很棒,但它不会生成非常适合您正在谈论的弹出窗口的文档集。Appledoc 并不完美,但我们转向它并且对结果非常满意。


回答by Sauvik Dolui
It is also possible to add some code snippet in documentation like the following
也可以在文档中添加一些代码片段,如下所示


by adding the following code
通过添加以下代码
* @code
* - (UIButton*) createButtonWithRect:(CGRect)rect
{
// Write your code here
}
* @endcode
For more details of documenting methods of a custom class you can have a look on my blog Function Documentation in Xcode.
有关记录自定义类的方法的更多详细信息,您可以查看我的博客Xcode 中的函数文档。
回答by Mark Szymczyk
To get Xcode to show documentation for your classes, you must create a documentation set for your classes using a tool like Doxygen or HeaderDoc. After creating the documentation set, you must install it using Xcode's documentation preferences. Apple has an article on using Doxygen, but it covers Xcode 3, not 4.
要让 Xcode 显示您的类的文档,您必须使用 Doxygen 或 HeaderDoc 等工具为您的类创建文档集。创建文档集后,您必须使用 Xcode 的文档首选项安装它。Apple 有一篇关于使用 Doxygen 的文章,但它涵盖了 Xcode 3,而不是 4。

