【问题标题】:Create "Quick Help" Entry in Xcode在 Xcode 中创建“快速帮助”条目
【发布时间】:2011-05-16 06:18:41
【问题描述】:
如何在 Xcode 中为我自己的代码创建快速帮助条目?
我只是希望它作为编码支持,这意味着在编码 Java 时就像 Eclipse 功能一样。
在 Eclipse 中,当将方法悬停在其他地方时,您会在方法上方输入注释。
Xcode 等效项似乎是“快速帮助”。
除了使用 Doxygen 真的没有别的方法了吗?
对于我正在从事的小项目来说,Doxygen 似乎有点矫枉过正。
目前我确实知道我只希望彻底填充快速帮助,因此请避免任何提示,例如“您必须为您的项目创建文档”。
我非常感谢任何帮助,因为我能在这个主题上找到的唯一内容就是 question。
但正如您所见,没有可用的解决方案。
【问题讨论】:
标签:
objective-c
xcode
doxygen
comments
code-documentation
【解决方案1】:
是的......你可以......这是一个现成的“片段”,你可以拖动或自动完成等......
/**
* <#summary#>
* @param <#name#> <#how you gonna get it?#>
* @param <#name#> <#really, there's more?#>
* @return <#name#> <#what do you want!#>
*/
将那个“拖到”sn-p“东西”上,就像,你知道的.. 设置它..
你有它...
【解决方案3】:
从 Xcode 5.0 开始,变量和方法的 Doxygen 和 HeaderDoc 格式会自动解析并呈现在快速帮助弹出窗口中。有关它的更多信息here,但这里有一些关键位:
/**
* 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;
在 Xcode 中呈现为:
至于属性,很简单:
/// Base64-encoded data.
@property (nonatomic, strong) NSData *data;
当点击选项时,会出现这个可爱的弹出框:
【解决方案4】:
Xcode 5 现在内置了对 DOxygen 样式 cmets 的支持。因此,您可以像这样评论您的方法:
/*!
* Provides an NSManagedObjectContext singleton appropriate for use on the main
* thread. If the context doesn't already exist it is created and bound to the
* persistent store coordinator for the application, otherwise the existing
* singleton contextis returned.
* \param someParameter You can even add parameters
* \returns The a shared NSManagedObjectContext for the application.
*/
+ (NSManagedObjectContext *)sharedContext;
内联帮助将如下所示:
快速帮助如下所示:
侧边栏帮助将如下所示:
这是一个方便的代码 sn-p,您可以添加 Xcode 代码片段库以简化方法文档:
/**
<#description#>
@param <#parameter#>
@returns <#retval#>
@exception <#throws#>
*/
现在,您只需输入“doxy”就可以了!你有你的 doxygen 模板。
【解决方案5】:
对于任何对如何在 Swift 3 中执行此操作感兴趣的人。
/**
Makes a route
- Parameters:
- Parameter1 : The *x* component.
- Parameter2 : The *y* component.
- Throws: Error.IncorrectX if the x parameter
is less than zero.
- Returns: A new integer answer which is x*y.
*/
参数 1 和 2 必须是您为参数指定的正确名称。
【解决方案6】:
您可以使用 AppleDoc 轻松创建 DocSet,它会生成 QuickHelp-Links(选项 ⌥ + 鼠标单击)。
终端命令的示例和二进制文件在这里:
http://gentlebytes.com/appledoc-docs-examples-basic/
我试过了,只使用了基本的开关,新的 DocSet 与 QuickHelp 一起工作:
./appledoc --project-name testdocs --project-company "My Company" --company-id com.mycompany --output ~/Desktop ~/Desktop/appledoc-master
【解决方案7】:
Lewis 的 Swift 3 答案的略微修改和代码 sn-p 版本:
/**
<#summary#>
<#discussion#>
Example:
````
<#example codeblock#>
````
- important: <#important stuff here#>
- version: <#version number#>
- Parameter <#param1#> : <#description#>
- Parameter <#param2#> : <#description#>
- Throws: <#error description#>
- Returns: <#return value#>
*/
我不得不使用单独的参数语法,否则 Xcode 会破坏 sn-p 中嵌套参数的格式(无论出于何种原因)。