Xcode 注释自动补全(appledoc 风格) [英] Xcode comments autocompletion (appledoc style)

查看:41
本文介绍了Xcode 注释自动补全(appledoc 风格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现记录我的界面特别痛苦,因为我需要自己输入所有内容.所以我想我一定不是唯一一个这样的人,并开始寻找一种方法来减轻我的痛苦,但没有找到太多.

I find documentating my interfaces particularly painful because I need to type everything myself. So I figured that I must not be the only one like this and started to look for a way to reduce my pain but didn't find much.

我的问题是,是否有快捷方式或方法让 Xcode 自动完成我的评论?例如,如果我输入 /** + [tab],它会自动完成:

My question is, is there a shortcut or a way to have Xcode autocomplete my comments? For example, I'd very much like if I type /** + [tab] that it autocompletes to:

/**
 * [cursor here]
 * 
 * (maybe some pre-populate a list of arguments for the method below)
 */
- (void)test:(NSString *)testString another:(NSString *)another;

谢谢!

推荐答案

使用 Xcode 的片段功能.你可以用你想要的任何文本创建一个片段,并在文本中添加要填充的项目.要创建一个片段,只需在 Xcode 编辑器中选择一些文本并将其拖到片段库中.您可以设置完成快捷方式,因此诸如 m-comment 之类的内容可能是您的标准方法注释:

Use Xcode's snippets feature. You can create a snippet with whatever text you want, and add items in the text to be filled in. To create a snippet, just select some text in an Xcode editor and drag it into the snippet library. You can set the completion shortcut, so something like m-comment could be your standard method comment:

输入 m-comment 的第一位,然后显示整个快捷方式(和任何其他补全),并接受补全添加一个注释,其中包含等待填写的参数化部分.像往常一样,您可以从一个切换到下一个:

Typing the first bit of m-comment then displays the entire shortcut (and any other completions), and accepting the completion adds a comment with the parameterized parts waiting to be filled in. As usual, you can tab from one to the next:

您通过将文本的给定部分包含在 <##> 中来表明文本的给定部分是一个要填写的字段,例如:<#方法名称#>.

You indicate that a given part of the text is a field to be filled in by enclosing it in <# and #>, like: <#method name#>.

当然,Objective-C 的强项之一就是方法名一般会告诉你参数是什么.在评论中重复这一点似乎是不必要的额外工作.Xcode 3 更好地支持包含脚本的脚本,这些脚本会自动生成带有参数的 HeaderDoc 注释.不过,它们并没有被广泛使用,可能是因为这些评论并没有真正的用处.

Of course, one of the strengths of Objective-C is that the method name generally tells you what the parameters are. Repeating that in a comment seems like unnecessary extra work. Xcode 3 had better support for scripts included scripts that would automatically generate HeaderDoc comments with parameters. They weren't widely used, though, probably because those kinds of comments weren't really useful.

这篇关于Xcode 注释自动补全(appledoc 风格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