Skip to content

Commit

Permalink
chore(docs): update all lib docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Water-Melon committed Dec 4, 2023
1 parent 2130e17 commit c2a3414
Show file tree
Hide file tree
Showing 16 changed files with 244 additions and 242 deletions.
10 changes: 5 additions & 5 deletions docs/lib/aes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ aes.aes(data, key, bits, op);

Input:

- data -- a string value and its length can be divided by 16.
- key -- a string value for *data* encryption and decryption.
- bits -- an integer value of the *key* bit length. *Key*'s' bit-length must be equal to or greater than *bits*. It supports these value: *128*, *192*, *256*.
- `data` -- a string value and its length can be divided by `16`.
- `key` -- a string value for `data` encryption and decryption.
- `bits` -- an integer value of the `key` bit length. `key`'s bit length must be equal to or greater than `bits`. It supports these value: `128`, `192`, `256`.

- op -- a string value to indicate function to encrypt or decrypt. It only has two values: *encode* and *decode*.
- `op` -- a string value to indicate function to encrypt or decrypt. It only has two values: `encode` and `decode`.

Return value:

- The encrypted cipher string.
- The encrypted cipher string or decrypted text string.

Error:

Expand Down
4 changes: 2 additions & 2 deletions docs/lib/base64.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ b.base64(data, op);

Input:

- data - string type value.
- op - a string value to indicate function to encode or decode. It only has two values: *encode* and *decode*.
- `data` - string type value.
- `op` - a string value to indicate function to encode or decode. It only has two values: `encode` and `decode`.

Return value:

Expand Down
12 changes: 6 additions & 6 deletions docs/lib/des.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ d.des(data, key, op);

Input:

- data - string value and its length % 8 must be 0.
- key - must be an integer value.
- op - a string value to indicate function to encrypt or decrypt. It only has two values: *encode* and *decode*.
- `data` - string value and its length % 8 must be 0.
- `key` - must be an integer value.
- `op` - a string value to indicate function to encrypt or decrypt. It only has two values: `encode` and `decode`.

Return value:

Expand Down Expand Up @@ -61,9 +61,9 @@ des3(data, key1, key2, op);

Input:

- data - string value and its length % 8 must be 0.
- key1, key2 - must be an integer value.
- op - a string value to indicate function to encrypt or decrypt. It only has two values: *encode* and *decode*.
- `data` - string value and its length % 8 must be 0.
- `key1`, `key2` - must be an integer value.
- `op` - a string value to indicate function to encrypt or decrypt. It only has two values: `encode` and `decode`.

Return value:

