From f2a2bfc617f8fe5d97db70bc5b2ccf1b99ec6d4a Mon Sep 17 00:00:00 2001 From: BJ Dierkes Date: Tue, 31 Jul 2012 17:15:08 -0500 Subject: [PATCH] Improving documentation --- cement/core/arg.py | 5 +- cement/core/cache.py | 6 +- cement/core/config.py | 6 +- cement/core/controller.py | 193 +++++----- cement/core/exc.py | 23 +- cement/core/extension.py | 60 +-- cement/core/foundation.py | 491 ++++++++++++------------ cement/core/log.py | 5 + cement/core/output.py | 5 + cement/core/plugin.py | 5 + doc/source/api/core/arg.rst | 4 +- doc/source/api/core/backend.rst | 3 +- doc/source/api/core/cache.rst | 4 +- doc/source/api/core/config.rst | 4 +- doc/source/api/core/controller.rst | 4 +- doc/source/api/core/exc.rst | 4 +- doc/source/api/core/extension.rst | 4 +- doc/source/api/core/foundation.rst | 3 +- doc/source/api/core/handler.rst | 4 +- doc/source/api/core/hook.rst | 4 +- doc/source/api/core/interface.rst | 4 +- doc/source/api/core/log.rst | 4 +- doc/source/api/core/meta.rst | 4 +- doc/source/api/core/output.rst | 4 +- doc/source/api/core/plugin.rst | 4 +- doc/source/api/ext/ext_argparse.rst | 2 + doc/source/api/ext/ext_configparser.rst | 3 + doc/source/api/ext/ext_json.rst | 4 +- doc/source/api/ext/ext_logging.rst | 4 +- doc/source/api/ext/ext_nulloutput.rst | 2 + doc/source/api/ext/ext_plugin.rst | 2 + doc/source/api/utils/fs.rst | 4 +- doc/source/api/utils/misc.rst | 4 +- doc/source/api/utils/shell.rst | 4 +- doc/source/api/utils/test.rst | 4 +- 35 files changed, 489 insertions(+), 401 deletions(-) diff --git a/cement/core/arg.py b/cement/core/arg.py index fc2ed08d..4c116856 100644 --- a/cement/core/arg.py +++ b/cement/core/arg.py @@ -97,7 +97,10 @@ class CementArgumentHandler(handler.CementBaseHandler): """ # pylint: disable=W0232,R0903 class Meta: - """Handler meta-data options.""" + """ + Handler meta-data (can be passed as keyword arguments to the parent + class). + """ label = None """The string identifier of the handler implementation.""" diff --git a/cement/core/cache.py b/cement/core/cache.py index 455bc923..f3005760 100644 --- a/cement/core/cache.py +++ b/cement/core/cache.py @@ -109,7 +109,11 @@ class CementCacheHandler(handler.CementBaseHandler): """ class Meta: - """Handler meta-data.""" + """ + Handler meta-data (can be passed as keyword arguments to the parent + class). + """ + label = None """String identifier of this handler implementation.""" diff --git a/cement/core/config.py b/cement/core/config.py index 2de72372..7543ed83 100644 --- a/cement/core/config.py +++ b/cement/core/config.py @@ -161,6 +161,7 @@ class IConfig(interface.Interface): """ Returns whether or not the section exists. + :param section: The section to test for. :returns: boolean """ @@ -171,7 +172,10 @@ class CementConfigHandler(handler.CementBaseHandler): """ class Meta: - """Handler meta-data.""" + """ + Handler meta-data (can be passed as keyword arguments to the parent + class). + """ label = None """The string identifier of the implementation.""" diff --git a/cement/core/controller.py b/cement/core/controller.py index 73f5fc29..ed1a1316 100644 --- a/cement/core/controller.py +++ b/cement/core/controller.py @@ -62,11 +62,16 @@ class IController(interface.Interface): """ # pylint: disable=W0232, C0111, R0903 class IMeta: + """Interface meta-data.""" + label = 'controller' + """The string identifier of the interface.""" + validator = controller_validator + """The interface validator function.""" # Must be provided by the implementation - Meta = interface.Attribute('Handler Meta-data') + Meta = interface.Attribute('Handler meta-data') def _setup(app_obj): """ @@ -77,12 +82,8 @@ class IController(interface.Interface): Must 'setup' the handler object making it ready for the framework or the application to make further calls to it. - Required Arguments: - - app_obj - The application object. - - Return: None + :param app_obj: The application object. + :returns: None """ @@ -96,7 +97,8 @@ class IController(interface.Interface): on a controller, as it expects the controller to handle parsing arguments (I.e. self.app.args.parse()). - Return None + :returns: None + """ class expose(object): @@ -104,16 +106,12 @@ class expose(object): Used to expose controller functions to be listed as commands, and to decorate the function with Meta data for the argument parser. - Optional Arguments: - - hide - Whether the command should be visible. - - help - Help text to display for that command. - - aliases - List of aliases to this command. + :param hide: Whether the command should be visible. + :type hide: boolean + :param help: Help text to display for that command. + :type help: str + :param aliases: Aliases to this command. + :type aliases: list Usage: @@ -150,59 +148,15 @@ class expose(object): class CementBaseController(handler.CementBaseHandler): """ - This is an implementation of the IControllerHandler interface, but as a - base class that application controllers need to subclass from. + This is an implementation of the + `IControllerHandler <#cement.core.controller.IController>`_ interface, but + as a base class that application controllers `should` subclass from. Registering it directly as a handler is useless. - NOTE: This handler *requires* that the applications 'arg_handler' be + NOTE: This handler **requires** that the applications 'arg_handler' be argparse. If using an alternative argument handler you will need to write your own controller base class. - Optional / Meta Options: - - interface - The interface that this controller implements (IController). - - label - The label of the controller. Will be used as the sub-command - name for 'stacked' controllers. - - aliases - A list of aliases for the controller. Will be treated like - command/function aliases for non-stacked controllers. For example: - 'myapp --help' is the same as - 'myapp --help'. - - Default: [] - - description - The description shown at the top of '--help'. - - config_section - A config [section] to merge config_defaults into. - - Default: controller.