Skip to content

Commit 80af3ff

Browse files
committed
Added more docstrings
1 parent 9dc5d5c commit 80af3ff

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

chartlets.py/chartlets/extension.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,29 @@
44

55

66
class Extension:
7-
"""A UI Extension."""
7+
"""An extension for a UI application that
8+
uses the Chartlets JS framework."""
89

910
_contrib_points: dict[type[Contribution], str] = {}
1011

1112
@classmethod
1213
def add_contrib_point(cls, name: str, item_type: type[Contribution]):
14+
"""Add a contribution point.
15+
16+
Args:
17+
name: The name of the contribution point.
18+
item_type: The type of items that can be added
19+
to the new contribution point.
20+
"""
1321
cls._contrib_points[item_type] = name
1422

1523
@classmethod
1624
def get_contrib_point_names(cls) -> tuple[str, ...]:
25+
"""Get names of all known contribution points added
26+
by the `add_contrib_point()` method.
27+
28+
Returns: Tuple of registered contribution point names.
29+
"""
1730
values = cls._contrib_points.values()
1831
# noinspection PyTypeChecker
1932
return tuple(values)
@@ -26,6 +39,13 @@ def __init__(self, name: str, version: str = "0.0.0"):
2639
setattr(self, contrib_point_name, [])
2740

2841
def add(self, contribution: Contribution):
42+
"""Add a contribution to this extension.
43+
44+
Args:
45+
contribution: The contribution.
46+
Its type must be an instance of one of the
47+
registered contribution types.
48+
"""
2949
contrib_type = type(contribution)
3050
contrib_point_name = self._contrib_points.get(contrib_type)
3151
if contrib_point_name is None:
@@ -37,6 +57,10 @@ def add(self, contribution: Contribution):
3757
contributions.append(contribution)
3858

3959
def to_dict(self) -> dict[str, Any]:
60+
"""Convert this extension into a JSON-serializable dictionary.
61+
62+
Returns: A dictionary representing this extension.
63+
"""
4064
return dict(
4165
name=self.name,
4266
version=self.version,

0 commit comments

Comments
 (0)