Skip to content

Commit 550e5a3

Browse files
committed
Get the docs to build
TODO: figure out why this is necessary
1 parent 3bfed40 commit 550e5a3

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

docs/source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@
3434
("py:func", "trio_asyncio.run_future"),
3535
("py:func", "trio_asyncio.run_coroutine"),
3636
("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"),
3740
("py:func", "sniffio.current_async_library"),
3841
("py:class", "trio_asyncio.TrioEventLoop"),
3942
("py:class", "trio_asyncio.TrioExecutor"),
4043
("py:class", "trio_asyncio.TrioChildWatcher"),
4144
("py:meth", "trio_asyncio.TrioEventLoop.autoclose"),
4245
("py:meth", "trio_asyncio.TrioEventLoop.add_reader"),
4346
("py:meth", "trio_asyncio.TrioEventLoop.add_writer"),
47+
("py:meth", "trio_asyncio.TrioEventLoop.run_trio_task"),
4448
("py:meth", "trio_asyncio.sync.SyncTrioEventLoop.run_until_complete"),
4549
("py:mod", "trio_asyncio"), ## ???
4650
]

docs/source/usage.rst

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ Here, calling ``proc`` multiple times from within ``run`` is not a problem.
251251
Calling asyncio from Trio
252252
+++++++++++++++++++++++++
253253

254-
Wrap the callable, awaitable, generator, or iterator in :func:`aio_as_trio`.
254+
Wrap the callable, awaitable, generator, or iterator in
255+
:func:`trio_asyncio.aio_as_trio`.
255256

256257
Thus, you can call an :mod:`asyncio` function from :mod:`trio` thus::
257258

@@ -306,9 +307,10 @@ You can wrap context handlers::
306307
await aio_as_trio(ctx.delay)(2)
307308
trio_asyncio.run(trio_ctx)
308309

309-
As you can see, while :func:`aio_as_trio` trio-izes the actual context,
310-
it doesn't know about the context's methods. You still need to treat them
311-
as :mod:`asyncio` methods and wrap them appropriately when you call them.
310+
As you can see, while :func:`trio_asyncio.aio_as_trio` trio-izes the actual
311+
context, it doesn't know about the context's methods. You still need to
312+
treat them as :mod:`asyncio` methods and wrap them appropriately when you
313+
call them.
312314

313315
Note that *creating* the async context handler is not itself an
314316
asynchronous process, i.e. ``AsyncCtx.__init__`` is a normal
@@ -353,10 +355,10 @@ to wrap the iterator, not the code creating it – the following code
353355
Too complicated?
354356
----------------
355357

356-
There's also a somewhat-magic wrapper (:func:`allow_asyncio`) which,
357-
as the name implies, allows you to directly call :mod:`asyncio` functions.
358-
It also works for awaiting futures and for using generators or context
359-
managers::
358+
There's also a somewhat-magic wrapper (:func:`trio_asyncio.allow_asyncio`)
359+
which, as the name implies, allows you to directly call :mod:`asyncio`
360+
functions. It also works for awaiting futures and for using generators or
361+
context managers::
360362

361363
async def hybrid():
362364
await trio.sleep(1)
@@ -366,10 +368,10 @@ managers::
366368

367369
This method works for one-off code. However, there are a couple of
368370
semantic differences between :mod:`asyncio` and :mod:`trio` which
369-
:func:`allow_asyncio` is unable to account for.
371+
:func:`trio_asyncio.allow_asyncio` is unable to account for.
370372

371-
Worse, :func:`allow_asyncio` can be used to auto-adapt asyncio code to Trio
372-
callers, but not vice versa.
373+
Worse, :func:`trio_asyncio.allow_asyncio` can be used to auto-adapt asyncio
374+
code to Trio callers, but not vice versa.
373375

374376
Thus, you really should not use it for "real" programs or libraries.
375377

@@ -378,7 +380,8 @@ Thus, you really should not use it for "real" programs or libraries.
378380
Calling Trio from asyncio
379381
+++++++++++++++++++++++++
380382

381-
Wrap the callable, awaitable, generator, or iterator in :func:`trio_as_aio`.
383+
Wrap the callable, awaitable, generator, or iterator in
384+
:func:`trio_asyncio.trio_as_aio`.
382385

383386
Thus, you can call a :mod:`trio` function from :mod:`asyncio` thus::
384387

@@ -397,13 +400,13 @@ or pre-wrapped::
397400
await trio_sleep(sec)
398401
trio_asyncio.run(aio_as_trio, aio_sleep, 3)
399402

400-
In contrast to :func:`aio_as_trio`, using an awaitable is not supported
401-
because that's not an idiom :mod:`trio` uses.
403+
In contrast to :func:`trio_asyncio.aio_as_trio`, using an awaitable is not
404+
supported because that's not an idiom :mod:`trio` uses.
402405

403-
Calling a function wrapped with :func:`trio_as_aio` returns a regular
404-
:class:`asyncio.Future`. Thus, you can call it from a synchronous context
405-
(e.g. a callback hook). Of course, you're responsible for catching any
406-
errors – either arrange to ``await`` the future, or use
406+
Calling a function wrapped with :func:`trio_asyncio.trio_as_aio` returns a
407+
regular :class:`asyncio.Future`. Thus, you can call it from a synchronous
408+
context (e.g. a callback hook). Of course, you're responsible for catching
409+
any errors – either arrange to ``await`` the future, or use
407410
``.add_done_callback()`` ::
408411

409412
async def trio_sleep(sec=1):
@@ -456,7 +459,7 @@ Trio background tasks
456459
If you want to start a Trio task that shall be monitored by ``trio_asyncio``
457460
(i.e. an uncaught error will propagate to, and terminate, the asyncio event
458461
loop) instead of a :class:`asyncio.Future`, use
459-
:meth:`TrioEventLoop.run_trio_task`.
462+
:meth:`trio_asyncio.TrioEventLoop.run_trio_task`.
460463

461464
.. autodoc: trio_asyncio.TrioEventLoop.run_trio_task
462465

0 commit comments

Comments
 (0)