Playground中格式注释语法
2016-08-26 07:58
127 查看
类似于Ruby的ruby document,Xcode的Playground自身也提供一些嵌入文档中的格式注释的语法.
我们先定义一个简单的类:
按住opt点击class A,你会发现啥都没有
![](http://img.blog.csdn.net/20160826074452053)
我们在class A上面增加一行注释,只不过有别于单行注释的//,我们用的是///
![](http://img.blog.csdn.net/20160826074631027)
现在描述具体多了吧.
接下来我们在类中添加一个方法:
我们同样用///来描述该方法:
![](http://img.blog.csdn.net/20160826074808554)
上面的方法没有参数和返回值,下面是一个签名齐全方法的实例:
![](http://img.blog.csdn.net/20160826075015837)
如果方法有多个参数,我们嫌写多个Parameter麻烦,我们也可以用以下的语法,效果是一样的:
Xcode还提供其他的注释分类:
效果如下:
![](http://img.blog.csdn.net/20160826075436570)
如果我们喜欢,我们可以进一步美化格式,比如增加标题,粗体,斜体以及有序和无序列表:
![](http://img.blog.csdn.net/20160826075643075)
更详细的注释语法,我们可以到apple开发网站查询:
https://developer.apple.com/library/ios/documentation/Xcode/Reference/xcode_markup_formatting_ref/AnyPage.html#//apple_ref/doc/uid/TP40016497-CH22-SW1
我们先定义一个简单的类:
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
相关文章推荐
- Playground中格式注释语法
- Playground中格式注释语法
- 从0开始学java——JUnit4 复习,其实基本思想还是那些,不过采用了新的注释格式的语法
- IOS 封装类的时候注释格式,使用的时候可以想官方库一样快捷显示
- 存储过程的语法格式为
- lua语法-程序块(chunk)与注释
- iptables的基本语法格式
- Delphi基本语法格式
- JScript多语言语法加亮引擎改进(修正多行注释识别)
- xml--语法02-- 元素/标签/element,属性,注释
- PHP代码添加注释的几种格式
- 一步一步学习Swift之(二):好玩的工具playground与swfit基础语法
- JSP基础语法:注释、Scriptlet、编译指令
- 【Linux学习笔记】Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)
- JPA like 模糊查询 语法格式
- 2.1php标签,语法,注释
- Java Annotation注释语法
- Linux下AT&T汇编语法格式简介
- 设置Java文件注释格式
- 格式正规的XML:语法 属性 实体 处理指令 样式单 CDATA节