Expand Down
54 changes: 27 additions & 27 deletions docs/lib/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ File {

##### fd

fd is the file descriptor that is like an integer in C. But in Melang, this property is read-only. It will be set by method *open*. Usually, we don't have to access it.
fd is the file descriptor that is like an integer in C. But in Melang, this property is read-only. It will be set by method `open`. Usually, we don't have to access it.



Expand All @@ -46,72 +46,72 @@ Open a file in the specified mode.

Input:

- path - this is a file path string.
- `path` - this is a file path string.

- op - a string that indicates the operation including *read*, *write* and *append*. Its value is composed of three parts:
- `op` - a string that indicates the operation including *read*, *write* and *append*. Its value is composed of three parts:

- r - read
- w - write
- a - append
- \+ - not truncate
- `r` - read
- `w` - write
- `a` - append
- `+` - not truncate

e.g.

- rw - read and write
- ra - read from the end of file
- aw - append to write
- `rw` - read and write
- `ra` - read from the end of file
- `aw` - append to write

- prio - an integer indicates the file access authority, e.g. 0777. This argument only used on opening a nonexistent file. It is optional. If not given, 0644 will be set by default.
- `prio` - an integer indicates the file access authority, e.g. `0777`. This argument only used on opening a nonexistent file. It is optional. If not given, `0644` will be set by default.

Return value:

- *true* will be returned on success, otherwise *false* returned and *errno* will be set.
- `true` will be returned on success, otherwise `false` returned and `errno` will be set.



##### lseek

Repositions the offset of the file descriptor to the argument *offset*, according to the directive *whence*.
Repositions the offset of the file descriptor to the argument `offset`, according to the directive `whence`.

Input:

- offset - an integer offset.
- whence - a string value including three values:
- begin - from the beginning of the file.
- current - from current position.
- end - from the end of the file.
- `offset` - an integer offset.
- `whence` - a string value including three values:
- `begin` - from the beginning of the file.
- `current` - from current position.
- `end` - from the end of the file.

Return value:

- *true* will be returned on success, otherwise *false* returned and *errno* will be set.
- `true` will be returned on success, otherwise `false` returned and `errno` will be set.



##### read

Read *nbytes* from current position of the openned file.
Read `nbytes` from current position of the openned file.

Input:

- nbytes - an integer indicates how many bytes read in this time.
- `nbytes` - an integer indicates how many bytes read in this time.

Return value:

- *nbytes* data in file will be returned on success, otherwise *false* returned and errno will be set.
- `nbytes` data in file will be returned on success, otherwise `false` returned and `errno` will be set.



##### write

Write *data* in the file.
Write `data` in the file.

Input:

- data - must be a string.
- `data` - must be a string.

Return value:

- the number of bytes written in file will be returned on success, otherwise *false* returned and errno will be set.
- the number of bytes written in file will be returned on success, otherwise `false` returned and `errno` will be set.



Expand All @@ -123,7 +123,7 @@ Input: None

Return value:

- Always be *nil*.
- Always be `nil`.



Expand All @@ -147,7 +147,7 @@ Input: None

Return value:

- an integer file bytes will be returned on success, otherwise *false* returned.
- an integer file bytes will be returned on success, otherwise `false` returned.



Expand Down
6 changes: 3 additions & 3 deletions docs/lib/http.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### HTTP

This HTTP library does not support chunk mode.
This HTTP library does **not** support chunk mode.



Expand All @@ -20,7 +20,7 @@ http.parse(data);

Input:

- data - a raw HTTP string.
- `data` - a raw HTTP string.

Return value:

Expand Down Expand Up @@ -72,7 +72,7 @@ http.create(data);

Input:

- data - an array (dict) which is used to be constructed an HTTP string.
- `data` - an array (dict) which is used to be constructed an HTTP string.

Format (example):

Expand Down
10 changes: 5 additions & 5 deletions docs/lib/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ j.encode(array);

Input:

- array - must be an array (common array or dict).
- `array` - must be an array (regular array or dict).

Return value:

- a encoded JSON string on success, otherwise *false* returned.
- a encoded JSON string on success, otherwise `false` returned.

Error:

- An error will be occurred if encounter Invalid argument.
- An error will be occurred if encounter invalid argument.



Expand All @@ -38,11 +38,11 @@ j.decode(s);

Input:

- s - must be a string.
- `s` - must be a string.

Return value:

- a decoded JSON array on success, otherwise *false* returned.
- a decoded JSON array on success, otherwise `false` returned.

Error:

Expand Down
4 changes: 2 additions & 2 deletions docs/lib/matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ m.mul(array1, array2);

Input:

- *array1* and *array2* are dicts those format must be:
- `array1` and `array2` are dicts those format must be:

```
['row': rownum, 'col': colnum, 'data':[...]]
Expand Down Expand Up @@ -84,7 +84,7 @@ m.inv(array);

Input:

- *array* - is a dict whose format follows the rules given in *mln_matrix_mul*.
- `array` - is a dict whose format follows the rules as given in `mln_matrix_mul`.

Return value:

Expand Down
4 changes: 2 additions & 2 deletions docs/lib/md5.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ m.md5(data);

Input:

- data - a string or an opened File object.
- `data` - a string or an **opened** `File` object.

Return value:

- The digest of string or file content one success. If read file failed, *false* will be returned.
- The digest of string or file content one success. If read file failed, `false` will be returned.

Error:

Expand Down
26 changes: 14 additions & 12 deletions docs/lib/msgqueue.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
### Message Queue

This document introduces a set of functions about message queue.
Message queue is only working in a coroutine group in the same thread.
Message queue is only working on a coroutine group in the same thread.

There are two kinds of message: queue message and topic message.

Melang supports many coroutines to listen the same queue. If message is a queue message, only one coroutine can get this message. If is topic message, every subscribed coroutine can receive this message.
Melang supports many coroutines to listen the same queue. If a message is a queue message, only one coroutine can obtain this message. If it is a topic message, every subscribed coroutine can obtain this message.



Expand All @@ -27,11 +27,11 @@ mq.subscribe(qname);

Input:

- qname - a string queue name.
- `qname` - a queue name string.

Return value:

- Always return *nil*.
- Always return `nil`.

Error:

Expand All @@ -49,11 +49,11 @@ mq.unsubscribe(qname);

Input:

- qname - a string queue name.
- `qname` - a queue name string.

Return value:

- Always *nil*.
- Always `nil`.

Error:

Expand All @@ -71,13 +71,13 @@ mq.send(qname, msg, asTopic);

Input:

- qname - a string queue name.
- msg - the message that we want to send. The type of this argument must be *integer, boolean, real or string*.
- asTopic - if want to send queue message, this argument must be *false*, otherwise *true*. This is an optional argument. Omitted means *false*.
- `qname` - a queue name string.
- `msg` - the message that we want to send. The type of this argument must be *integer, boolean, real or string*.
- `asTopic` - if want to send a queue message, this argument must be `false`, otherwise `true`. This is an optional argument. Omitted means `false`.

Return value:

- Always *nil*.
- Always `nil`.

Error:

Expand All @@ -93,12 +93,14 @@ mq.recv(qname, timeout);

Input:

- qname - a string queue name.
- timeout - a positive integer or *nil*. If is positive integer, program will wait for *timeout* microseconds. If omitted or *nil*, prigram will wait until got a message.
- `qname` - a queue name string.
- `timeout` - a positive integer or `nil`. If it is a positive integer, program will wait for `timeout` microseconds. If it is zero, function returned immediately with `nil` as the return value. If it is omitted or a `nil`, prigram will wait until got a message.

Return value:

- A message.
- `nil` on timeout
- `false` on failure

Error:

Expand Down
Loading

0 comments on commit c2a3414

Please sign in to comment.