From 79d6b6f67f074d51bc6bf78d558ca40daee6e1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 5 Nov 2015 19:11:35 +0100 Subject: [PATCH] Added plugins FAQ to the docs --- docs/plugins.rst | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index 4787c87..a38002f 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -1,4 +1,48 @@ Developing new plugins ---------------------- -See the examples at: ``_. +Plugins Interface +================= + +The basic methods in a plugin are: + +* __init__ +* activate: used to load memory-hungry resources +* deactivate: used to free up resources + +Plugins are loaded asynchronously, so don't worry if the activate method takes too long. The plugin will be marked as activated once it is finished executing the method. + +F.A.Q. +====== +If I'm using a classifier, where should I train the classifier? +??????????????????????????????????????????????????????????????? + +Training a classifier can be time time consuming. To avoid running the training unnecessarily, you can use ShelfMixin to store the classifier. For instance: + +.. code:: python + + from senpy.plugins import ShelfMixin, SenpyPlugin + + class MyPlugin(ShelfMixin, SenpyPlugin): + def train(self): + ''' Code to train the classifier + ''' + # Here goes the code + # ... + return classifier + + def activate(self): + if 'classifier' not in self.sh: + classifier = self.train() + self.sh['classifier'] = classifier + self.classifier = self.sh['classifier'] + + def deactivate(self): + self.close() + +You can speficy a 'shelf_file' in your .senpy file. By default the ShelfMixin creates a file based on the plugin name and stores it in that plugin's folder. + +Where can I find more code examples? +???????????????????????????????????? + +See: ``_.