Xcode 是否有类似 Javadoc 的插件可以自动生成文档模板?
我知道 Doxygen 可以生成文档。我正在寻找一种在 Xcode 中插入文档的快速方法,类似于 Eclipse 在编辑 Java 文件时所做的事情。
假设我有一个 Objective-C 方法,它有几个像这样的参数:
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
在 Eclipse 中,如果将光标放在方法上方并输入:/**
,您将获得一个 Javadoc 模板预先填充了 @param
和 @return
标签。
Xcode 中是否可以实现类似的功能?输入 /**
后,我想自动获取:
/**
*
* @param one
* @param two
*
* @return
*/
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
I'm aware of Doxygen to generate the documentation. What I'm looking for is quick way to insert documentation in Xcode similar to what Eclipse does when editing Java files.
Let's say I have an objective-c method with a couple of arguments like this:
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
In Eclipse, if you place the cursor above the method and type: /**<Enter>
you get a Javadoc template pre-populated with @param
and @return
tags.
Is it possible to achieve something similar in Xcode? After typing /**<Enter>
, I'd like to get this automatically:
/**
*
* @param one
* @param two
*
* @return
*/
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里的脚本 http:// www.duckrowing.com/2011/05/14/using-the-doxygen-helper-in-xcode-4/ 正是您想要的。
编辑:
这是脚本的更新版本:https://github.com/premosystems/DoxygenXCodeHelper
The script here http://www.duckrowing.com/2011/05/14/using-the-doxygen-helper-in-xcode-4/ does exactly what you want.
EDIT:
Here is an updated version of the Script: https://github.com/premosystems/DoxygenXCodeHelper
我一直在 Xcode 5 中成功使用 VVDocumenter-Xcode 并且运行良好。当您在方法上方输入“///”时,它会自动生成特定于该方法的模板。
I have been using VVDocumenter-Xcode successfully in Xcode 5 and it works well. It automatically generates a template specific to a method when you enter "///" above the method.
“用户脚本”菜单(Xcode 菜单栏中的黑色小滚动图标)有一个 HeaderDoc 子菜单,其中包含 HD 语法中各种文档标记的模板。您可以通过转到 Xcode 的“首选项”窗口中的“按键绑定”来为要使用的项目设置键盘快捷键。
由于用户脚本本质上是 shell 脚本,因此您可以使用任何脚本语言来编写自己的脚本,因此如果您愿意,您甚至可以编写一个小的正则表达式辅助脚本,该脚本可以解析所选行中的参数名称并填写您的脚本的基础知识。标题文档注释。
The "User Scripts" menu (that little black scroll icon in Xcode's menu bar) has a HeaderDoc submenu with templates for all sorts of documentation markup in HD syntax. You can set a keyboard shortcut for the items you want to use by going to "Key Bindings" in Xcode's "Preferences" window.
Since User Scripts are essentially shell scripts, you can use any scripting language to write your own, so if you wanted you could even write a little regex-aided script that parses the parameter names out of the selected line and fills out the basics of your HeaderDoc comment.
如果您有耐心,请查看此处,因为它解释了完成行为和覆盖在 XCode 中。我不知道这是否适用于评论集,但这似乎是一个好的开始。
——弗兰克
If you've got the patience, take a look here as it explains completion behavior and overrides in XCode. I don't know if this will work for the comment set but it seems like a good start.
-- Frank