Skip to content

Commit 0098024

Browse files
committed
Merge branch 'docs'
2 parents 796b5e9 + fe98426 commit 0098024

14 files changed

+557
-18
lines changed

channel.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
__all__ = ('Channel', 'SerialChannel', 'Writer', 'ChannelWriter', 'CallbackChannelWriter',
1818
'Reader', 'ChannelReader', 'CallbackChannelReader', 'mkchannel', 'ReadOnly',
19-
'IteratorReader')
19+
'IteratorReader', 'CallbackReaderMixin', 'CallbackWriterMixin')
2020

2121
#{ Classes
2222
class Channel(object):
@@ -114,10 +114,12 @@ def __init__(self, *args):
114114
self._pre_cb = None
115115

116116
def set_pre_cb(self, fun = lambda item: item):
117-
"""Install a callback to be called before the given item is written.
117+
"""
118+
Install a callback to be called before the given item is written.
118119
It returns a possibly altered item which will be written to the channel
119120
instead, making it useful for pre-write item conversions.
120121
Providing None uninstalls the current method.
122+
121123
:return: the previously installed function or None
122124
:note: Must be thread-safe if the channel is used in multiple threads"""
123125
prev = self._pre_cb
@@ -161,9 +163,11 @@ def next(self):
161163
#{ Interface
162164

163165
def read(self, count=0, block=True, timeout=None):
164-
"""read a list of items read from the device. The list, as a sequence
166+
"""
167+
read a list of items read from the device. The list, as a sequence
165168
of items, is similar to the string of characters returned when reading from
166169
file like objects.
170+
167171
:param count: given amount of items to read. If < 1, all items will be read
168172
:param block: if True, the call will block until an item is available
169173
:param timeout: if positive and block is True, it will block only for the
@@ -275,21 +279,24 @@ def __init__(self, *args):
275279
self._post_cb = None
276280

277281
def set_pre_cb(self, fun = lambda count: None):
278-
"""Install a callback to call with the item count to be read before any
282+
"""
283+
Install a callback to call with the item count to be read before any
279284
item is actually read from the channel.
280285
Exceptions will be propagated.
281286
If a function is not provided, the call is effectively uninstalled.
287+
282288
:return: the previously installed callback or None
283289
:note: The callback must be threadsafe if the channel is used by multiple threads."""
284290
prev = self._pre_cb
285291
self._pre_cb = fun
286292
return prev
287293

288294
def set_post_cb(self, fun = lambda items: items):
289-
"""Install a callback to call after items have been read, but before
290-
they are returned to the caller. The callback may adjust the items and/or
291-
the list
295+
"""
296+
Install a callback to call after items have been read, but before
297+
they are returned to the caller. The callback may adjust the items and/or the list.
292298
If no function is provided, the callback is uninstalled
299+
293300
:return: the previously installed function"""
294301
prev = self._post_cb
295302
self._post_cb = fun
@@ -361,7 +368,8 @@ def read(self, count=0, block=True, timeout=None):
361368

362369
#{ Constructors
363370
def mkchannel(ctype = Channel, wtype = ChannelWriter, rtype = ChannelReader):
364-
"""Create a channel, with a reader and a writer
371+
"""
372+
Create a channel, with a reader and a writer
365373
:return: tuple(reader, writer)
366374
:param ctype: Channel to instantiate
367375
:param wctype: The type of the write channel to instantiate

doc/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

doc/Makefile

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = build
9+
10+
# Internal variables.
11+
PAPEROPT_a4 = -D latex_paper_size=a4
12+
PAPEROPT_letter = -D latex_paper_size=letter
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
14+
15+
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
16+
17+
help:
18+
@echo "Please use \`make <target>' where <target> is one of"
19+
@echo " html to make standalone HTML files"
20+
@echo " dirhtml to make HTML files named index.html in directories"
21+
@echo " pickle to make pickle files"
22+
@echo " json to make JSON files"
23+
@echo " htmlhelp to make HTML files and a HTML help project"
24+
@echo " qthelp to make HTML files and a qthelp project"
25+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
26+
@echo " changes to make an overview of all changed/added/deprecated items"
27+
@echo " linkcheck to check all external links for integrity"
28+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
29+
30+
clean:
31+
-rm -rf $(BUILDDIR)/*
32+
33+
html:
34+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
35+
@echo
36+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
37+
38+
dirhtml:
39+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
40+
@echo
41+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
42+
43+
pickle:
44+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
45+
@echo
46+
@echo "Build finished; now you can process the pickle files."
47+
48+
json:
49+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
50+
@echo
51+
@echo "Build finished; now you can process the JSON files."
52+
53+
htmlhelp:
54+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
55+
@echo
56+
@echo "Build finished; now you can run HTML Help Workshop with the" \
57+
".hhp project file in $(BUILDDIR)/htmlhelp."
58+
59+
qthelp:
60+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
61+
@echo
62+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
63+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
64+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/async.qhcp"
65+
@echo "To view the help file:"
66+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/async.qhc"
67+
68+
latex:
69+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
70+
@echo
71+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
72+
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
73+
"run these through (pdf)latex."
74+
75+
changes:
76+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
77+
@echo
78+
@echo "The overview file is in $(BUILDDIR)/changes."
79+
80+
linkcheck:
81+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
82+
@echo
83+
@echo "Link check complete; look for any errors in the above output " \
84+
"or in $(BUILDDIR)/linkcheck/output.txt."
85+
86+
doctest:
87+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
88+
@echo "Testing of doctests in the sources finished, look at the " \
89+
"results in $(BUILDDIR)/doctest/output.txt."

doc/source/api.rst

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.. _api-label:
2+
3+
#############
4+
API Reference
5+
#############
6+
7+
****************
8+
Channel
9+
****************
10+
11+
.. automodule:: async.channel
12+
:members:
13+
:undoc-members:
14+
15+
****************
16+
Graph
17+
****************
18+
19+
.. automodule:: async.graph
20+
:members:
21+
:undoc-members:
22+
23+
****************
24+
Pool
25+
****************
26+
27+
.. automodule:: async.pool
28+
:members:
29+
:undoc-members:
30+
31+
****************
32+
Task
33+
****************
34+
35+
.. automodule:: async.task
36+
:members:
37+
:undoc-members:
38+
39+
****************
40+
Thread
41+
****************
42+
43+
.. automodule:: async.thread
44+
:members:
45+
:undoc-members:
46+
47+
****************
48+
Util
49+
****************
50+
51+
.. automodule:: async.util
52+
:members:
53+
:undoc-members:

0 commit comments

Comments
 (0)