From 9763cb55a6363e193b892bbb1f1658e1db78af28 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 14 Feb 2010 02:57:05 +0100 Subject: [PATCH] Add examples of code style --- docs/development.rst | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/development.rst b/docs/development.rst index 3f4897db..826dd215 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -30,12 +30,33 @@ Code style We generally follow the `PEP-8 `_ style guidelines, with a couple of notable exceptions: -- We only indent continuation lines with an addition four spaces relative to - the previous line. +- We indent continuation lines with four spaces more than the previous line. + For example:: + + from mopidy.backends import (BaseBackend, BaseCurrentPlaylistController, + BasePlaybackController, BaseLibraryController, + BaseStoredPlaylistsController) + + And not:: + + from mopidy.backends import (BaseBackend, BaseCurrentPlaylistController, + BasePlaybackController, BaseLibraryController, + BaseStoredPlaylistsController) + - An exception to the previous exception: When continuing control flow - statements like ``if``, ``for`` and ``while``, indent the continuation lines - with eight spaces, so that it is indented an additional level compared to the - following block of code. + statements like ``if``, ``for`` and ``while``, we indent with eight spaces + more than the previous line. In other words, the line is indented one level + further to the right than the following block of code. For example:: + + if (old_state in (self.PLAYING, self.STOPPED) + and new_state == self.PLAYING): + self._play_time_start() + + And not:: + + if (old_state in (self.PLAYING, self.STOPPED) + and new_state == self.PLAYING): + self._play_time_start() Running tests