diff options
author | Jason Madden <jamadden@gmail.com> | 2018-03-22 10:02:55 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2018-03-22 10:09:54 -0500 |
commit | c23444edde95141192d46b98276de1d0206d9a97 (patch) | |
tree | 8c3c9213a19889357f38bd1cb84c0cce025c132f | |
parent | e10358c000edbfd7036178dff77f1dcb03338c70 (diff) | |
download | zope-event-c23444edde95141192d46b98276de1d0206d9a97.tar.gz |
The sphinx docs for z.e.classhandler use `.. automodule`.
For two reasons:
1) DRY
2) Ability to cross-reference :mod:`zope.event.classhandler`.
-rw-r--r-- | docs/classhandler.rst | 39 | ||||
-rw-r--r-- | docs/conf.py | 11 | ||||
-rw-r--r-- | src/zope/event/classhandler.py | 5 |
3 files changed, 14 insertions, 41 deletions
diff --git a/docs/classhandler.rst b/docs/classhandler.rst index 94861b2..3135aa1 100644 --- a/docs/classhandler.rst +++ b/docs/classhandler.rst @@ -2,41 +2,4 @@ Class-based event handlers ============================ -A light-weight event-handler framework based on event classes is -provided by the ``zope.event.classhandler`` module. - -Handlers are registered for event classes: - - >>> import zope.event.classhandler - - >>> class MyEvent(object): - ... def __repr__(self): - ... return self.__class__.__name__ - - >>> def handler1(event): - ... print("handler1 %r" % event) - - >>> zope.event.classhandler.handler(MyEvent, handler1) - -Descriptor syntax: - - >>> @zope.event.classhandler.handler(MyEvent) - ... def handler2(event): - ... print("handler2 %r" % event) - - >>> class MySubEvent(MyEvent): - ... pass - - >>> @zope.event.classhandler.handler(MySubEvent) - ... def handler3(event): - ... print("handler3 %r" % event) - - -Subscribers are called in class method-resolution order, so only -new-style event classes are supported, and then by order of registry. - - >>> import zope.event - >>> zope.event.notify(MySubEvent()) - handler3 MySubEvent - handler1 MySubEvent - handler2 MySubEvent +.. automodule:: zope.event.classhandler diff --git a/docs/conf.py b/docs/conf.py index 0bddd42..552b723 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -29,6 +29,7 @@ extensions = [ 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', ] # Add any paths that contain templates here, relative to this directory. @@ -45,7 +46,7 @@ master_doc = 'index' # General information about the project. project = u'zope.event' -copyright = u'2010, Zope Foundation and Contributors' +copyright = u'2010-2018, Zope Foundation and Contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -202,4 +203,10 @@ latex_documents = [ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} +intersphinx_mapping = { + 'https://docs.python.org/': None +} + +autodoc_default_flags = ['members', 'show-inheritance'] +autodoc_member_order = 'bysource' +autoclass_content = 'both' diff --git a/src/zope/event/classhandler.py b/src/zope/event/classhandler.py index 0a1df59..c839901 100644 --- a/src/zope/event/classhandler.py +++ b/src/zope/event/classhandler.py @@ -45,7 +45,10 @@ import zope.event registry = {} def handler(event_class, handler_=None, decorator=False): - """Define an event handler for a (new-style) class. + """ + handler(event_class, [handler]) -> None + + Define an event handler for a (new-style) class. This can be called with a class and a handler, or with just a class and the result used as a handler decorator. |