diff --git a/README.rst b/README.rst index 005785e97..128958146 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,9 @@ worker in two different threads, ``runworker`` to run separate workers, and ``runwsserver`` to run a Twisted-based WebSocket server. You should place consumers in either your ``views.py`` or a ``consumers.py``. -Here's an example of WebSocket consumers for basic chat:: +Here's an example of WebSocket consumers for basic chat: + +.. code-block:: python import redis from channels import Channel @@ -56,9 +58,10 @@ Here's an example of WebSocket consumers for basic chat:: # you'd want expiring keys here in real life. Alternately, you can just push some code outside of a normal view into a worker -thread:: +thread: + +.. code-block:: python - from django.shortcuts import render from channels import Channel diff --git a/docs/concepts.rst b/docs/concepts.rst index 3171b01cb..aac803a62 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -60,7 +60,9 @@ How do we use channels? ----------------------- That's what a channel is, but how is Django using them? Well, inside Django -you can connect a function to consume a channel, like so:: +you can connect a function to consume a channel, like so: + +.. code-block:: python @Channel.consumer("channel-name") def my_consumer(something, **kwargs): @@ -99,7 +101,9 @@ message and can write out zero to many other channel messages. Now, let's make a channel for requests (called ``django.wsgi.request``), and a channel per client for responses (e.g. ``django.wsgi.respsonse.o4F2h2Fd``), with the response channel a property (``send_channel``) of the request message. -Suddenly, a view is merely another example of a consumer:: +Suddenly, a view is merely another example of a consumer: + +.. code-block:: python @Channel.consumer("django.wsgi.request") def my_consumer(send_channel, **request_data): diff --git a/docs/installation.rst b/docs/installation.rst index 06a7c5cc3..d074bd542 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,7 +6,9 @@ Channels is available on PyPI - to install it, just run:: pip install -U channels Once that's done, you should add ``channels`` to your -``INSTALLED_APPS`` setting:: +``INSTALLED_APPS`` setting: + +.. code-block:: python INSTALLED_APPS = ( 'django.contrib.auth',