Updated Branches: refs/heads/trunk 4fe570a7b -> 9548848cb
docs: Update code coventions section. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/678f54ae Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/678f54ae Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/678f54ae Branch: refs/heads/trunk Commit: 678f54ae34b674851494ad177573ec77a8c13091 Parents: 4fe570a Author: Tomaz Muraus <[email protected]> Authored: Sat Jan 11 22:27:47 2014 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Sat Jan 11 22:27:47 2014 +0100 ---------------------------------------------------------------------- docs/development.rst | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/678f54ae/docs/development.rst ---------------------------------------------------------------------- diff --git a/docs/development.rst b/docs/development.rst index afe79d0..5d9b673 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -114,6 +114,54 @@ For example: def __eq__(self, other): return self.name == other.name +Methods on a driver class should be organized in the following order: + +1. Methods which are part of the standard API +2. Extension methods +3. "Private" methods (methods prefixed with an underscore) +4. "Internal" methods (methods prefixed and suffixed with a double underscore) + +Methods which perform a similar functionality should be grouped together and +defined one after another. + +For example: + +.. sourcecode:: python + + class MyDriver(object): + def __init__(self): + pass + + def list_nodes(self): + pass + + def list_images(self): + pass + + def create_node(self): + pass + + def reboot_node(self): + pass + + def ex_create_image(self): + pass + + def _to_nodes(self): + pass + + def _to_node(self): + pass + + def _to_images(self): + pass + + def _to_image(self): + pass + +Methods should be ordered this way for the consistency reasons and to make +reading and following the generated API documentation easier. + 3. Prefer keyword over regular arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
