• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nocarryr / python-dispatch / 3734659194

pending completion
3734659194

push

github

nocarryr
Pin Sphinx to 4.5.0

707 of 722 relevant lines covered (97.92%)

3.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/sphinx-plugin/pydispatch_sphinx/directives.py
1
import typing as tp
4✔
2

3
from sphinx.application import Sphinx
4✔
4
from sphinx.util import logging
4✔
5
from sphinx import addnodes
4✔
6
from docutils import nodes
4✔
7
from docutils.parsers.rst import directives
4✔
8
from sphinx.locale import _, __
4✔
9
from sphinx.domains import ObjType
4✔
10
from sphinx.domains.python import (
4✔
11
    PyXRefRole, PyAttribute, PyMethod, PyObject, type_to_xref,
12
)
13

14
from pydispatch.dispatch import Event
4✔
15
_Event_fullname = '.'.join([Event.__module__, Event.__qualname__])
4✔
16

17
logger = logging.getLogger(__name__)
4✔
18

19
class DispatcherPropertyDirective(PyAttribute):
4✔
20
    option_spec = PyAttribute.option_spec.copy()
4✔
21
    option_spec.update({
4✔
22
        'propcls':directives.unchanged,
23
    })
24

25
    def get_signature_prefix(self, sig: str) -> tp.List[nodes.Node]:
4✔
26
        propcls = self.options.get('propcls')
4✔
27
        return [
4✔
28
            addnodes.desc_type(propcls, '',
29
                type_to_xref(propcls, self.env, suppress_prefix=True),
30
                addnodes.desc_sig_space(),
31
            ),
32
        ]
33

34
class DispatcherEventMethodDirective(PyMethod):
4✔
35
    option_spec = PyMethod.option_spec.copy()
4✔
36
    option_spec['hasargs'] = directives.flag
4✔
37
    option_spec['type'] = directives.unchanged
4✔
38

39
    def needs_arglist(self) -> bool:
4✔
40
        return 'hasargs' in self.options
4✔
41

42
    def get_signature_prefix(self, sig: str) -> tp.List[nodes.Node]:
4✔
43
        return [
4✔
44
            type_to_xref(_Event_fullname, self.env, suppress_prefix=True),
45
            addnodes.desc_sig_space(),
46
        ]
47

48

49
def setup(app: Sphinx) -> None:
4✔
50
    app.setup_extension('sphinx.directives')
4✔
51
    directive_name = 'dispatcherproperty'
4✔
52

53
    app.add_directive_to_domain('py', directive_name, DispatcherPropertyDirective)
4✔
54
    propertyobj_role = PyXRefRole()
4✔
55
    app.add_role_to_domain('py', directive_name, propertyobj_role)
4✔
56

57
    app.add_directive_to_domain('py', 'event', DispatcherEventMethodDirective)
4✔
58
    event_role = PyXRefRole()
4✔
59
    app.add_role_to_domain('py', 'event', event_role)
4✔
60

61
    property_obj_type = ObjType(_('Property'), directive_name, 'attr', 'obj')
4✔
62
    event_obj_type = ObjType(_('Event'), 'event', 'attr', 'obj')
4✔
63
    object_types = app.registry.domain_object_types.setdefault('py', {})
4✔
64
    object_types[directive_name] = property_obj_type
4✔
65
    object_types['event'] = event_obj_type
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc