Browse Source

【完善】:MicroPython 文档格式

SummerGift 7 years ago
parent
commit
774587703b

+ 6 - 7
docs/03-Basic_Module/01-rtthread.md

@@ -4,17 +4,16 @@
 !!! abstract "简介"
      **rtthread** 模块提供了与 RT-Thread 操作系统相关的功能,如查看栈使用情况等。
 
-
 ## 函数
 
-- rtthread.current_tid()  
-  返回当前线程的 id 。
+### rtthread.current_tid()  
+返回当前线程的 id 。
 
-- rtthread.is_preempt_thread()  
-  返回是否是可抢占线程。
+### rtthread.is_preempt_thread()  
+返回是否是可抢占线程。
 
-- rtthread.stacks_analyze()  
-  返回当前系统线程和栈使用信息。
+### rtthread.stacks_analyze()  
+返回当前系统线程和栈使用信息。
 
 ## 示例 
 

+ 22 - 29
docs/05-System_Module/01-uos.md

@@ -3,46 +3,37 @@
 !!! abstract "简介"
     `uos` 模块包含了对文件系统的访问操作,是对应 CPython 模块的一个子集。
 
-更多内容可参考 [uos](http://docs.micropython.org/en/latest/pyboard/library/uos.html) 。
-
-`函数`
+## 函数
 
-- uos.chdir(path)  
-  更改当前目录。
+### **uos.chdir**(path)  
+更改当前目录。
 
-- uos.getcwd()  
-  获取当前目录。
+### **uos.getcwd**()  
+获取当前目录。
 
-- uos.ilistdir([dir])  
-  这个函数返回一个迭代器,然后产生三元组对应正在列出的目录中的条目。没有参数,它列出了
-  当前目录,否则它列出了目录给出的`dir`。
+### **uos.listdir**([dir])
+没有参数就列出当前目录,否则列出给定目录。
 
-- 3-元组的形式`(name, type, inode)`:
-  name 是一个字符串(或字节,如果是一个字节对象),是输入的名称;
-  type 是一个整数,指定的条目类型,与普通文件和目录0x4000 0x8000;
-  inode 对应文件的inode的整数,可0的文件系统,没有这样的概念。
-  uos.listdir([dir])
-  没有参数,列出当前目录。否则列出给定目录。
+### **uos.mkdir**(path)  
+创建一个目录。
 
-- uos.mkdir(path)  
-  创建一个目录
+### **uos.remove**(path)  
+删除文件。
 
-- uos.remove(path)  
-  删除文件
+### **uos.rmdir**(path)  
+删除目录
 
-- uos.rmdir(path)  
-  删除目录
+### **uos.rename**(old_path, new_path)  
+重命名文件
 
-- uos.rename(old_path, new_path)  
-  重命名文件
+### **uos.stat**(path)  
+获取文件或目录的状态
 
-- uos.stat(path)  
-  获取文件或目录的状态
+### **uos.sync**()  
+同步所有的文件系统
 
-- uos.sync()  
-  同步所有的文件系统。
+## 示例
 
-`example`:
 ```
 >>> import uos
 >>> uos.                        # Tab 
@@ -63,4 +54,6 @@ stat            unlink          mount           umount
 >>> 
 ```
 
+更多内容可参考 [uos](http://docs.micropython.org/en/latest/pyboard/library/uos.html) 。
+
 ----------

+ 23 - 27
docs/05-System_Module/02-uselect.md

@@ -1,41 +1,37 @@
 # **uselect** – 等待流事件
-`uselect` 模块提供了在流上等待事件的功能(选择可操作的流),轮询是在多个对象上等待读/写活动的有效方法。
+!!! abstract "简介"
+    `uselect` 模块提供了在流上等待事件的功能(选择可操作的流),轮询是在多个对象上等待读/写活动的有效方法。
 
-更多内容可参考 [select](https://docs.python.org/3.5/library/select.html#module-select) 。
-
-`函数`
-
-- select.poll()  
-  创建轮询类的实例。
+## 函数
 
-- select.select(rlist, wlist, xlist[, timeout])  
-  等待激活一组对象
+### **select.poll**()  
+创建轮询类的实例。
 
-提供的兼容性和效率不高,推荐使用 `Poll`。
+### **select.select**(rlist, wlist, xlist[, timeout])  
+等待激活一组对象。提供的兼容性和效率不高,推荐使用 `Poll`。
 
-`eventmask` 
+## `eventmask` 
 
-- select.POLLIN - 读取可用数据  
+### **select.POLLIN** - 读取可用数据  
 
-- select.POLLOUT - 写入更多数据  
+### **select.POLLOUT** - 写入更多数据  
 
-- select.POLLERR - 发生错误  
+### **select.POLLERR** - 发生错误  
 
-- select.POLLHUP - 流结束/连接终止检测  
-  eventmask 默认 select.POLLIN | select.POLLOUT.
+### **select.POLLHUP** - 流结束/连接终止检测  
+eventmask 默认 select.POLLIN | select.POLLOUT.
 
-`类 Poll`
+## 类 Poll
 
-- poll.register(obj[, eventmask])  
-  登记轮询对象 obj 。 
+### **poll.register**(obj[, eventmask])  
+注册轮询对象 。 
+### **poll.unregister**(obj)  
+注销轮询对象。
+### **poll.modify**(obj, eventmask)  
+修改对象的 eventmask。
+### **poll.poll**([timeout])  
+等待至少一个已注册的对象准备就绪。返回列表(obj, event, ...) 元组, event 元素指定了一个流发生的事件,是上面所描述的 `select.POLL*`常量组合。 在元组中可能有其他元素,取决于平台和版本,所以不要假定它的大小是2。如果超时,则返回空列表。超时为毫秒。
 
-- poll.unregister(obj)  
-  注销轮询对象 obj。
-
-- poll.modify(obj, eventmask)  
-  修改对象 ``obj`` 的 eventmask。
-
-- poll.poll([timeout])  
-  等待至少一个已注册的对象准备就绪。返回列表(obj, event, ...) 元组, event 元素指定了一个流发生的事件,是上面所描述的 `select.POLL*`常量组合。 在元组中可能有其他元素,取决于平台和版本,所以不要假定它的大小是2。如果超时,则返回空列表。超时为毫秒。
+更多内容可参考 [select](https://docs.python.org/3.5/library/select.html#module-select) 。
 
 ----------

+ 20 - 16
docs/05-System_Module/03-uctypes.md

@@ -1,27 +1,31 @@
 # **uctypes** – 以结构化的方式访问二进制数据
-`uctypes` 模块是 MicroPython 的外函数库,它提供 C 兼容的数据类型。
 
-更多内容可参考 [ctypes](https://docs.python.org/3/library/ctypes.html?highlight=ctypes#module-ctypes) 。
+!!! abstract "简介"
+    `uctypes` 模块是 MicroPython 的外函数库,它提供 C 兼容的数据类型。
+
+## 常量
+### **uctypes.LITTLE_ENDIAN**
+Layout type for a little-endian packed structure. (Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1).
 
-- uctypes.LITTLE_ENDIAN  
-  Layout type for a little-endian packed structure. (Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1).
+### **uctypes.BIG_ENDIAN**  
+Layout type for a big-endian packed structure.
 
-- uctypes.BIG_ENDIAN  
-  Layout type for a big-endian packed structure.
+### **uctypes.NATIVE**  
+Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs.
 
-- uctypes.NATIVE  
-  Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs.
+## 函数
+### **uctypes.sizeof**(struct)  
+Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object (or its aggregate field).
 
-- uctypes.sizeof(struct)  
-  Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object (or its aggregate field).
+### **uctypes.addressof**(obj)  
+Return address of an object. Argument should be bytes, bytearray or other object supporting buffer protocol (and address of this buffer is what actually returned).
 
-- uctypes.addressof(obj)  
-  Return address of an object. Argument should be bytes, bytearray or other object supporting buffer protocol (and address of this buffer is what actually returned).
+### **uctypes.bytes_at**(addr, size)  
+Capture memory at the given address and size as bytes object. As bytes object is immutable, memory is actually duplicated and copied into bytes object, so if memory contents change later, created object retains original value.
 
-- uctypes.bytes_at(addr, size)  
-  Capture memory at the given address and size as bytes object. As bytes object is immutable, memory is actually duplicated and copied into bytes object, so if memory contents change later, created object retains original value.
+### **uctypes.bytearray_at**(addr, size)  
+Capture memory at the given address and size as bytearray object. Unlike bytes_at() function above, memory is captured by reference, so it can be both written too, and you will access current value at the given memory address.
 
-- uctypes.bytearray_at(addr, size)  
-  Capture memory at the given address and size as bytearray object. Unlike bytes_at() function above, memory is captured by reference, so it can be both written too, and you will access current value at the given memory address.
+更多内容可参考 [ctypes](https://docs.python.org/3/library/ctypes.html?highlight=ctypes#module-ctypes) 。
 
 ----------

+ 4 - 4
docs/05-System_Module/04-uerrno.md

@@ -1,10 +1,9 @@
 # **uerrno** – 系统错误码模块
 
-`uerrno` 模块提供了标准的 errno 系统符号,每个符号的值是对应的整数值。
+!!! abstract "简介"
+    `uerrno` 模块提供了标准的 errno 系统符号,每个符号都有对应的整数值。
 
-更多内容可参考 [errno](https://docs.python.org/3/library/errno.html?highlight=errno#module-errno) 。
-
-`Usage example` :
+## 示例
 
 ```
 try:
@@ -18,5 +17,6 @@ Dictionary mapping numeric error codes to strings with symbolic error code (see
 >>> print(uerrno.errorcode[uerrno.EEXIST])
 EEXIST
 ```
+更多内容可参考 [errno](https://docs.python.org/3/library/errno.html?highlight=errno#module-errno) 。
 
 ----------

+ 5 - 3
docs/05-System_Module/05-_thread.md

@@ -1,9 +1,9 @@
 # **_thread** – 多线程支持
-`_thread` 模块提供了用于处理多线程的基本方法——多个控制线程共享它们的全局数据空间。为了实现同步,提供了简单的锁(也称为互斥锁或二进制信号量)。
+!!! abstract "简介"
+    `_thread` 模块提供了用于处理多线程的基本方法——多个控制线程共享它们的全局数据空间。为了实现同步,提供了简单的锁(也称为互斥锁或二进制信号量)。
 
-更多内容可参考 [_thread](https://docs.python.org/3/library/_thread.html?highlight=_thread#module-_thread)  。
+## 示例
 
-`example`:
 ```
 >>> ###  press CTRL + E to enter paste mode
 
@@ -22,4 +22,6 @@ paste mode; Ctrl-C to cancel, Ctrl-D to finish
 
 ```
 
+更多内容可参考 [_thread](https://docs.python.org/3/library/_thread.html?highlight=_thread#module-_thread)  。
+
 ----------

+ 27 - 26
docs/06-Tools_Module/01-cmath.md

@@ -1,43 +1,44 @@
 # **cmath** – 复数的数学函数
-`cmath` 模块提供了对复数的数学函数的访问。这个模块中的函数接受整数、浮点数或复数作为参数。他们还将接受任何有复杂()或浮点()方法的Python对象:这些方法分别用于将对象转换成复数或浮点数,然后将该函数应用到转换的结果中。
+!!! abstract "简介"
+    `cmath` 模块提供了对复数的数学函数的访问。这个模块中的函数接受整数、浮点数或复数作为参数。他们还将接受任何有复数或浮点方法的 Python 对象:这些方法分别用于将对象转换成复数或浮点数,然后将该函数应用到转换的结果中。
 
-更多内容可参考 [cmath](https://docs.python.org/3/library/cmath.html?highlight=cmath#module-cmath)  。
+## 函数
 
-`函数`
+### **cmath.cos**(z)  
+返回``z``的余弦。
 
-- cmath.cos(z)  
-  返回``z``的余弦
+### **cmath.exp**(z)  
+返回``z``的指数
 
-- cmath.exp(z)  
-  返回``z``的指数。
+### **cmath.log**(z)  
+返回``z``的对数。
 
-- cmath.log(z)  
-  返回``z``的对数。
+### **cmath.log10**(z)  
+返回``z``的常用对数。
 
-- cmath.log10(z)  
-  返回``z``的常用对数
+### **cmath.phase**(z)  
+返回``z``的相位, 范围是(-pi, +pi],以弧度表示
 
-- cmath.phase(z)  
-  返回``z``的相位, 范围是(-pi, +pi],以弧度表示
+### **cmath.polar**(z)  
+返回``z``的极坐标
 
-- cmath.polar(z)  
-  返回``z``的极坐标.
+### **cmath.rect**(r, phi)  
+返回`模量r`和相位``phi``的复数。
 
-- cmath.rect(r, phi)  
-  返回`模量`r``和相位``phi``的复数
+### **cmath.sin**(z)  
+返回``z``的正弦
 
-- cmath.sin(z)  
-  返回``z``的正弦
+### **cmath.sqrt**(z)  
+返回``z``的平方根
 
-- cmath.sqrt(z)  
-  返回``z``的平方根。
+## 常数
 
-`常数`
+### **cmath.e**  
+自然对数的指数。
 
-- cmath.e  
-  自然对数的指数
+### **cmath.pi**  
+圆周率
 
-- cmath.pi  
-  圆周率。
+更多内容可参考 [cmath](https://docs.python.org/3/library/cmath.html?highlight=cmath#module-cmath)  。
 
 ----------

+ 14 - 14
docs/06-Tools_Module/02-ubinascii.md

@@ -1,24 +1,24 @@
 # **ubinascii** – 二进制/ ASCII转换
-`ubinascii` 模块包含许多在二进制和各种 ascii 编码的二进制表示之间转换的方法。
-
-更多内容可参考 [binascii](https://docs.python.org/3/library/binascii.html?highlight=binascii#module-binascii)  。
+!!! abstract "简介"
+    `ubinascii` 模块包含许多在二进制和各种 ascii 编码的二进制表示之间转换的方法。
 
+## 函数
 
-`函数`
+### **ubinascii.hexlify**(data[, sep])  
+将二进制数据转换为十六进制表示。
 
-- ubinascii.hexlify(data[, sep])  
-  将二进制数据转换为十六进制表示。
+### **Difference to CPython**  
+If additional argument, sep is supplied, it is used as a separator between hexadecimal values.
 
-- Difference to CPython  
-  If additional argument, sep is supplied, it is used as a separator between hexadecimal values.
+### **ubinascii.unhexlify**(data)  
+将十六进制数据转换为二进制表示。返回字节串 (换言之, 反二进制转换)
 
-- ubinascii.unhexlify(data)  
-  将十六进制数据转换为二进制表示。返回字节串 (换言之, 反二进制转换)
+### **ubinascii.a2b_base64**(data)  
+Base64编码的数据转换为二进制表示。返回字节串。
 
-- ubinascii.a2b_base64(data)  
-  Base64编码的数据转换为二进制表示。返回字节串。
+### **ubinascii.b2a_base64**(data)  
+编码base64格式的二进制数据。返回的字符串。
 
-- ubinascii.b2a_base64(data)  
-  编码base64格式的二进制数据。返回的字符串。
+更多内容可参考 [binascii](https://docs.python.org/3/library/binascii.html?highlight=binascii#module-binascii)  。
 
 ----------

+ 23 - 19
docs/06-Tools_Module/03-uhashlib.md

@@ -1,34 +1,38 @@
 # **uhashlib** – 哈希算法
-`uhashlib` 模块实现了二进制数据哈希算法。
+!!! abstract "简介"
+    `uhashlib` 模块实现了二进制数据哈希算法。
 
-更多内容可参考 [hashlib](https://docs.python.org/3/library/hashlib.html?highlight=hashlib#module-hashlib)  。
+## 算法功能
 
-其中的算法提供的功能有:
+### **SHA256** 
+The current generation, modern hashing algorithm (of SHA2 series). It is suitable for cryptographically-secure purposes. Included in the MicroPython core and any board is recommended to provide this, unless it has particular code size constraints.
 
-SHA256 - The current generation, modern hashing algorithm (of SHA2 series). It is suitable for cryptographically-secure purposes. Included in the MicroPython core and any board is recommended to provide this, unless it has particular code size constraints.
+### **SHA1**
+A previous generation algorithm. Not recommended for new usages, but SHA1 is a part of number of Internet standards and existing applications, so boards targetting network connectivity and interoperatiability will try to provide this.
 
-SHA1 - A previous generation algorithm. Not recommended for new usages, but SHA1 is a part of number of Internet standards and existing applications, so boards targetting network connectivity and interoperatiability will try to provide this.
+### **MD5** 
+A legacy algorithm, not considered cryptographically secure. Only selected boards, targetting interoperatibility with legacy applications, will offer this.
 
-MD5 - A legacy algorithm, not considered cryptographically secure. Only selected boards, targetting interoperatibility with legacy applications, will offer this.
+## 函数
 
-`函数`
+### **class uhashlib.sha256**([data])  
+创建一个SHA256哈希对象并提供 data 赋值。
 
-- class uhashlib.sha256([data])  
-  创建一个SHA256哈希对象并提供 data 赋值。
+### **class uhashlib.sha1**([data])  
+创建一个SHA1哈希对象并提供 data 赋值。
 
-- class uhashlib.sha1([data])  
-  创建一个SHA1哈希对象并提供 data 赋值。
+### **class uhashlib.md5**([data])  
+创建一个MD5哈希对象并提供 data 赋值。
 
-- class uhashlib.md5([data])  
-  创建一个MD5哈希对象并提供 data 赋值
+### **hash.update**(data)  
+将更多二进制数据放入哈希表中
 
-- hash.update(data)  
-  将更多二进制数据放入哈希表中
+### **hash.digest**()  
+返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希
 
-- hash.digest()  
-  返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希
+### **hash.hexdigest**()  
+此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果
 
-- hash.hexdigest()  
-  此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。
+更多内容可参考 [hashlib](https://docs.python.org/3/library/hashlib.html?highlight=hashlib#module-hashlib)  。
 
 ----------

+ 10 - 9
docs/06-Tools_Module/04-uheapq.md

@@ -1,18 +1,19 @@
 # **uheapq** – 堆排序算法
 
-`uheapq` 模块提供了堆排序相关算法,堆队列是一个列表,它的元素以特定的方式存储。
+!!! abstract "简介"
+    `uheapq` 模块提供了堆排序相关算法,堆队列是一个列表,它的元素以特定的方式存储。
 
-更多内容可参考 [heapq](https://docs.python.org/3/library/heapq.html?highlight=heapq#module-heapq)  。
+## 函数
 
-`函数`
+### **uheapq.heappush**(heap, item)  
+将对象压入堆中。
 
-- uheapq.heappush(heap, item)  
-  把 item 推到 heap
+### **uheapq.heappop**(heap)  
+从 heap 弹出第一个元素并返回。 如果是堆时空的会抛出 IndexError
 
-- uheapq.heappop(heap)  
-  从 heap 弹出第一个元素并返回。 如果是堆时空的会抛出 IndexError
+### **uheapq.heapify**(x)  
+将列表 x 转换成堆
 
-- uheapq.heapify(x)  
-  将列表 x 转换成堆。
+更多内容可参考 [heapq](https://docs.python.org/3/library/heapq.html?highlight=heapq#module-heapq)  。
 
 ----------

+ 8 - 7
docs/06-Tools_Module/05-ujson.md

@@ -1,14 +1,15 @@
 # **ujson** – JSON编码与解码
-`ujson` 模块提供 Python 对象到 JSON(JavaScript Object Notation) 数据格式的转换。
+!!! abstract "简介"
+    `ujson` 模块提供 Python 对象到 JSON(JavaScript Object Notation) 数据格式的转换。
 
-更多内容可参考 [json](https://docs.python.org/3/library/json.html?highlight=json#module-json)  。
+## 函数
 
-`函数`
+### **ujson.dumps**(obj)  
+返回对象的 JSON 字符串。
 
-- ujson.dumps(obj)  
-  返回 obj JSON字符串
+### **ujson.loads**(str)  
+解析 str 字符串并返回对象。如果字符串格式错误将引发 ValueError 异常
 
-- ujson.loads(str)  
-  解析 str 字符串并返回对象。如果字符串格式错误将引发 ValueError 异常。
+更多内容可参考 [json](https://docs.python.org/3/library/json.html?highlight=json#module-json)  。
 
 ----------

+ 26 - 25
docs/06-Tools_Module/06-ure.md

@@ -1,15 +1,17 @@
 # **ure** – 正则表达式
-`ure` 模块用于测试字符串的某个模式,执行正则表达式操作。
+!!! abstract "简介"
+    `ure` 模块用于测试字符串的某个模式,执行正则表达式操作。
+
+## 匹配字符集
 
-更多内容可参考 [re](https://docs.python.org/3/library/re.html?highlight=re#module-re)  。
 
-- 支持操作符:
+### 匹配任意字符
   ``'.'``
 
-- 匹配任意字符。
+### 匹配字符集合,支持单个字符和一个范围
   ``'[]'``
 
-- 匹配字符集合,支持单个字符和一个范围。
+### 支持多种匹配元字符
   ``'^'``
   ``'$'``
   ``'?'``
@@ -18,36 +20,35 @@
   ``'??'``
   ``'*?'``
   ``'+?'``
+  ``'{m,n}'``
 
-重复计数 ({m,n}), 不支持高级的断言、命名组等。
-
-`函数`
-
-- ure.compile(regex)  
-  编译正则表达式,返回 regex 对象。
+## 函数
 
-- ure.match(regex, string)  
-  用 string 匹配 regex,匹配总是从字符串的开始匹配
+### **ure.compile**(regex)  
+编译正则表达式,返回 regex 对象。
 
-- ure.search(regex, string)  
-  在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)
+### **ure.match**(regex, string)  
+用 string 匹配 regex,匹配总是从字符串的开始匹配
 
-- ure.DEBUG  
-  标志值,显示表达式的调试信息
+### **ure.search**(regex, string)  
+在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)
 
-**正则表达式对象**:
+### **ure.DEBUG**  
+标志值,显示表达式的调试信息。
 
+## **正则表达式对象**:
 编译正则表达式,使用 `ure.compile()` 创建实例。
 
-- regex.match(string)  
-- regex.search(string)  
-- regex.split(string, max_split=-1)  
-
-**匹配对象** :
+### **regex.match**(string)  
+### **regex.search**(string)  
+### **regex.split**(string, max_split=-1)  
 
+## **匹配对象** :
 匹配对象是 match() 和 search() 方法的返回值。
 
-- match.group([index])  
-  只支持数字组。
+### **match.group**([index])  
+只支持数字组。
+
+更多内容可参考 [re](https://docs.python.org/3/library/re.html?highlight=re#module-re)  。
 
 ----------

+ 6 - 5
docs/06-Tools_Module/07-uzlib.md

@@ -1,13 +1,14 @@
 # **uzlib** – zlib 解压缩
 
-`uzlib` 模块实现了使用 DEFLATE 算法解压缩二进制数据 (常用的 zlib 库和 gzip 文档)。目前不支持压缩。
+!!! abstract "简介"
+    `uzlib` 模块实现了使用 DEFLATE 算法解压缩二进制数据 (常用的 zlib 库和 gzip 文档)。目前不支持压缩。
 
-更多内容可参考 [zlib](https://docs.python.org/3/library/zlib.html?highlight=zlib#module-zlib) 。
+## 函数
 
-`函数`
+### **uzlib.decompress**(data)  
+返回解压后的 bytes 数据。
 
-- uzlib.decompress(data)  
-  返回解压后的 bytes 数据。
+更多内容可参考 [zlib](https://docs.python.org/3/library/zlib.html?highlight=zlib#module-zlib) 。
 
 ----------
 

+ 20 - 21
docs/06-Tools_Module/08-urandom.md

@@ -1,33 +1,32 @@
 # **urandom** - 随机数生成模块
-`urandom` 模块实现了伪随机数生成器。
+!!! abstract "简介"
+    `urandom` 模块实现了伪随机数生成器。
 
-更多内容可参考 [random](https://docs.python.org/3/library/random.html?highlight=random#module-random) 。
-
-`函数` 
+## 函数 
 
-- urandom.choice()  
-  Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError.
+### **urandom.choice**()  
+Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError.
 
-- urandom.getrandbits()  
-  Returns a Python integer with k random bits. This method is supplied with the MersenneTwister generator and some other generators may also provide it as an optional part of the API. When available, getrandbits() enables randrange() to handle arbitrarily large ranges.
+### **urandom.getrandbits**()  
+Returns a Python integer with k random bits. This method is supplied with the MersenneTwister generator and some other generators may also provide it as an optional part of the API. When available, getrandbits() enables randrange() to handle arbitrarily large ranges.
 
-- urandom.randint()  
-  Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
+### **urandom.randint**()  
+Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
 
-- urandom.random()  
-  Return the next random floating point number in the range [0.0, 1.0).
+### **urandom.random**()  
+Return the next random floating point number in the range [0.0, 1.0).
 
-- urandom.randrange()  
-  Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object.
+### **urandom.randrange**()  
+Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object.
 
+### **urandom.seed**()  
+Initialize the random number generator.
+If a is omitted or None, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).
 
-- urandom.seed()  
-  Initialize the random number generator.
-  If a is omitted or None, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).
-
-- urandom.uniform()  
-  Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.
-  The end-point value b may or may not be included in the range depending on floating-point rounding in the equation a + (b-a) * random().
+### **urandom.uniform**()  
+Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.
+The end-point value b may or may not be included in the range depending on floating-point rounding in the equation a + (b-a) * random().
 
+更多内容可参考 [random](https://docs.python.org/3/library/random.html?highlight=random#module-random) 。
 
 ----------

+ 66 - 62
docs/07-Network_Module/01-usocket.md

@@ -1,97 +1,98 @@
 # **usocket** – 套接字模块
-`usocket` 模块提供对BSD套接字接口的访问。
+!!! abstract "简介"
+    `usocket` 模块提供对BSD套接字接口的访问。 
 
-更多的内容可参考 [socket](https://docs.python.org/3/library/socket.html) 。
-
-`常数`
+## 常数
 
-- socket.AF_INET  
-- socket.AF_INET6  
+### **socket.AF_INET**  
+### **socket.AF_INET6**  
 
 `TCP类型定义`
 
-- socket.SOCK_STREAM  
-- socket.SOCK_DGRAM  
+### **socket.SOCK_STREAM**  
+### **socket.SOCK_DGRAM**  
 
 `Socket类型`
 
-- socket.IPPROTO_UDP  
-- socket.IPPROTO_TCP  
+### **socket.IPPROTO_UDP**  
+### **socket.IPPROTO_TCP**  
 
 `IP协议号`
 
-- socket.SOL_*  
-  Socket option levels (an argument to setsockopt()). The exact inventory depends on a board.
+### **socket.SOL_***  
+Socket option levels (an argument to setsockopt()). The exact inventory depends on a board.
 
-- socket.SO_*  
-  Socket options (an argument to setsockopt()). The exact inventory depends on a board.
+### **socket.SO_***  
+Socket options (an argument to setsockopt()). The exact inventory depends on a board.
 
-- socket.IPPROTO_SEC  
-  Special protocol value to create SSL-compatible socket.
+### **socket.IPPROTO_SEC**  
+Special protocol value to create SSL-compatible socket.
 
-`函数`
+## 函数
 
-- socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)  
-  创建新的套接字,使用指定的地址、类型和协议号。
+### **socket.socket**(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)  
+创建新的套接字,使用指定的地址、类型和协议号。
 
-- socket.getaddrinfo(host, port)  
-  传递 主机/端口 到一个5个数据的元组。元组列表的结构如下:
-  (family, type, proto, canonname, sockaddr)
+### **socket.getaddrinfo**(host, port)  
+传递 主机/端口 到一个5个数据的元组。元组列表的结构如下:
+(family, type, proto, canonname, sockaddr)
 
-- socket.close()  
-  关闭套接字。一旦关闭后,套接字所有的功能都将失效。远端将接收不到任何数据 (清理队列数据后)。 在回收垃圾时套接字会自动关闭,但还是推荐在必要时用 close() 去关闭,或, or to use a with statement around them。
+### **socket.close**()  
+关闭套接字。一旦关闭后,套接字所有的功能都将失效。远端将接收不到任何数据 (清理队列数据后)。 在回收垃圾时套接字会自动关闭,但还是推荐在必要时用 close() 去关闭,或, or to use a with statement around them。
 
-- socket.bind(address)  
-  将套接字绑定到地址,套接字不能是已经绑定的。
+### **socket.bind**(address)  
+将套接字绑定到地址,套接字不能是已经绑定的。
 
-- socket.listen([backlog])  
-  允许服务器接收连接。如果指定了 backlog,它不能小于0 (如果小于0将自动设置为0);超出后系统将拒绝新的连接。如果没有指定,将使用默认值。
+### **socket.listen**([backlog])  
+允许服务器接收连接。如果指定了 backlog,它不能小于0 (如果小于0将自动设置为0);超出后系统将拒绝新的连接。如果没有指定,将使用默认值。
 
-- socket.accept()  
-  接收连接。套接字需要指定地址并监听连接。返回值是 (conn, address),其中conn是用来接收和发送数据的套接字,address是绑定到另一端的套接字。
+### **socket.accept**()  
+接收连接。套接字需要指定地址并监听连接。返回值是 (conn, address),其中conn是用来接收和发送数据的套接字,address是绑定到另一端的套接字。
 
-- socket.connect(address)  
-  连接到指定地址的远端套接字。
+### **socket.connect**(address)  
+连接到指定地址的远端套接字。
 
-- socket.send(bytes)  
-  发送数据。套接字需要已连接到远程。
+### **socket.send**(bytes)  
+发送数据。套接字需要已连接到远程。
 
-- socket.sendall(bytes)  
-  发送数据。套接字已连接到远程。 Unlike send(), this method will try to send all of data, by sending data chunk by chunk consecutively.
+### **socket.sendall**(bytes)  
+发送数据。套接字已连接到远程。 Unlike send(), this method will try to send all of data, by sending data chunk by chunk consecutively.
 
-- socket.recv(bufsize)  
-  接收数据,返回值是数据字节对象。bufsize是接收数据的最大数量。
+### **socket.recv**(bufsize)  
+接收数据,返回值是数据字节对象。bufsize是接收数据的最大数量。
 
-- socket.sendto(bytes, address)  
-  发送数据。套接字没有连接到远程,目标套接字由地址参数指定。
+### **socket.sendto**(bytes, address)  
+发送数据。套接字没有连接到远程,目标套接字由地址参数指定。
 
-- socket.recvfrom(bufsize)  
-  接收数据。返回值是 (bytes, address),其中 bytes 是字节对象,address 是发送数据的套接字。
+### **socket.recvfrom**(bufsize)  
+接收数据。返回值是 (bytes, address),其中 bytes 是字节对象,address 是发送数据的套接字。
 
-- socket.setsockopt(level, optname, value)  
-  设置套接字参数。需要的符号常数定义在套接字模块 (SO_* 等)。value 可以是整数或字节对象。
+### **socket.setsockopt**(level, optname, value)  
+设置套接字参数。需要的符号常数定义在套接字模块 (SO_* 等)。value 可以是整数或字节对象。
 
-- socket.settimeout(value)  
-  设置阻塞套接字超时时间。value 参数可以是代表秒的正浮点数或 None。如果设定大于 0 的参数,在后面套接字操作超出指定时间后将引起 timeout 异常。如果参数是 0,套接字将使用非阻塞模式。如果是 None,套接字使用阻塞模式。
+### **socket.settimeout**(value)  
+设置阻塞套接字超时时间。value 参数可以是代表秒的正浮点数或 None。如果设定大于 0 的参数,在后面套接字操作超出指定时间后将引起 timeout 异常。如果参数是 0,套接字将使用非阻塞模式。如果是 None,套接字使用阻塞模式。
 
-- socket.setblocking(flag)  
-  设置阻塞或非阻塞模式: 如果 flag 是 false,设置非阻塞模式。
+### **socket.setblocking**(flag)  
+设置阻塞或非阻塞模式: 如果 flag 是 false,设置非阻塞模式。
 
-- socket.read([size])  
-  Read up to size bytes from the socket. Return a bytes object. If size is not given, it reads all data available from the socket until EOF; as such the method will not return until the socket is closed. This function tries to read as much data as requested (no “short reads”). This may be not possible with non-blocking socket though, and then less data will be returned.
+### **socket.read**([size])  
+Read up to size bytes from the socket. Return a bytes object. If size is not given, it reads all data available from the socket until EOF; as such the method will not return until the socket is closed. This function tries to read as much data as requested (no “short reads”). This may be not possible with non-blocking socket though, and then less data will be returned.
 
-- socket.readinto(buf[, nbytes])  
-  Read bytes into the buf. If nbytes is specified then read at most that many bytes. Otherwise, read at most len(buf) bytes. Just as read(), this method follows “no short reads” policy.
-  Return value: number of bytes read and stored into buf.
+### **socket.readinto**(buf[, nbytes])  
+Read bytes into the buf. If nbytes is specified then read at most that many bytes. Otherwise, read at most len(buf) bytes. Just as read(), this method follows “no short reads” policy.
+Return value: number of bytes read and stored into buf.
 
-- socket.readline()  
-  读取一行,以换行符结束,返回读取的数据行。
+### **socket.readline**()  
+读取一行,以换行符结束,返回读取的数据行。
 
-- socket.write(buf)  
-  Write the buffer of bytes to the socket. This function will try to write all data to a socket (no “short writes”). This may be not possible with a non-blocking socket though, and returned value will be less than the length of buf.
-  Return value: number of bytes written.
+### **socket.write**(buf)  
+Write the buffer of bytes to the socket. This function will try to write all data to a socket (no “short writes”). This may be not possible with a non-blocking socket though, and returned value will be less than the length of buf.
+Return value: number of bytes written.
 
-`TCP Server example`:
+## 示例
+
+### TCP Server example
 
 ```
 >>> import usocket 
@@ -103,10 +104,9 @@
 >>> sock.recv(10)                    
 b'rt-thread\r'
 >>> s.close()
->>> 
 ```
 
-`TCP Client example`:
+### TCP Client example
 
 ```
 >>> import usocket 
@@ -121,4 +121,8 @@ b'rt-thread\r'
 ```
 s = socket.socket()
 s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1])
-```
+```
+
+更多的内容可参考 [socket](https://docs.python.org/3/library/socket.html) 。
+
+----------

+ 9 - 1
docs/README.md

@@ -56,12 +56,20 @@
 
 # 2. MicroPython 开发资源
 
+- [RT-Thread MicroPython 开发手册](https://www.rt-thread.org/document/site/rtthread-development-guide/micropython/docs/README/)
+
 - [RT-Thread MicroPython 源码](https://github.com/RT-Thread-packages/micropython)
+
 - [RT-Thread MicroPython 论坛](https://www.rt-thread.org/qa/forum.php)
+
 - [MicroPython 官方网站](https://micropython.org/)
+
 - [官方在线文档](http://docs.micropython.org/en/latest/pyboard/)
+
 - [MicroPython 在线演示](https://micropython.org/unicorn)
+
 - [MicroPython 源码](https://github.com/micropython/micropython)
+
 - [MicroPython 官方论坛](http://forum.micropython.org/)
-- [MicroPython 中文社区](http://www.micropython.org.cn/)
 
+- [MicroPython 中文社区](http://www.micropython.org.cn/)