Skip to content

Commit cca15c5

Browse files
committed
docs: add missing method docs in papi.py
1 parent 2d31c69 commit cca15c5

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

endstone_papi/papi.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def __init__(self, plugin: Plugin):
2222
def set_placeholders(self, player: Player | None, text: str) -> str:
2323
"""
2424
Translates all placeholders into their corresponding values.
25-
The pattern of a valid placeholder is {<identifier>:<params>}.
25+
The pattern of a valid placeholder is {<identifier>|<params>}.
2626
2727
Args:
28-
player (Player): Player to parse the placeholders against.
28+
player (Player | None): Player to parse the placeholders against.
2929
text (str): Text to set the placeholder values in.
3030
3131
Returns:
@@ -34,23 +34,53 @@ def set_placeholders(self, player: Player | None, text: str) -> str:
3434
return apply(player, text, self._registry)
3535

3636
def is_registered(self, identifier: str) -> bool:
37+
"""
38+
Check if a specific placeholder identifier is currently registered.
39+
40+
Args:
41+
identifier (str): The identifier to check.
42+
43+
Returns:
44+
bool: True if identifier is already registered, False otherwise.
45+
"""
3746
return identifier in self._registry
3847

3948
@property
4049
def registered_identifiers(self):
50+
"""
51+
Get all registered placeholder identifiers.
52+
53+
Returns:
54+
list[str]: A list containing the identifiers of all registered placeholders.
55+
"""
4156
return self._get_registered_identifiers()
4257

4358
def _get_registered_identifiers(self) -> list[str]:
4459
return list(self._registry.keys())
4560

4661
@property
4762
def placeholder_pattern(self):
63+
"""
64+
Get the normal placeholder pattern.
65+
66+
Returns:
67+
str: Regex pattern of [{]([^{}]+)[}].
68+
"""
4869
return self._get_placeholder_pattern()
4970

5071
def _get_placeholder_pattern(self) -> str:
5172
return self._placeholder_pattern.pattern
5273

5374
def contains_placeholders(self, text: str) -> bool:
75+
"""
76+
Check if a string contains any placeholders ({<identifier>|<params>}).
77+
78+
Args:
79+
text (str): String to check.
80+
81+
Returns:
82+
bool: True if string contains any matches to the bracket placeholder pattern, False otherwise.
83+
"""
5484
return self._placeholder_pattern.search(text) is not None
5585

5686
def register_placeholder(
@@ -59,6 +89,17 @@ def register_placeholder(
5989
identifier: str,
6090
processor: Callable[[Player | None, str], str],
6191
) -> bool:
92+
"""
93+
Attempt to register a placeholder.
94+
95+
Args:
96+
plugin (Plugin): The plugin that is registering the placeholder.
97+
identifier (str): The identifier of the placeholder.
98+
processor (Callable[[Player | None, str], str]): The processor that will process the placeholder.
99+
100+
Returns:
101+
bool: True if the placeholder was successfully registered, False otherwise.
102+
"""
62103
if self.is_registered(identifier):
63104
# use the fallback identifier with plugin name as the namespace
64105
identifier = f"{plugin.name}:{identifier}"

0 commit comments

Comments
 (0)