34

如何在 Xcode 中为我自己的代码创建快速帮助条目?我只是希望它作为编码支持,这意味着在编码 Java 时就像 Eclipse 功能一样。在 Eclipse 中,当将方法悬停在其他地方时,您会在方法上方输入注释。

Xcode 等效项似乎是“快速帮助”。

除了使用 Doxygen 真的没有别的办法了吗?对于我正在从事的小项目来说,Doxygen 似乎有点矫枉过正。目前我确实知道我只想要彻底填充快速帮助,所以请避免任何提示,例如“您必须为您的项目创建文档”。

我真的很感激任何帮助,因为我在这个主题上唯一能找到的就是这个问题

但如您所见,没有可用的解决方案。

4

7 回答 7

29

是的......你可以......这是一个现成的“片段”,你可以拖动或自动完成等......

/** 
 * <#summary#>
 * @param <#name#> <#how you gonna get it?#>
 * @param <#name#> <#really, there's more?#>
 * @return <#name#> <#what do you want!#>
 */

将那个“拖到”片段“东西”上,就像,你知道的..设置它.. 在此处输入图像描述

那里有它...

在此处输入图像描述

于 2013-07-10T17:31:59.317 回答
9

我认为唯一的方法是为您的代码创建一个文档集,然后将其安装在 XCode 上:

Xcode 4 的上下文帮助,Apple 称之为“快速帮助”,完全依赖于安装的文档集。Xcode 4 会自动下载 Mac OS 和 iOS API 的文档集(包括更新),但您也可以安装第三方集。

(...)

创建文档集后,您可以将其安装在 Xcode 的首选项中(在“文档”选项卡下)。假设文档集正确构建和安装,快速帮助应该“正常工作”。当然,除非您与小组或全世界共享复杂的 API,否则这是有限的。

来源:http: //xcodebook.com/2011/04/providing-your-own-quick-help/

Apple 的文档集指南:http: //developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/Documentation_Sets/

于 2011-07-08T16:55:37.653 回答
6

从 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;

单击选项时,会出现这个可爱的弹出框:

于 2013-10-08T20:49:26.417 回答
5

Xcode 5 现在内置了对 DOxygen 样式注释的支持。因此,您可以像这样评论您的方法:

/*!
 * 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;


内联帮助将如下所示:

内联帮助



快速帮助将如下所示:

快速帮助



侧边栏帮助将如下所示:

侧边栏帮助

这是一个方便的代码片段,您可以添加 Xcode 代码片段库以简化方法文档:

/**
 <#description#>
 @param <#parameter#>
 @returns <#retval#>
 @exception <#throws#>
 */

doxygen 代码片段

现在,你可以输入“doxy”然后噗!你有你的 doxygen 模板。

于 2013-11-11T18:45:40.077 回答
2

对于任何对如何在 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 必须是您为参数指定的正确名称。

于 2016-10-25T23:36:17.770 回答
0

您可以使用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
于 2013-04-25T07:40:12.770 回答
0

刘易斯的 Swift 3 答案的稍微修改的代码片段版本:

    /**
 <#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 否则会破坏片段中嵌套参数的格式(无论出于何种原因)。

于 2019-03-13T18:27:01.407 回答