Difference between revisions of "Contribute code"

From Archivematica
Jump to navigation Jump to search
(→‎Code Style Guide For Archivematica: pothole case instead of camel, updating import guidelines)
(→‎Code Style Guide For Archivematica: Update to reference external guidelines mostly)
Line 14: Line 14:
  
 
=== Code Style Guide For Archivematica ===
 
=== Code Style Guide For Archivematica ===
This coding convention is adopted from:
 
<br/>http://www.python.org/dev/peps/pep-0008/
 
<br/>authors: Guido van Rossum <guido at python.org>, Barry Warsaw <barry at python.org>
 
  
*Tabs are forbidden.
+
Archivematica follows common Python coding standards, notably
*4 spaces per indent.
+
* [https://www.python.org/dev/peps/pep-0008/ PEP8] for styling
*pothole_case all variables, except for class names which are CamelCase (See PEP8 for details/clarifications)
+
** Exception is line length, which should be wrapped at 79 characters or left long for the IDE to wrap.
*Max 79 characters per line.
+
** Imports are sorted alphabetically within their grouping to reduce duplicate imports
*Import grouped according to where they come from and sorted alphabetically, by import source
+
* [https://www.python.org/dev/peps/pep-0257/ PEP257] for docstring structure
<pre>
+
** Parameters and return values should be specified in Sphinx-style.
# Example:
 
# stdlib, alphabetical by import source
 
import logging
 
import os
 
import stat
 
  
# Core Django, alphabetical by import source
+
We encourage installing a Python linter to help with this. [https://pypi.python.org/pypi/flake8 flake8] is recommended because it wraps three common linters (pep8, pyflakes, mccabe).
from django.core import validators
 
from django.core.exceptions import ValidationError
 
from django.db import models
 
  
# Third party dependencies, alphabetical by import source
+
* Install instructions for [https://github.com/SublimeLinter/SublimeLinter-flake8 SublimeLinter-flake8]
from django_extensions.db.fields import SomeField, UUIDField
 
 
 
# This project, alphabetical by import source
 
import common.utils as utils
 
</pre>
 
*All imports from archivematicaCommon should be below adding that to the sys.path (though we shouldn't have to do that)
 
  
 
=== File Structure ===
 
=== File Structure ===

Revision as of 14:53, 11 August 2015

Main Page > Development > Contribute code


Patches

If you find a bug in this project or would like to make an enhancement, please be encouraged to contribute a patch by following these instructions.

Commit access

Anyone can contribute code patches to this project. Project collaborators and regular patch contributors will be given access to commit directly to the git code repository.

Contributor's Agreement

In order to accept any patches or code commits, contributors must first sign the Archivematica Contributor's Agreement.

Standards

Code Style Guide For Archivematica

Archivematica follows common Python coding standards, notably

  • PEP8 for styling
    • Exception is line length, which should be wrapped at 79 characters or left long for the IDE to wrap.
    • Imports are sorted alphabetically within their grouping to reduce duplicate imports
  • PEP257 for docstring structure
    • Parameters and return values should be specified in Sphinx-style.

We encourage installing a Python linter to help with this. flake8 is recommended because it wraps three common linters (pep8, pyflakes, mccabe).

File Structure

The file structure in Archivematica will comply with the Filesystem Hierarchy Standard (FHS).
More information on this standard is available at:
http://www.pathname.com/fhs/