|
30 | 30 | from .players import Player |
31 | 31 |
|
32 | 32 |
|
33 | | -class OverrideDoc(type): |
34 | | - """Helper metaclass to make Sphinx recognise attributes from base classes. |
35 | | -
|
36 | | - This just overrides the object's docstring and injects any documented attributes from the base classes. |
37 | | - """ |
38 | | - |
39 | | - def __new__(cls, *args, **kwargs): |
40 | | - _, bases, _ = args |
41 | | - new_cls = super().__new__(cls, *args, **kwargs) |
42 | | - |
43 | | - for obj in bases: |
44 | | - if obj.__doc__ is None: |
45 | | - continue |
46 | | - if new_cls.__doc__ is None: |
47 | | - continue |
48 | | - if "Attributes" not in obj.__doc__: |
49 | | - continue |
50 | | - |
51 | | - try: |
52 | | - doc = obj.__doc__.split("Attributes")[1].split("\n\n")[0] |
53 | | - except (KeyError, AttributeError): |
54 | | - continue |
55 | | - |
56 | | - if "Attributes" not in new_cls.__doc__: |
57 | | - new_cls.__doc__ += "\nAttributes\n----------\n" + doc.replace("----------", "") |
58 | | - else: |
59 | | - try: |
60 | | - insert = new_cls.__doc__.index("Attributes") |
61 | | - except ValueError: |
62 | | - return new_cls |
63 | | - |
64 | | - # fmt: off |
65 | | - new_cls.__doc__ = ( |
66 | | - new_cls.__doc__[:insert + 25] + doc.replace("----------", "") + new_cls.__doc__[insert + 25:] |
67 | | - ) |
68 | | - # fmt: on |
69 | | - |
70 | | - return new_cls |
71 | | - |
72 | | - |
73 | | -class BaseClan(metaclass=OverrideDoc): |
| 33 | +class BaseClan: |
74 | 34 | """An ABC that implements some common operations on clans, regardless of type. |
75 | 35 |
|
76 | 36 | Attributes |
@@ -142,7 +102,7 @@ def get_detailed_members(self, cls: Type["Player"] = None) -> AsyncIterator["Pla |
142 | 102 | return PlayerIterator(self._client, (p.tag for p in self.members), cls=cls) |
143 | 103 |
|
144 | 104 |
|
145 | | -class BasePlayer(metaclass=OverrideDoc): |
| 105 | +class BasePlayer: |
146 | 106 | """An ABC that implements some common operations on players, regardless of type. |
147 | 107 |
|
148 | 108 | Attributes |
|
0 commit comments