Skip to content
John Sullivan edited this page May 8, 2013 · 4 revisions

Style Guide for Galah Group Repositories

Style isn't really something that I want anyone to spend a lot of time dealing with, so these rules are as minimal as I can make them.

Python Source Files

  1. Use 4 spaces for each indent.
  2. Ensure there is a newline at the end of every file (most editors have a way to automatically do this for you).
  3. CamelCase for class names only, everything else (functions and variables) should use underscores (ex: foo_bar).
  4. Every source file must have license header at the top, even if the file is empty.
class Bar:
    def __init__(self):
        self.counter = 3

    def pet_hamster(self):
        Pimport hamster
        hamster.pet()

Git Commit Messages

  1. Use the past tense when writing commit messages rather than the present tense (exception for Fixes/Fixed messages, either is fine).
  2. Limit the first line of the commit message to 50 characters. Vim will automatically use angry colors if you go over this limit.
  3. Details (if needed) should be written in bullet point form (using asterisks as bullets, no whitespace before the asterisk).
  4. Use proper punctuation, grammar, capitilization, etc.
Added dependency to foo.py.

* Was missing hamster module.
* This fixes #9999.
Fixed #219.

CSS

  1. If selector has one attribute, all of it goes on one line, otherwise use multiple lines with brace on the same line as the selector.
  2. Each attribute on its own line (always ending with a semicolon).
  3. The ending brace on a line of its own with no indentation.
  4. Each block must be surrounded by a single blank line on both sides.
  5. Pixels (px) rather than ems should be used.

JS, HTML, and Jinja2

  1. Always use semi-colons.
  2. Curly braces should be on the same line as the control structure.
  3. Use tabs rather than spaces.
  4. Indent after Jinja2 control structures and use dashes.
  5. Same naming rules as for Python.
{%- if submission.show_resubmit -%}
	<div>
		<a href="resubmit/{{ submission.id }}"><input type="button" value="Resubmit"></a>
	</div>
{%- endif -%}
if (files_added > 0) {
    $(this).attr("disabled", "disabled");
    $("form").submit();
}