Skip to content

Commit f49e734

Browse files
📝 Add docstrings to feat/intent_transformers (#317)
Docstrings generation was requested by @JarbasAl. * #316 (comment) The following files were modified: * `ovos_plugin_manager/templates/transformers.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3467ff1 commit f49e734

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

ovos_plugin_manager/templates/transformers.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,23 @@ def transform(self, utterances: List[str],
7676
return utterances, {}
7777

7878
def default_shutdown(self):
79-
""" perform any shutdown actions """
79+
"""
80+
Performs any necessary shutdown or cleanup actions.
81+
82+
Intended to be overridden by subclasses to implement custom shutdown logic.
83+
"""
8084
pass
8185

8286

8387
class IntentTransformer:
8488
""" runs before selected intent is triggered, can be used to inject message.data"""
8589

8690
def __init__(self, name, priority=50, config=None):
91+
"""
92+
Initializes the IntentTransformer with a name, priority, and optional configuration.
93+
94+
If no configuration is provided, attempts to load it from the global configuration under "intent_transformers" using the given name.
95+
"""
8796
self.name = name
8897
self.bus = None
8998
self.priority = priority
@@ -93,23 +102,42 @@ def __init__(self, name, priority=50, config=None):
93102
self.config = config or {}
94103

95104
def bind(self, bus=None):
96-
""" attach messagebus """
105+
"""
106+
Attach a message bus instance to the transformer.
107+
108+
If no bus is provided, the default Mycroft message bus is used.
109+
"""
97110
self.bus = bus or get_mycroft_bus()
98111

99112
def initialize(self):
100-
""" perform any initialization actions """
113+
"""
114+
Performs any necessary initialization actions for the transformer.
115+
116+
Intended to be overridden by subclasses to implement custom setup logic.
117+
"""
101118
pass
102119

103120
@abc.abstractmethod
104121
def transform(self, intent: Union[IntentHandlerMatch, PipelineMatch]) -> Union[IntentHandlerMatch, PipelineMatch]:
105122
"""
106-
Optionally transform intent handler data
107-
e.g. NER could be performed here by modifying intent.match_data
123+
Transforms the intent match object before the intent handler is triggered.
124+
125+
This method can be used to modify or inject data into the intent, such as performing named entity recognition (NER) or altering match data. By default, it returns the intent unchanged.
126+
127+
Args:
128+
intent: The intent match object to be transformed.
129+
130+
Returns:
131+
The transformed intent match object.
108132
"""
109133
return intent
110134

111135
def default_shutdown(self):
112-
""" perform any shutdown actions """
136+
"""
137+
Performs any necessary shutdown actions for the transformer.
138+
139+
Intended to be overridden by subclasses to implement cleanup procedures.
140+
"""
113141
pass
114142

115143

0 commit comments

Comments
 (0)