Playground中格式注释语法
来源:互联网 发布:凯文.米特尼克 知乎 编辑:程序博客网 时间:2024/05/16 12:52
类似于Ruby的ruby document,Xcode的Playground自身也提供一些嵌入文档中的格式注释的语法.
我们先定义一个简单的类:
class A{}
按住opt点击class A,你会发现啥都没有
我们在class A上面增加一行注释,只不过有别于单行注释的//,我们用的是///
///A simple class that does some stuff you want it to do
现在描述具体多了吧.
接下来我们在类中添加一个方法:
///Does something;in this case ,prints out a message letting the user know that something is hanppening func test(){ print(#function) }
我们同样用///来描述该方法:
上面的方法没有参数和返回值,下面是一个签名齐全方法的实例:
/** this method is make two people to super couple!!!but be careful not everyone can make super successed,and even make successd,that's no one can give word that result is good! - Parameter name: the first person's name - Parameter otherName: the second person's name,aka other person ;]�� - Returns: A combined couple name */ func makeSuper(name:String,otherName:String)->String{ let str = "\(name) combine with \(otherName) to super couple!!!" print(str) return str }
如果方法有多个参数,我们嫌写多个Parameter麻烦,我们也可以用以下的语法,效果是一样的:
- Parameters: - name: the first person's name - otherName: the second person's name,aka other person ;]�� - Returns: A combined couple name
Xcode还提供其他的注释分类:
- Author: Panda Hopy - Version: 1.04 - Note: This is a simple class - Warning: This class doesn't actually do anything! - ToDo: Add some actual functionality to this class
效果如下:
如果我们喜欢,我们可以进一步美化格式,比如增加标题,粗体,斜体以及有序和无序列表:
# Lists You can apply *italic* , **bold** , or `code` inline styles to any text ,and _what_ ## Unordered Lists - Some item - Another item - The last item ## Ordered Lists 1. Some item 2. Another item 3. The last item
更详细的注释语法,我们可以到apple开发网站查询:
https://developer.apple.com/library/ios/documentation/Xcode/Reference/xcode_markup_formatting_ref/AnyPage.html#//apple_ref/doc/uid/TP40016497-CH22-SW1
0 0
- Playground中格式注释语法
- Playground
- 使用Playground快速练习Swift语法 (一)
- Xcode中playground的使用
- myeclipse中设置注释格式参考
- 在MyEclipse 中设置注释格式
- 怎么修改eclipse中注释的格式
- Myeclipse(eclipse)中自动注释格式设置
- myeclipse中java注释格式设置
- Myeclipse中java文件注释格式设置
- 项目中更改注释格式配置
- myeclipse中设置注释格式参考
- ACCESS中DLOOKUP的语法和格式
- 语法格式
- 语法格式
- eclipse3.4中设置新建文件注释格式收藏
- 代码编写中关于文件/函数注释的统一格式
- myeclipse中java文件头注释格式设置
- 5-5 堆中的路径 (25分)
- Geekband STL与泛型编程 第一周作业
- TensorFlow与TensorLayer教程[精选][转]
- 5-6 列出连通集 (25分)
- SqLite数据库MVC模式
- Playground中格式注释语法
- Vagrant使用指南:Vagrant第一个Helloworld例子
- TCP之Eclipse控制台的群聊
- http://bailian.openjudge.cn/practice/2694/2694:逆波兰表达式 题解
- gtest入口代码示例
- C++11 常用特性
- Win10语言包下载
- 5-7 六度空间 (30分)
- Kubernetes1.3:POD生命周期管理