Skip to content

Commit 8511fec

Browse files
claws1st1
authored andcommitted
Add documentation; integrate sphinx
1 parent 72487f6 commit 8511fec

File tree

12 files changed

+335
-3
lines changed

12 files changed

+335
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ __pycache__/
2626
/*.egg-info
2727
/dist
2828
/.cache
29+
docs/_build

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
.PHONY: compile clean all distclean test debug sdist clean-libuv release sdist-libuv
1+
.PHONY: compile clean all distclean test debug sdist clean-libuv
2+
.PHONY: release sdist-libuv docs
23

34

45
all: clean compile
56

67

78
clean:
8-
rm -fr dist/
9+
rm -fr dist/ doc/_build/
910
rm -fr uvloop/*.c uvloop/*.html uvloop/*.so build *.egg-info
1011
rm -fr uvloop/handles/*.html uvloop/includes/*.html
1112
find . -name '__pycache__' | xargs rm -rf
@@ -34,6 +35,10 @@ debug: clean
3435
python setup.py build_ext --inplace
3536

3637

38+
docs: compile
39+
cd docs && sphinx-build -b html . _build/html
40+
41+
3742
test:
3843
PYTHONASYNCIODEBUG=1 python -m unittest discover -s tests
3944
python -m unittest discover -s tests

docs/_build/.gitignore

Whitespace-only changes.

docs/_static/.gitignore

Whitespace-only changes.

docs/_templates/.gitignore

Whitespace-only changes.

docs/api/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
API
2+
===
3+
4+
If you are looking for information on a specific function, class or method,
5+
this part of the documentation is for you.
6+
7+
8+
uvloop
9+
------
10+
11+
.. autoclass:: uvloop.EventLoopPolicy
12+
:members:
13+
14+
.. autoclass:: uvloop.loop.Loop
15+
:members:
16+
:undoc-members:
17+

docs/conf.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import os
5+
6+
import alabaster
7+
8+
9+
sys.path.insert(0, os.path.abspath('..'))
10+
11+
12+
# -- General configuration ------------------------------------------------
13+
14+
extensions = [
15+
'sphinx.ext.autodoc',
16+
'alabaster',
17+
]
18+
templates_path = ['_templates']
19+
source_suffix = '.rst'
20+
master_doc = 'index'
21+
project = 'uvloop'
22+
copyright = '2016, Yury Selivanov'
23+
author = 'Yury Selivanov'
24+
version = '0.4.14'
25+
release = '0.4.14'
26+
language = None
27+
exclude_patterns = ['_build']
28+
pygments_style = 'sphinx'
29+
todo_include_todos = False
30+
31+
32+
# -- Options for HTML output ----------------------------------------------
33+
34+
html_theme = 'alabaster'
35+
html_theme_options = {
36+
'description': 'uvloop is an ultra fast implementation of the '
37+
'asyncio event loop on top of libuv.',
38+
'show_powered_by': False,
39+
}
40+
html_theme_path = [alabaster.get_path()]
41+
html_title = 'uvloop Documentation'
42+
html_short_title = 'uvloop'
43+
html_static_path = ['_static']
44+
html_sidebars = {
45+
'**': [
46+
'about.html',
47+
'navigation.html',
48+
'searchbox.html',
49+
]
50+
}
51+
html_show_sourcelink = False
52+
html_show_sphinx = False
53+
html_show_copyright = False
54+
htmlhelp_basename = 'uvloopdoc'
55+
56+
57+
# -- Options for LaTeX output ---------------------------------------------
58+
59+
latex_elements = {}
60+
61+
latex_documents = [
62+
(master_doc, 'uvloop.tex', 'uvloop Documentation',
63+
'Yury Selivanov', 'manual'),
64+
]
65+
66+
67+
# -- Options for manual page output ---------------------------------------
68+
69+
man_pages = [
70+
(master_doc, 'uvloop', 'uvloop Documentation',
71+
[author], 1)
72+
]
73+
74+
75+
# -- Options for Texinfo output -------------------------------------------
76+
77+
texinfo_documents = [
78+
(master_doc, 'uvloop', 'uvloop Documentation',
79+
author, 'uvloop', 'One line description of project.',
80+
'Miscellaneous'),
81+
]

docs/dev/index.rst

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Developers Guide
2+
================
3+
4+
The project is hosted on `GitHub <https://github.com/MagicStack/uvloop>`_.
5+
and uses `Travis <https://travis-ci.org/MagicStack/uvloop>`_ for
6+
Continuous Integration.
7+
8+
A goal for the `uvloop` project is to provide a drop in replacement for the
9+
`asyncio` event loop. Any deviation from the behavior of the reference
10+
`asyncio` event loop is considered a bug.
11+
12+
If you have found a bug or have an idea for an enhancement that would
13+
improve the library, use the `bug tracker <https://github.com/MagicStack/uvloop/issues>`_.
14+
15+
16+
Get the source
17+
--------------
18+
19+
.. code-block:: console
20+
21+
$ git clone --recursive [email protected]:MagicStack/uvloop.git
22+
23+
The ``--recursive`` argument is important. It will fetch the ``libuv`` source
24+
from the `libuv` Github repository.
25+
26+
27+
Build
28+
-----
29+
30+
To build `uvloop`, you'll need ``Cython`` and Python 3.5.
31+
32+
.. note::
33+
34+
The best way to work on `uvloop` is to create a virtual env, so that
35+
you'll have Cython and Python commands pointing to the correct
36+
tools.
37+
38+
.. code-block:: console
39+
40+
$ python3 -m venv myvenv
41+
$ cd myvenv
42+
$ source bin/activate
43+
$ cd ..
44+
45+
Install Cython if not already present.
46+
47+
.. code-block:: console
48+
49+
$ pip install Cython
50+
51+
52+
Build `uvloop` by running the ``make`` rule from the top level directory.
53+
54+
.. code-block:: console
55+
56+
$ cd uvloop
57+
$ make
58+
59+
60+
Test
61+
----
62+
63+
The easiest method to run all of the unit tests is to run the ``make test``
64+
rule from the top level directory. This runs the standard library
65+
``unittest`` tool which discovers all the unit tests and runs them.
66+
It actually runs them twice, once with the `PYTHONASYNCIODEBUG` enabled and
67+
once without.
68+
69+
.. code-block:: console
70+
71+
$ cd uvloop
72+
$ make test
73+
74+
75+
Individual Tests
76+
++++++++++++++++
77+
78+
Individual unit tests can be run using the standard library ``unittest``
79+
or ``pytest`` package.
80+
81+
The easiest approach to ensure that ``uvloop`` can be found by Python is to
82+
install the package using ``pip``:
83+
84+
.. code-block:: console
85+
86+
$ cd uvloop
87+
$ pip install -e .
88+
89+
You can then run the unit tests individually from the tests directory using
90+
``unittest``:
91+
92+
.. code-block:: console
93+
94+
$ cd uvloop/tests
95+
$ python -m unittest test_tcp
96+
97+
or using ``pytest``:
98+
99+
.. code-block:: console
100+
101+
$ cd uvloop/tests
102+
$ py.test -k test_signals_sigint_uvcode
103+
104+
105+
Documentation
106+
-------------
107+
108+
To rebuild the project documentation, developers should run the ``make docs``
109+
rule from the top level directory. It performs a number of steps to create
110+
a new set of `sphinx <http://sphinx-doc.org/>`_ html content.
111+
112+
This step requires Sphinx to be installed. Sphinx can be installed using
113+
pip:
114+
115+
.. code-block:: console
116+
117+
$ pip install sphinx
118+
119+
Once Sphinx is available you can make the documentation using:
120+
121+
.. code-block:: console
122+
123+
$ make docs

docs/index.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
.. raw:: html
3+
4+
<div>
5+
<img src="https://img.shields.io/pypi/status/uvloop.svg?maxAge=2592000?style=plastic" />
6+
<img src="https://img.shields.io/travis/MagicStack/uvloop/master.svg" />
7+
<br />
8+
<br />
9+
</div>
10+
11+
uvloop
12+
======
13+
14+
`uvloop` is a fast, drop-in replacement of the built-in asyncio event loop.
15+
`uvloop` is released under the MIT license.
16+
17+
`uvloop` and asyncio, combined with the power of async/await in Python 3.5,
18+
makes it easier than ever to write high-performance networking code in Python.
19+
20+
`uvloop` makes asyncio fast. In fact, it is at least 2x faster than nodejs,
21+
gevent, as well as any other Python asynchronous framework. The performance of
22+
uvloop-based asyncio is close to that of Go programs.
23+
24+
You can read more about uvloop in this `blog post <http://magic.io/blog/uvloop-blazing-fast-python-networking/>`_.
25+
26+
Architecture
27+
------------
28+
29+
The asyncio module, introduced by PEP 3156, is a collection of network
30+
transports, protocols, and streams abstractions, with a pluggable event loop.
31+
The event loop is the heart of asyncio. It provides APIs for:
32+
33+
- scheduling calls,
34+
- transmitting data over the network,
35+
- performing DNS queries,
36+
- handling OS signals,
37+
- convenient abstractions to create servers and connections,
38+
- working with subprocesses asynchronously.
39+
40+
`uvloop` implements the :class:`asyncio.AbstractEventLoop` interface which
41+
means that it provides a drop-in replacement of the asyncio event loop.
42+
43+
`uvloop` is written in Cython and is built on top of libuv.
44+
45+
libuv is a high performance, multiplatform asynchronous I/O library used by
46+
nodejs. Because of how wide-spread and popular nodejs is, libuv is fast and
47+
stable.
48+
49+
`uvloop` implements all asyncio event loop APIs. High-level Python objects
50+
wrap low-level libuv structs and functions. Inheritance is used to keep the
51+
code DRY and ensure that any manual memory management is in sync with libuv
52+
primitives' lifespans.
53+
54+
55+
Contents
56+
--------
57+
58+
.. toctree::
59+
:maxdepth: 1
60+
61+
user/index
62+
dev/index
63+
api/index

docs/user/index.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
User Guide
2+
==========
3+
4+
This section of the documentation provides information about how to use
5+
uvloop.
6+
7+
8+
Installation
9+
------------
10+
11+
`uvloop` is available from PyPI. It requires Python 3.5.
12+
13+
Use pip to install it.
14+
15+
.. code-block:: console
16+
17+
$ pip install uvloop
18+
19+
20+
Using uvloop
21+
------------
22+
23+
To make asyncio use the event loop provided by `uvloop`, you install the
24+
`uvloop` event loop policy:
25+
26+
.. code-block:: python
27+
28+
import asyncio
29+
import uvloop
30+
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
31+
32+
33+
Alternatively, you can create an instance of the loop manually, using:
34+
35+
.. code-block:: python
36+
37+
import asyncio
38+
import uvloop
39+
loop = uvloop.new_event_loop()
40+
asyncio.set_event_loop(loop)

0 commit comments

Comments
 (0)