我认为多行注释最好是这样的:
/* this is a mult-line comment, which wraps lines at some reasonable length,
* usually approximately 80 characters. this way, comments are easy to read
* and, with any half way capable text editor, easy to edit without having
* to manually reshuffle lines, line breaks, and the comment leader. */
// this is a mult-line comment, which wraps lines at some reasonable length,
// usually approximately 80 characters. this way, comments are easy to read
// and, with any half way capable text editor, easy to edit without having
// to manually reshuffle lines, line breaks, and the comment leader.
/* this is a mult-line comment, which wraps lines at some reasonable length,
usually approximately 80 characters. this way, comments are easy to read
and, with any half way capable text editor, easy to edit without having
to manually reshuffle lines, line breaks, and the comment leader. */
但是,XCode 不支持以这种风格管理评论。您必须在正确的时间手动按回车键以适当的宽度包装评论,然后编辑它们成为完整的 PITA。
或者,您永远不会按回车键并让编辑器将其包装在编辑器屏幕的边缘。但如果你像我一样,你的编辑器比理想的自动换行行长度要宽得多。
此外,XCode 通过提供一个在编辑器中以 80 个字符呈现包装指南的功能来 mock 我,但这纯粹是一个视觉功能,没有任何机制来支持它。这感觉就像把一把花园铲子交给习惯使用反铲的人。
我是否需要在这里进行实际检查 - 我的想法是否错误 - 还是 XCode 极度缺乏基本的段落式注释格式?
经验丰富、负责任、专业的 Objective-C 开发人员在代码中发表大量注释时会怎么做?帮我看看这里的光。
注意:对于 XCode 3,我编写了一个手卷脚本,它重新格式化文本并将其绑定(bind)到一个热键。我还没有弄清楚如何在 XCode 4 中做到这一点。但是如何编写 XCode 4 脚本与这个问题有点正交:必须用这些基础知识来扩充 IDE 听起来很糟糕,我的问题是关于 XCode 开发人员的风格和文化期望。
感谢您的建议。
最佳答案
我同意它应该内置在 Xcode 中。但无论如何,这里是如何通过创建一个调用脚本的服务项并为其分配键盘快捷键来快速将其添加到 Xcode4:
fmt
实用程序来重新格式化您的文本,允许行以句点开头,折叠行内的空格,允许缩进段落,在 80 个字符列处换行。查看 fmt
的手册页以了解其他选项。显然,您可以在这里通过 emacs 或 markdown 或其他方式传递文本来发疯。现在,当您在 Xcode 中选择文本后,您可以通过菜单栏选择服务将其重新格式化为 80 个字符:Xcode/Services/Reformat-to-80。
现在让我们为其分配一个键盘快捷键:
现在,在 Xcode 中,您可以使用该键盘快捷键将所选文本替换为 shell 脚本的输出,这会将文本重新格式化为
https://stackoverflow.com/questions/7353097/