Skip to content

Commit

Permalink
Bump to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Aug 19, 2020
1 parent 3a7c171 commit 82de677
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
17 changes: 15 additions & 2 deletions docs/index.rst
Expand Up @@ -15,11 +15,15 @@ Add :ref:`coroutine<coroutine>` markup support to sphinx-based docs.
Installation
------------

1. Install from PyPI::
1. Install from PyPI:

.. code-block:: shell
$ pip install sphinxcontrib-asyncio
2. Enable ``sphinxcontrib-asyncio`` extension in your ``conf.py``::
2. Enable ``sphinxcontrib-asyncio`` extension in your ``conf.py``:

.. code-block:: python
extensions = ['sphinxcontrib.asyncio']
Expand All @@ -33,6 +37,7 @@ Use ``cofunction`` instead of ``function``::
Simple coroutine function.

.. cofunction:: coro(a, b)
:noindex:

Simple coroutine function.

Expand All @@ -45,6 +50,7 @@ and ``comethod`` instead of ``method``::
Coroutine method.

.. class:: A
:noindex:

.. comethod:: meth(self, param)

Expand Down Expand Up @@ -78,6 +84,7 @@ For more complex markup use *directive options*, e.g.

.. cofunction:: iter_vals(arg)
:async-for:
:noindex:

A function the returns asynchronous generator.

Expand All @@ -101,6 +108,7 @@ is both *coroutine* and *asynchronous context manager*) explicit
.. cofunction:: get(url)
:async-with:
:coroutine:
:noindex:

A function can be used in ``async with`` and ``await`` context.

Expand All @@ -115,6 +123,7 @@ is both *coroutine* and *asynchronous context manager*) explicit
This is classmethod

.. class:: A
:noindex:

.. comethod:: f(cls, arg)
:classmethod:
Expand Down Expand Up @@ -147,9 +156,11 @@ Using this simple configuration in your `.rst` file::
Will yield next documentation:

.. autocofunction:: coro
:noindex:

.. autoclass:: MyClass
:members:
:noindex:

You can set directive options by adding it to `autocofunction` and
`autocomethod` directives::
Expand All @@ -161,6 +172,7 @@ You can set directive options by adding it to `autocofunction` and
.. autocofunction:: coro
:async-for:
:coroutine:
:noindex:

You can also force `coroutine` prefix on not-coroutine method by overriding it
as `autocomethod` directive::
Expand All @@ -174,6 +186,7 @@ as `autocomethod` directive::
.. autoclass:: MyClass
:members:
:exclude-members: my_func
:noindex:

.. autocomethod:: my_func()

Expand Down
9 changes: 5 additions & 4 deletions setup.py
Expand Up @@ -13,7 +13,7 @@
raise RuntimeError('Unable to determine version.')


install_requires = ['sphinx']
install_requires = ['sphinx>=3.0']


def read(f):
Expand Down Expand Up @@ -45,11 +45,12 @@ def run(self):
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Documentation :: Sphinx',
'Topic :: Software Development :: Documentation'],
author='Andrew Svetlov',
Expand Down
12 changes: 6 additions & 6 deletions sphinxcontrib/asyncio.py
@@ -1,5 +1,5 @@
from docutils.parsers.rst import directives
from sphinx.domains.python import PyModulelevel, PyClassmember
from sphinx.domains.python import PyFunction, PyMethod
from sphinx.ext.autodoc import FunctionDocumenter, MethodDocumenter, \
bool_option
try:
Expand All @@ -9,7 +9,7 @@ def iscoroutinefunction(func):
"""Return True if func is a decorated coroutine function."""
return getattr(func, '_is_coroutine', False)

__version__ = '0.2.0'
__version__ = '0.3.0'


def merge_dicts(*dcts):
Expand Down Expand Up @@ -45,18 +45,18 @@ def get_signature_prefix(self, sig):
return ret


class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel):
class PyCoroutineFunction(PyCoroutineMixin, PyFunction):
option_spec = merge_dicts(PyCoroutineMixin.option_spec,
PyModulelevel.option_spec)
PyFunction.option_spec)

def run(self):
self.name = 'py:function'
return super(PyCoroutineFunction, self).run()


class PyCoroutineMethod(PyCoroutineMixin, PyClassmember):
class PyCoroutineMethod(PyCoroutineMixin, PyMethod):
option_spec = merge_dicts(PyCoroutineMixin.option_spec,
PyClassmember.option_spec,
PyMethod.option_spec,
{'staticmethod': directives.flag,
'classmethod': directives.flag})

Expand Down

0 comments on commit 82de677

Please sign in to comment.