在 Xcode 中创建“快速帮助”条目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4286728/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:57:05  来源:igfitidea点击:

Create "Quick Help" Entry in Xcode

objective-cxcodedoxygencommentscode-documentation

提问by m Jae

How do I create quick help entries in Xcode for my own code? I just want it as a coding support, meaning like the Eclipse functionality when coding Java. In eclipse you get a comment you entered above a method when hovering a method somewhere else.

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

The Xcode equivalent seems to be the "Quick Help".

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

Is there really no other way than using Doxygen? Doxygen seems like overkill for the small project I'm working on. At the moment I do know for sure that I only want the quick help populated thoroughly, so please avoid any hints like, "you have to create a documentation for your project".

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

I would really appreciate any help as the only thing I could find on this topic was this question.

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

But as you can see, no solution is available.

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

回答by Alex Gray

Yes... you can.. Here is a ready-made "Snippet" you can drag or auto-complete, etc...

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

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

Drag that "onto" the snippet "thing" and like, you know.. set it up.. enter image description here

将其“拖到”片段“东西”上,就像,你知道的……设置它…… 在此处输入图片说明

and there ya have it...

你有它...

enter image description here

在此处输入图片说明

回答by lkraider

I think the only way is to create a Documentation Setfor your code and then install it on XCode:

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

Xcode 4′s contextual help, which Apple calls “Quick Help,” relies entirely on the installed documentation sets. Xcode 4 automatically downloads the documentation sets (including updates) for the Mac OS and iOS APIs but you can install third-party sets as well.

(...)

Once you create your documentation set, you can install it in Xcode's preferences (under the Documentation tab). Assuming the doc set is correctly built and installed, Quick Help should “just work.” Of course this is of limited use unless you're sharing complex API with a group or the wide world.

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

(...)

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

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

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

Apple's Documentation Set guide: http://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/Documentation_Sets/

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

回答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 memmons

Xcode 5 now has built-in support for DOxygen style comments. So, you can comment your methods like this:

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;



Inline help will look like this:

内联帮助将如下所示:

inline help



在线帮助



Quick help will look like this:

快速帮助如下所示:

quick help



快速帮助



And sidebar help will look like this:

侧边栏帮助将如下所示:

sidebar help

侧边栏帮助

Here's a handy code snippet you can add the your Xcode Code Snippet library to make method documentation simple:

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

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

doxygen code snippet

doxygen 代码片段

Now, you can just type "doxy" and poof! You have your doxygen template.

现在,您只需输入“doxy”然后噗!你有你的 doxygen 模板。

回答by Lewis Black

For anyone interested in how to do this in Swift 3.

对于任何对如何在 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.

*/

The parameters 1 and 2 have to be the correct names you have given your parameters.

参数 1 和 2 必须是您为参数指定的正确名称。

回答by 5AMp

A slightly modified, and code snippet version of Lewis' Swift 3 answer:

刘易斯的 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#>

 */

I had to use individual Parameter syntax because Xcode will otherwise ruin the formatting of nested parameters in the snippet (for whatever reason).

我不得不使用单独的 Parameter 语法,否则 Xcode 会破坏代码片段中嵌套参数的格式(无论出于何种原因)。

回答by Binarian

You can create a DocSet with AppleDoceasily and it generates QuickHelp-Links (option ? + mouse click).

您可以使用AppleDoc轻松创建 DocSet,它会生成QuickHelp-Links(选项?+ 鼠标单击)。

Examples and the Binary for the Terminal Command are here:

终端命令的示例和二进制文件在这里:

http://gentlebytes.com/appledoc-docs-examples-basic/

http://gentlebytes.com/appledoc-docs-examples-basic/

I tried it and only used the basic switches and the new DocSet works with QuickHelp:

我试过了,只使用了基本的开关,新的 DocSet 可以与 QuickHelp 一起使用:

./appledoc --project-name testdocs --project-company "My Company" --company-id com.mycompany --output ~/Desktop ~/Desktop/appledoc-master