Add some docstrings for CommonPlay/Query skills
parent
5b135bcd91
commit
6fbb49c1e9
|
@ -30,6 +30,15 @@ class CPSMatchLevel(Enum):
|
|||
|
||||
|
||||
class CommonPlaySkill(MycroftSkill, ABC):
|
||||
""" To integrate with the common play infrastructure of Mycroft
|
||||
skills should use this base class and override the two methods
|
||||
`CPS_match_query_phrase` (for checking if the skill can play the
|
||||
utterance) and `CPS_start` for launching the media.
|
||||
|
||||
The class makes the skill available to queries from the
|
||||
mycroft-playback-control skill and no special vocab for starting playback
|
||||
is needed.
|
||||
"""
|
||||
def __init__(self, name=None, bus=None):
|
||||
super().__init__(name, bus)
|
||||
self.audioservice = None
|
||||
|
@ -43,6 +52,13 @@ class CommonPlaySkill(MycroftSkill, ABC):
|
|||
# with a translatable name in their initialize() method.
|
||||
|
||||
def bind(self, bus):
|
||||
""" Overrides the normal bind method.
|
||||
Adds handlers for play:query and play:start messages allowing
|
||||
interaction with the playback control skill.
|
||||
|
||||
This is called automatically during setup, and
|
||||
need not otherwise be used.
|
||||
"""
|
||||
if bus:
|
||||
super().bind(bus)
|
||||
self.audioservice = AudioService(self.bus)
|
||||
|
|
|
@ -41,11 +41,23 @@ def handles_visuals(self, platform):
|
|||
|
||||
|
||||
class CommonQuerySkill(MycroftSkill, ABC):
|
||||
""" Question answering skills should be based on this class. The skill
|
||||
author needs to implement `CQS_match_query_phrase` returning an answer
|
||||
and can optionally implement `CQS_action` to perform additional actions
|
||||
if the skill's answer is selected.
|
||||
|
||||
This class works in conjunction with skill-query which collects
|
||||
answers from several skills presenting the best one available.
|
||||
"""
|
||||
def __init__(self, name=None, bus=None):
|
||||
super().__init__(name, bus)
|
||||
|
||||
def bind(self, bus):
|
||||
""" Overrides the default bind method of MycroftSkill.
|
||||
|
||||
This registers messagebus handlers for the skill during startup
|
||||
but is nothing the skill author needs to consider.
|
||||
"""
|
||||
if bus:
|
||||
super().bind(bus)
|
||||
self.add_event('question:query', self.__handle_question_query)
|
||||
|
|
Loading…
Reference in New Issue