Skip to content

Commit f4f5c9b

Browse files
committed
fix documentation
single- vs. double-colon annoyances
1 parent 550e5a3 commit f4f5c9b

5 files changed

Lines changed: 29 additions & 37 deletions

File tree

docs/source/conf.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@
3030
("py:class", "CapacityLimiter-like object"),
3131
("py:class", "bytes-like"),
3232
("py:class", "None"),
33-
("py:func", "trio_asyncio.wait_for_child"),
34-
("py:func", "trio_asyncio.run_future"),
35-
("py:func", "trio_asyncio.run_coroutine"),
36-
("py:func", "trio_asyncio.run_asyncio"),
37-
("py:func", "trio_asyncio.aio_as_trio"),
38-
("py:func", "trio_asyncio.trio_as_aio"),
39-
("py:func", "trio_asyncio.allow_asyncio"),
40-
("py:func", "sniffio.current_async_library"),
41-
("py:class", "trio_asyncio.TrioEventLoop"),
42-
("py:class", "trio_asyncio.TrioExecutor"),
43-
("py:class", "trio_asyncio.TrioChildWatcher"),
44-
("py:meth", "trio_asyncio.TrioEventLoop.autoclose"),
45-
("py:meth", "trio_asyncio.TrioEventLoop.add_reader"),
46-
("py:meth", "trio_asyncio.TrioEventLoop.add_writer"),
47-
("py:meth", "trio_asyncio.TrioEventLoop.run_trio_task"),
48-
("py:meth", "trio_asyncio.sync.SyncTrioEventLoop.run_until_complete"),
49-
("py:mod", "trio_asyncio"), ## ???
5033
]
5134

5235
autodoc_inherit_docstrings = False
@@ -71,7 +54,7 @@
7154
intersphinx_mapping = {
7255
"python": ('https://docs.python.org/3', None),
7356
"trio": ('https://trio.readthedocs.io/en/stable', None),
74-
# "sniffio": ('https://sniffio.readthedocs.io/en/stable', None),
57+
"sniffio": ('https://sniffio.readthedocs.io/en/latest', None),
7558
}
7659

7760
autodoc_member_order = "bysource"

docs/source/usage.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Usage
44
+++++++
55

6-
.. module: trio_asyncio
6+
.. module:: trio_asyncio
77

88
Using :mod:`trio` from :mod:`asyncio`, or vice versa, requires two steps:
99

@@ -74,6 +74,8 @@ the loop's context.
7474

7575
.. autofunction:: trio_asyncio.run
7676

77+
.. autoclass:: trio_asyncio.TrioEventLoop
78+
7779
.. note:
7880
7981
The ``async with open_loop()`` way of running ``trio_asyncio`` is
@@ -349,7 +351,7 @@ to wrap the iterator, not the code creating it – the following code
349351
async for n in aio_as_trio(aio_slow)():
350352
print(n)
351353

352-
.. autodoc: trio_asyncio.aio_as_trio
354+
.. autofunction:: trio_asyncio.aio_as_trio
353355

354356

355357
Too complicated?
@@ -375,7 +377,7 @@ code to Trio callers, but not vice versa.
375377

376378
Thus, you really should not use it for "real" programs or libraries.
377379

378-
.. autodoc: trio_asyncio.allow_asyncio
380+
.. autofunction:: trio_asyncio.allow_asyncio
379381

380382
Calling Trio from asyncio
381383
+++++++++++++++++++++++++
@@ -450,7 +452,7 @@ You can also wrap async generators or iterators::
450452
print(n)
451453
trio_asyncio.run(aio_as_trio, printer)
452454

453-
.. autodoc: trio_asyncio.trio_as_aio
455+
.. autofunction:: trio_as_aio
454456

455457

456458
Trio background tasks
@@ -461,7 +463,7 @@ If you want to start a Trio task that shall be monitored by ``trio_asyncio``
461463
loop) instead of a :class:`asyncio.Future`, use
462464
:meth:`trio_asyncio.TrioEventLoop.run_trio_task`.
463465

464-
.. autodoc: trio_asyncio.TrioEventLoop.run_trio_task
466+
.. automethod:: trio_asyncio.TrioEventLoop.run_trio_task
465467

466468
Multiple asyncio loops
467469
++++++++++++++++++++++
@@ -482,7 +484,13 @@ method is mainly useful for servers and should be used as supplementing,
482484
but not replacing, a ``finally:`` handler or an ``async with aclosing():``
483485
block.
484486

