Swift编程规范之 Documentation/Comments
Documentation/Comments 1 Documentation如果某个函数不是简单地O(1)操作,那么最好就是为该函数添加一些注释文档,这样能有效地提高代码的可读性与可维护性。之前有个非常不错的文档工具VVDocumenter。推荐阅读Apple的官方指南中的描述:described in Apple’s Documentation. Guidelines:
/** ## Feature Support This class does some awesome things. It supports: - Feature 1 - Feature 2 - Feature 3 ## Examples Here is an example use case indented by four spaces because that indicates a code block: let myAwesomeThing = MyAwesomeClass() myAwesomeThing.makeMoney() ## Warnings:告警 There are some things you should be careful of: 1. Thing one 2. Thing two 3. Thing three */
class MyAwesomeClass {
/* ... */
}
/** This does something with a `UIViewController`,perchance. - warning: Make sure that `someValue` is `true` before running this function. */
func myFunction() {
/* ... */
}
2 Other Commenting Guidelines:其他的注释规则
class Pirate {
// MARK: - instance properties
private let pirateName: String
// MARK: - initialization
init() {
/* ... */
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |