From 8e2ca7681f689c389fa8c7a4a78a10b67b92e5a4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 27 Mar 2011 14:12:35 -0600 Subject: [PATCH] Add a section on how to debug plugins --- src/calibre/manual/creating_plugins.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/calibre/manual/creating_plugins.rst b/src/calibre/manual/creating_plugins.rst index 65e44760ef..90494231d2 100644 --- a/src/calibre/manual/creating_plugins.rst +++ b/src/calibre/manual/creating_plugins.rst @@ -174,6 +174,27 @@ The different types of plugins As you may have noticed above, a plugin in |app| is a class. There are different classes for the different types of plugins in |app|. Details on each class, including the base class of all plugins can be found in :ref:`plugins`. +Debugging plugins +------------------- + +The first, most important step is to run |app| in debug mode. You can do this from the command line with:: + + calibre-debug -g + +Or from within calibre by clicking the arrow next to the preferences button or using the `Ctrl+Shift+R` keyboard shortcut. + +When running from the command line, debug output will be printed to the console, when running from within |app| the output will go to a txt file. + +You can insert print statements anywhere in your plugin code, they will be output in debug mode. Remember, this is python, you really shouldn't need anything more than print statements to debug ;) I developed all of |app| using just this debugging technique. + +It can get tiresome to keep re-adding a plugin to calibre to test small changes. The plugin zip files are stored in the calibre config directory in plugins/ (goto Preferences->Misc and click open config directory to see the config directory). + +Once you've located the zip file of your plugin you can then directly update it with your changes instead of re-adding it each time. To do so from the command line, in the directory that contains your plugin source code, use:: + + zip -R /path/to/plugin/zip/file.zip * + +This will automatically update all changed files. It relies on the freely available zip command line tool. + More plugin examples ----------------------