485-
.. autodoc: trio_asyncio.TrioEventLoop.autoclose
487+
.. automethod:: trio_asyncio.TrioEventLoop.autoclose
488+
489+
.. automethod:: trio_asyncio.TrioEventLoop.add_reader
490+
.. automethod:: trio_asyncio.TrioEventLoop.remove_reader
491+
492+
.. automethod:: trio_asyncio.TrioEventLoop.add_writer
493+
.. automethod:: trio_asyncio.TrioEventLoop.remove_writer
486494

487495
Errors and cancellations
488496
++++++++++++++++++++++++
@@ -526,6 +534,8 @@ There is one caveat: the executor must be either ``None`` or an instance of
526534
:class:`trio_asyncio.TrioExecutor`. The constructor of this class accepts one
527535
argument: the number of workers.
528536

537+
.. autoclass:: trio_asyncio.TrioExecutor
538+
529539
------------------
530540
File descriptors
531541
------------------

trio_asyncio/adapter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ def aio_as_trio(proc, *, loop=None):
105105
Encapsulate an asyncio-style coroutine, procedure, generator, or
106106
iterator, to be called seamlessly from Trio.
107107
108-
Note that while adapting coroutines, i.e.
108+
Note that while adapting coroutines, i.e.::
109+
109110
wrap(proc(*args))
111+
110112
is supported (because asyncio uses them a lot) they're not a good
111113
idea because setting up the coroutine won't run within an asyncio
112114
context. If at all possible, use::
@@ -276,7 +278,7 @@ async def main():
276278
277279
Unfortunately, there are issues with cancellation (specifically,
278280
:mod:`asyncio` function will see :class:`trio.Cancelled` instead of
279-
:class:`asyncio.CancelledError`). Thus, this mode is not the default.
281+
:exc:`concurrent.futures.CancelledError`). Thus, this mode is not the default.
280282
281283
This function must be called from :mod:`trio` context.
282284
"""

trio_asyncio/async_.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
class TrioEventLoop(BaseTrioEventLoop):
1212
"""A Trio-compatible asyncio event loop.
1313
14-
This loop runs in an async Trio context. If you really do need a
15-
stand-alone implementation, use :class:`SyncTrioEventLoop`.
14+
This loop runs in an async Trio context.
1615
"""
1716

1817
def _queue_handle(self, handle):

trio_asyncio/base.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,18 +549,16 @@ def add_reader(self, fd, callback, *args):
549549
ready for reading.
550550
551551
This creates a new Trio task. You may want to use "await
552-
:meth:`trio.hazmat.wait_readable`(fd) instead, or
552+
:obj:`trio.hazmat.wait_readable`\ (fd)" instead, or
553553
554554
:param fd: Either an integer (Unix file descriptor) or an object
555-
with a :meth:`fileno` methor providing one.
555+
with a ``fileno`` method providing one.
556556
:return: A handle. To remove the listener, either call
557-
``handle.cancel()`` or :meth:`remove_reader`(fd).
557+
``handle.cancel()`` or :meth:`.remove_reader`\ (fd).
558558
"""
559559
self._ensure_fd_no_transport(fd)
560560
return self._add_reader(fd, callback, *args)
561561

562-
# remove_reader: unchanged from asyncio
563-
564562
def _add_reader(self, fd, callback, *args):
565563
self._check_closed()
566564
handle = Handle(callback, args, self, context=None, is_sync=True)
@@ -604,12 +602,12 @@ def add_writer(self, fd, callback, *args):
604602
ready for writing.
605603
606604
This creates a new Trio task. You may want to use "await
607-
:meth:`trio.hazmat.wait_writable`(fd) instead, or
605+
:obj:`trio.hazmat.wait_writable`\ (fd) instead, or
608606
609607
:param fd: Either an integer (Unix file descriptor) or an object
610-
with a :meth:`fileno` methor providing one.
608+
with a ``fileno`` method providing one.
611609
:return: A handle. To remove the listener, either call
612-
``handle.cancel()`` or :meth:`remove_writer`(fd).
610+
``handle.cancel()`` or :meth:`remove_writer`\ (fd).
613611
"""
614612
self._ensure_fd_no_transport(fd)
615613
return self._add_writer(fd, callback, *args)
@@ -661,7 +659,7 @@ def autoclose(self, fd):
661659
Calling this method twice has no effect.
662660
663661
:param fd: Either an integer (Unix file descriptor) or an object
664-
with a :meth:`fileno` methor providing one.
662+
with a ``fileno`` method providing one.
665663
"""
666664
if hasattr(fd, 'fileno'):
667665
fd = fd.fileno()

0 commit comments

Comments
 (0)