Skip to content

Commit 0aaa314

Browse files
committed
Proofread docs and set up RTD (#57)
* Published to RTD. * Proofread the previous commit. * Added sphinxcontrib-trio so that async APIs are documented correctly. * Added credits page.
1 parent 72af164 commit 0aaa314

File tree

10 files changed

+99
-89
lines changed

10 files changed

+99
-89
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
[![PyPI](https://img.shields.io/pypi/v/trio-websocket.svg?style=flat-square)](https://pypi.org/project/trio-websocket/)
2-
![Python Versions](https://img.shields.io/pypi/pyversions/trio-websocket.svg?style=flat-square)
3-
![MIT License](https://img.shields.io/github/license/HyperionGray/trio-websocket.svg?style=flat-square)
4-
[![Build Status](https://img.shields.io/travis/HyperionGray/trio-websocket.svg?style=flat-square)](https://travis-ci.org/HyperionGray/trio-websocket)
5-
[![Coverage](https://img.shields.io/coveralls/github/HyperionGray/trio-websocket.svg?style=flat-square)](https://coveralls.io/github/HyperionGray/trio-websocket?branch=master)
6-
![Read the Docs](https://img.shields.io/readthedocs/trio-websocket.svg)
7-
81
# Trio WebSocket
92

103
This library implements [the WebSocket
@@ -20,6 +13,13 @@ framework](https://trio.readthedocs.io/en/latest/). This library passes the
2013
This README contains a brief introduction to the project. Full documentation [is
2114
available here](https://trio-websocket.readthedocs.io).
2215

16+
[![PyPI](https://img.shields.io/pypi/v/trio-websocket.svg?style=flat-square)](https://pypi.org/project/trio-websocket/)
17+
![Python Versions](https://img.shields.io/pypi/pyversions/trio-websocket.svg?style=flat-square)
18+
![MIT License](https://img.shields.io/github/license/HyperionGray/trio-websocket.svg?style=flat-square)
19+
[![Build Status](https://img.shields.io/travis/HyperionGray/trio-websocket.svg?style=flat-square)](https://travis-ci.org/HyperionGray/trio-websocket)
20+
[![Coverage](https://img.shields.io/coveralls/github/HyperionGray/trio-websocket.svg?style=flat-square)](https://coveralls.io/github/HyperionGray/trio-websocket?branch=master)
21+
[![Read the Docs](https://img.shields.io/readthedocs/trio-websocket.svg)](https://trio-websocket.readthedocs.io)
22+
2323
## Installation
2424

2525
This library requires Python 3.5 or greater. To install from PyPI:

docs/api.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ Connections
3737
The preferred way to obtain a connection is to use one of the
3838
convenience functions described in :ref:`websocket-clients` or
3939
:ref:`websocket-servers`. Instantiating a connection instance directly is
40-
tricky and only advisable for esoteric use cases.
40+
tricky and is not recommended.
4141

42-
A connection has properties that expose the connection's role (client vs.
43-
server) and other connection metadata.
42+
This object has properties that expose connection metadata.
4443

4544
.. autoattribute:: is_closed
4645
.. autoattribute:: close_reason
@@ -68,7 +67,7 @@ Connections
6867
.. automethod:: pong
6968

7069
Finally, the socket offers a method to close the connection. The connection
71-
context managers in ref:`websocket-clients` and :ref:`websocket-servers`
70+
context managers in :ref:`websocket-clients` and :ref:`websocket-servers`
7271
will automatically close the connection for you, but you may want to close
7372
the connection explicity if you are not using a context manager or if you
7473
want to customize the close reason.
@@ -79,4 +78,3 @@ Connections
7978
:members:
8079

8180
.. autoexception:: ConnectionClosed
82-
:members:

docs/clients.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Clients
55

66
.. currentmodule:: trio_websocket
77

8-
Context Managers
9-
----------------
8+
Creating A Client
9+
-----------------
1010

1111
This page goes into the details of creating a WebSocket client. Let's start by
12-
revisiting the example from :ref:`client-tutorial`.
12+
revisiting the example from the :ref:`client-tutorial`.
1313

1414
.. code-block:: python
1515
:linenos:
@@ -38,10 +38,13 @@ As explained in the tutorial, ``open_websocket_url(…)`` is a context manager
3838
that ensures the connection is properly opened and ready before entering the
3939
block. It also ensures that the connection is closed before exiting the block.
4040
This library contains two such context managers for creating client connections:
41-
one to connect by host/port/path and one to connect by URL.
41+
one to connect by host and one to connect by URL.
4242

4343
.. autofunction:: open_websocket
44+
:async-with: ws
45+
4446
.. autofunction:: open_websocket_url
47+
:async-with: ws
4548

4649
Custom Nursery
4750
--------------

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
extensions = [
4141
'sphinx.ext.autodoc',
4242
'sphinx.ext.intersphinx',
43+
'sphinxcontrib_trio',
4344
]
4445

4546
# Add any paths that contain templates here, relative to this directory.

docs/credits.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Credits
2+
=======
3+
4+
Thanks to `John Belmonte (@belm0) <https://github.com/belm0>`__ and `Nathaniel
5+
J. Smith (@njsmith) <https://github.com/njsmith>`__ for lots of feedback,
6+
discussion, code reviews, and pull requests. Thanks to all the Trio contributors
7+
for making a fantastic framework! Thanks to Hyperion Gray for supporting
8+
development time on this project.
9+
10+
.. image:: https://hyperiongray.s3.amazonaws.com/define-hg.svg
11+
:target: https://www.hyperiongray.com/?pk_campaign=github&pk_kwd=agnostic
12+
:alt: define hyperiongray
13+
:width: 500px

docs/getting_started.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Change into the project directory and run the following command.
2020

2121
$ pip3 install .
2222

23-
If you want to contribute to development of the library, look at the
24-
documentation for :ref:`developer-installation`.
23+
If you want to contribute to development of the library, also see
24+
:ref:`developer-installation`.
2525

2626
.. _client-tutorial:
2727

@@ -52,7 +52,7 @@ The function :func:`open_websocket_url` is a context manager that automatically
5252
connects and performs the WebSocket handshake before entering the block. This
5353
ensures that the connection is usable before ``ws.send_message(…)`` is called.
5454
The context manager yields a :class:`WebSocketConnection` instance that is used
55-
to send and receive message. The context manager also closes the connection
55+
to send and receive messages. The context manager also closes the connection
5656
before exiting the block.
5757

5858
For more details and examples, see :ref:`websocket-clients`.
@@ -63,8 +63,8 @@ Server Tutorial
6363
---------------
6464

6565
This example briefly demonstrates how to create a WebSocket server. This server
66-
is an *echo server*, i.e. it reads a message and then sends back the same
67-
message.
66+
is an *echo server*, i.e. it responds to each incoming message by sending back
67+
an identical message.
6868

6969
.. code-block:: python
7070
:linenos:

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ Autobahn Test Suite <https://github.com/crossbario/autobahn-testsuite>`__.
3535
api
3636
recipes
3737
contributing
38+
credits

docs/servers.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Creating A Server
99
-----------------
1010

1111
This page goes into the details of creating a WebSocket server. Let's start by
12-
revisiting the example from :ref:`server-tutorial`.
12+
revisiting the example from the :ref:`server-tutorial`.
1313

1414
.. code-block:: python
1515
:linenos:
@@ -37,15 +37,15 @@ revisiting the example from :ref:`server-tutorial`.
3737
<https://github.com/HyperionGray/trio-websocket/blob/master/examples/server.py>`__.
3838

3939
As explained in the tutorial, a WebSocket server needs a handler function and a
40-
host and port to bind to. The handler function receives a
41-
:class:`WebSocketRequest` object, and it calls ``accept()`` to finish the
42-
handshake and obtain a
40+
host/port to bind to. The handler function receives a
41+
:class:`WebSocketRequest` object, and it calls the request's
42+
:func:`~WebSocketRequest.accept` method to finish the handshake and obtain a
4343
:class:`WebSocketConnection` object.
4444

4545
.. autofunction:: serve_websocket
4646

47-
Serving Arbitrary Stream
48-
------------------------
47+
Custom Stream
48+
-------------
4949

5050
The WebSocket protocol is defined as an application layer protocol that runs on
5151
top of TCP, and the convenience functions described above automatically create

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
'pytest-trio>=0.5.0',
5353
'sphinx',
5454
'sphinx_rtd_theme',
55+
'sphinxcontrib-trio',
5556
'trustme',
5657
],
5758
},

0 commit comments

Comments
 (0)