11:title: Coding Standards
2- :description: -- todo: change me
3- :keywords: deis, documentation, contributing, developer, setup
2+ :description: Coding Standards for the Deis Project
3+ :keywords: deis, contributing, coding, python, test, tests, testing
44
55.. _standards :
66
@@ -9,36 +9,56 @@ Coding Standards
99
1010Deis is a `python `_ project. We chose python over other compelling
1111languages because it is widespread, well-documented, and friendly to
12- a large number of developers. We think open source code benefits from
13- many eyes upon it.
12+ a large number of developers. Source code benefits from many eyes
13+ upon it.
14+
15+ `The Zen of Python `_ emphasizes simple over clever, and we agree.
16+ Readability counts. Deis also aims for complete test coverage.
1417
1518Contributors to deis should feel welcome to make changes to any part
1619of the codebase. To create a proper github pull request for inclusion
1720into the official repository, your code must pass two tests:
1821
19- - :ref: `flake8 `
20- - :ref: `coverage `
22+ - :ref: `make_flake8 `
23+ - :ref: `make_coverage `
2124
2225
23- .. _ flake8 :
26+ .. _ make_flake8 :
2427
2528``make flake8 ``
2629---------------
2730
28- ::
31+ `flake8 `_ is a helpful command-line tool that combines the output of
32+ `pep8 <pep8_tool _>`_, `pyflakes `_, and `mccabe `_.
33+
34+ .. code-block :: console
2935
3036 $ cd $HOME/projects/deis
3137 $ make flake8
3238 flake8
3339 $
3440
41+ No output, as above, means ``flake8 `` found no errors. If errors
42+ are reported, fix them in your source code and try ``flake8 `` again.
43+
44+ The Deis project adheres to `PEP8 `_, the python code style guide,
45+ with the exception that we allow lines up to 99 characters in length.
46+ Docstrings and tests are also required for all public methods, although
47+ ``flake8 `` does not enforce this.
48+
49+ Default settings for ``flake8 `` are in the ``[flake8] `` section of the
50+ setup.cfg file in the project root.
51+
3552
36- .. _ coverage :
53+ .. _ make_coverage :
3754
3855``make coverage ``
3956-----------------
4057
41- ::
58+ Once your code passes the style checker, run the test suite and
59+ ensure that everything passes and that code coverage has not declined.
60+
61+ .. code-block :: console
4262
4363 $ cd $HOME/projects/deis
4464 $ make coverage
@@ -53,5 +73,27 @@ into the official repository, your code must pass two tests:
5373 coverage html
5474 $
5575
76+ If a test fails, fixing it is obviously the first priority. And if you
77+ have introduced new code, it must be accompanied by unit tests.
78+
79+ In the example above, all tests passed and ``coverage `` created a report
80+ of what code was exercised while the tests were running. Open the file
81+ ``htmlcov/index.html `` under the project's root and ensure that the
82+ overall coverage percentage has not receded as a result of your
83+ changes. Current test coverage can be found here:
84+
85+ .. image :: https://coveralls.io/repos/opdemand/deis/badge.png?branch=master
86+ :target: https://coveralls.io/r/opdemand/deis?branch=master
87+ :alt: Coverage Status
88+
89+ Now create a GitHub pull request with a description of what your code
90+ fixes or improves. That's it!
91+
5692
5793.. _python : http://www.python.org/
94+ .. _flake8 : https://pypi.python.org/pypi/flake8/
95+ .. _pep8_tool : https://pypi.python.org/pypi/pep8/
96+ .. _pyflakes : https://pypi.python.org/pypi/pyflakes/
97+ .. _mccabe : https://pypi.python.org/pypi/mccabe/
98+ .. _PEP8 : http://www.python.org/dev/peps/pep-0008/
99+ .. _`The Zen of Python` : http://www.python.org/dev/peps/pep-0020/
0 commit comments