Created Daemon docstring formatting (markdown)
parent
a195205d5c
commit
a9da265d9d
1 changed files with 96 additions and 0 deletions
96
Daemon-docstring-formatting.md
Normal file
96
Daemon-docstring-formatting.md
Normal file
|
@ -0,0 +1,96 @@
|
|||
## Please make sure that all the docstrings for the jsonrpc commands should adhere to this format so that it can be properly parsed by the scripts which convert it to documentation
|
||||
|
||||
### Please note that the colons(:) are important.
|
||||
|
||||
### First line after the `"""` in the docstring is a short description of what the function does
|
||||
|
||||
### Subheading `Usage:`
|
||||
It should start with the word "Usage:", then in the next line list out the command name, then the arguments(as prescribed by [docopts library](http://docopt.org/)). It is of the following format
|
||||
|
||||
```
|
||||
Usage:
|
||||
command_name (<required_args>) [<optional_arg1> | --optional_arg1=<optional_arg1>]
|
||||
[<optional_arg2> | --optional_arg2=<optional_arg2>]
|
||||
```
|
||||
|
||||
### Subheading `Options:`
|
||||
It should start with the word "Options:", then in the next line
|
||||
1) If there are no arguments just write "None"
|
||||
2) Otherwise list out the command name followed by two dashes --, then ":", after that type of argument in parenthesis `(type)` and short description of the argument after a blank space. Please list out all of the arguments be it required, optional or Boolean as it is required by the api.
|
||||
It is of the following format
|
||||
|
||||
```
|
||||
Options:
|
||||
|
||||
--bool_arg : (bool) short description
|
||||
--required_arg=<required_arg> : (type) short description
|
||||
--optional_arg1=<optional_arg1> : (type) short description
|
||||
--optional_arg2=<optional_arg2> : (type) short description
|
||||
(Note: this ^ blank space is important)
|
||||
```
|
||||
|
||||
### Subheading `Returns:`
|
||||
It should start with the word "Returns:", then from the next line list out the response signature that the command return. It is of the following format
|
||||
|
||||
```
|
||||
Returns:
|
||||
Response signature, it may be a list, dict, Boolean etc.
|
||||
```
|
||||
|
||||
### If you think the scripts is missing some important functionality it can be changed [here](https://github.com/lbryio/lbry/blob/master/scripts/gen_docs.py) or you can open an issue in [lbryio/lbry](https://github.com/lbryio/lbry/issues/new) and tag @hackrush01 in the comments with the snippet which is not being correctly parsed by the scripts.
|
||||
|
||||
## A few examples
|
||||
|
||||
### Example 1
|
||||
```
|
||||
"""
|
||||
Get blob availability
|
||||
|
||||
Usage:
|
||||
blob_availability (<blob_hash>) [<search_timeout> | --search_timeout=<search_timeout>]
|
||||
[<blob_timeout> | --blob_timeout=<blob_timeout>]
|
||||
|
||||
Options:
|
||||
--blob_hash=<blob_hash> : (str) check availability for this blob hash
|
||||
--search_timeout=<search_timeout> : (int) how long to search for peers for the blob
|
||||
in the dht
|
||||
--blob_timeout=<blob_timeout> : (int) how long to try downloading from a peer
|
||||
|
||||
Returns:
|
||||
(dict) {
|
||||
"is_available": <bool, true if blob is available from a peer from peer list>
|
||||
"reachable_peers": ["<ip>:<port>"],
|
||||
"unreachable_peers": ["<ip>:<port>"]
|
||||
}
|
||||
"""
|
||||
```
|
||||
|
||||
### Example 2
|
||||
```
|
||||
"""
|
||||
Get DHT routing information
|
||||
|
||||
Usage:
|
||||
routing_table_get
|
||||
|
||||
Options:
|
||||
None
|
||||
|
||||
Returns:
|
||||
(dict) dictionary containing routing and contact information
|
||||
{
|
||||
"buckets": {
|
||||
<bucket index>: [
|
||||
{
|
||||
"address": (str) peer address,
|
||||
"node_id": (str) peer node id,
|
||||
"blobs": (list) blob hashes announced by peer
|
||||
}
|
||||
]
|
||||
},
|
||||
"contacts": (list) contact node ids,
|
||||
"blob_hashes": (list) all of the blob hashes stored by peers in the list of buckets,
|
||||
"node_id": (str) the local dht node id
|
||||
}
|
||||
"""
|
||||
```
|
Loading…
Reference in a new issue