Skip to content

Commit e7bb5e8

Browse files
committed
Fix installation doc and some notes
1 parent 2d3d076 commit e7bb5e8

File tree

4 files changed

+15
-45
lines changed

4 files changed

+15
-45
lines changed

docs/async.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ if response := dispatch(request):
3636
send(response)
3737
```
3838

39-
```{note}
40-
A synchronous protocol like HTTP requires a response no matter what, so we can
41-
send back the empty string. However with async protocols, we have the choice of
42-
responding or not.
43-
```
39+
> 📝 A synchronous protocol like HTTP requires a response no matter
40+
> what, so we can send back the empty string. However with async
41+
> protocols, we have the choice of responding or not.

docs/dispatch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ dispatch(request, serializer=ujson.dumps)
5959

6060
### validator
6161

62-
A function that validates the request once the json has been parsed. The
63-
function should raise an exception (any exception) if the request doesn't match
64-
the JSON-RPC spec. Default is `default_validator` which validates the request
65-
against a schema.
62+
A function that validates the request once the json has been parsed.
63+
The function should raise an exception (any exception) if the request
64+
doesn't match the JSON-RPC spec. Default is `default_validator` which
65+
validates the request against a schema.

docs/installation.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
1-
---
2-
hide:
3-
- title
4-
- toc
5-
---
6-
71
# Installation
82

9-
Create a `server.py`:
10-
11-
```python
12-
from jsonrpcserver import Success, method, serve
13-
14-
@method
15-
def ping():
16-
return Success("pong")
17-
18-
if __name__ == "__main__":
19-
serve()
20-
```
21-
22-
Start the server:
23-
24-
```sh
25-
$ pip install jsonrpcserver
26-
$ python server.py
27-
* Listening on port 5000
28-
```
29-
30-
Test the server:
3+
Install with Pip:
314

325
```sh
33-
$ curl -X POST http://localhost:5000 -d '{"jsonrpc": "2.0", "method": "ping", "id": 1}'
34-
{"jsonrpc": "2.0", "result": "pong", "id": 1}
6+
pip install jsonrpcserver
357
```

docs/methods.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def test() -> Result:
2525
return Error(1, "There was a problem")
2626
```
2727

28-
```{note}
29-
Alternatively, raise a `JsonRpcError`, which takes the same arguments as `Error`.
30-
```
28+
> 📝 Alternatively, raise a `JsonRpcError`, which takes the same
29+
> arguments as `Error`.
3130
3231
## Parameters
3332

@@ -48,9 +47,9 @@ $ curl -X POST http://localhost:5000 -d '{"jsonrpc": "2.0", "method": "hello", "
4847

4948
## Invalid params
5049

51-
A common error response is *invalid params*.
52-
The JSON-RPC error code for this is **-32602**. A shortcut, *InvalidParams*, is
53-
included so you don't need to remember that.
50+
A common error response is _invalid params_. The JSON-RPC error code
51+
for this is **-32602**. A shortcut, _InvalidParams_, is included so
52+
you don't need to remember that.
5453

5554
```python
5655
from jsonrpcserver import method, Result, InvalidParams, Success, dispatch
@@ -63,6 +62,7 @@ def within_range(num: int) -> Result:
6362
```
6463

6564
This is the same as saying
65+
6666
```python
6767
return Error(-32602, "Invalid params", "Value must be 1-5")
6868
```

0 commit comments

Comments
 (0)