From 627f6be0efce810240106fa3f58754cab159d902 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Dec 2008 15:42:28 -0800 Subject: [PATCH] Add documentation for plugin system --- src/calibre/customize/__init__.py | 18 ++-- src/calibre/customize/ui.py | 8 +- src/calibre/gui2/dialogs/config.ui | 2 +- src/calibre/gui2/images/news/endgadget.png | Bin 0 -> 698 bytes src/calibre/gui2/images/news/fudzilla.png | Bin 0 -> 519 bytes src/calibre/manual/customize.rst | 112 +++++++++++++++++++++ src/calibre/manual/index.rst | 1 + src/calibre/manual/plugins.rst | 100 ++++++++++++++++++ src/calibre/web/feeds/recipes/endgadget.py | 30 ++++++ src/calibre/web/feeds/recipes/fudzilla.py | 26 +++++ 10 files changed, 286 insertions(+), 11 deletions(-) create mode 100644 src/calibre/gui2/images/news/endgadget.png create mode 100644 src/calibre/gui2/images/news/fudzilla.png create mode 100644 src/calibre/manual/customize.rst create mode 100644 src/calibre/manual/plugins.rst create mode 100644 src/calibre/web/feeds/recipes/endgadget.py create mode 100644 src/calibre/web/feeds/recipes/fudzilla.py diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py index a09a764703..3d48f42535 100644 --- a/src/calibre/customize/__init__.py +++ b/src/calibre/customize/__init__.py @@ -19,12 +19,12 @@ class Plugin(object): Methods that should be overridden in sub classes: - * :method:`initialize` - * :method:`customization_help` + * :meth:`initialize` + * :meth:`customization_help` Useful methods: - * :method:`temporary_file` + * :meth:`temporary_file` ''' #: List of platforms this plugin works on @@ -93,6 +93,7 @@ class Plugin(object): a needed binary on the user's computer. :param gui: If True return HTML help, otherwise return plain text help. + ''' raise NotImplementedError @@ -157,9 +158,10 @@ class FileTypePlugin(Plugin): simply return the path to the original ebook. The modified ebook file should be created with the - :method:`temporary_file` method. + :meth:`temporary_file` method. :param path_to_ebook: Absolute path to the ebook. + :return: Absolute path to the modified ebook. ''' # Default implementation does nothing @@ -186,7 +188,8 @@ class MetadataReaderPlugin(Plugin): with the input data. :param type: The type of file. Guaranteed to be one of the entries - in :member:`file_types`. + in :attr:`file_types`. + :return: A :class:`calibre.ebooks.metadata.MetaInformation` object ''' return None @@ -212,8 +215,9 @@ class MetadataWriterPlugin(Plugin): with the input data. :param type: The type of file. Guaranteed to be one of the entries - in :member:`file_types`. + in :attr:`file_types`. :param mi: A :class:`calibre.ebooks.metadata.MetaInformation` object + ''' pass - \ No newline at end of file + diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py index a9f24b9447..f8df1a52d0 100644 --- a/src/calibre/customize/ui.py +++ b/src/calibre/customize/ui.py @@ -112,7 +112,8 @@ def get_file_type_metadata(stream, ftype): try: plugin = _metadata_readers[ftype.lower().strip()] if not is_disabled(plugin): - mi = plugin.get_metadata(stream, ftype.lower().strip()) + with plugin: + mi = plugin.get_metadata(stream, ftype.lower().strip()) except: pass return mi @@ -121,7 +122,8 @@ def set_file_type_metadata(stream, mi, ftype): try: plugin = _metadata_writers[ftype.lower().strip()] if not is_disabled(plugin): - plugin.set_metadata(stream, mi, ftype.lower().strip()) + with plugin: + plugin.set_metadata(stream, mi, ftype.lower().strip()) except: traceback.print_exc() @@ -288,4 +290,4 @@ def main(args=sys.argv): return 0 if __name__ == '__main__': - sys.exit(main()) \ No newline at end of file + sys.exit(main()) diff --git a/src/calibre/gui2/dialogs/config.ui b/src/calibre/gui2/dialogs/config.ui index 6d8647c4b9..05b66cac88 100644 --- a/src/calibre/gui2/dialogs/config.ui +++ b/src/calibre/gui2/dialogs/config.ui @@ -72,7 +72,7 @@ - 4 + 0 diff --git a/src/calibre/gui2/images/news/endgadget.png b/src/calibre/gui2/images/news/endgadget.png new file mode 100644 index 0000000000000000000000000000000000000000..94e8f1219c849379759e6479c74027c3428813fb GIT binary patch literal 698 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%b@U_I1CZGssfk$L9 zkoEv$x0Bg+Ai=T%$8;bK*3S@gZ0%tN2FAypE{-7WP_3o7xoZCMa9QgO<>o1+@ ztM+J%+h~+Jr zeB=&aT(0PfEnDlgSIpJBx#-a5ueoJWTHBwWEBKppN#@_ee@`9;^@_km@0}ZIj#}woLcnO|G+;Fr-J7-Qr#0OHX3F<-0Exaws7O!jEgV%`PdkK zvobQbGB(#Wu&^>P_-f3)6s93JKP5A*5>tb@6;P?E2}FbDmq;g|1_n=8KbLh* G2~7ag8zjE~ literal 0 HcmV?d00001 diff --git a/src/calibre/gui2/images/news/fudzilla.png b/src/calibre/gui2/images/news/fudzilla.png new file mode 100644 index 0000000000000000000000000000000000000000..ad1e67335d2a37402fc8512d77b1bdf4c91720a2 GIT binary patch literal 519 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%b@U_I1CZGssfk$L9 zkoEv$x0Bg+Ai=T%$8;bK*3S@gZ0%tN21Wx<7sn8b(@Q6x_hJeZIaY7%YU-ri<*AYN z;27idyja$?uQ_jRU8~Mf)x1ERBj=)4!S!RVyG#@XvP4xACrp<-=J7fHveWP6$FiN4 zyAS`|_kP~zyTw!1zO`kSU-(OrS?8Z0Us<`qB~Hy9F>8Z0rafU=86lE*GbZ%4F{{*B z@k;iI0TUXwoq1c^eEQSZ|LzgouNg{q*r%o@0ljcx)09oGt0T%o26cRvAdQ^ zto`{vg+?IZ`~bOv9F=P