Changes

Jump to: navigation, search

Programming guidelines

2,441 bytes removed, 18:56, 20 September 2007
Revert new module section (mostly included in PEP8)
As more and more people start editing the code, we need to establish a few guidelines to make sure the code remains maintainable.
* Write [http://www.python.org/dev/peps/pep-0008/ PEP 8] compatible code. ! This is important to have a consistent, readable codebase.
* Do not use tabs. Use whitespace. If you use an editor with tabs, go into the preferences, and change the tab behavior to a number of spaces. In GRAMPS we use 4 spaces for indentation.
 
* New modules should follow the GRAMPS convention of module structuring:
# GRAMPS header (programm name, copyright owner, license);
# SVN $Id$;
# Module docstring;
# Author and revision (using SVN $Revision$);
# Imports in the following order, separated with proper headers: Python modules, Logging, Gnome/Gtk modules, GRAMPS modules;
# Constants with header;
# Global variables, module functions, classes, etc.
 
<pre>
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 <Copyright Owner>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
 
# $Id$
 
"""Module docstring.
"""
 
__author__ = "Your Name"
__revision__ = "$Revision$"
 
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
import os
 
#------------------------------------------------------------------------
#
# Set up logging
#
#------------------------------------------------------------------------
import logging
log = logging.getLogger(".NameOfYourModule")
 
#-------------------------------------------------------------------------
#
# Gnome/GTK modules
#
#-------------------------------------------------------------------------
import gtk
 
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
import RelLib
 
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
 
# brief description of each constant
TEST_VALUE = 72.0
 
# etc.
</pre>
* Class headers. Each class should have a simple header to help mark it in the file. This is not used for documentation - it is used to help find the class when multiple classes exist in the same file.
35
edits

Navigation menu