Skip to content
Dan Feeney edited this page Jan 5, 2016 · 9 revisions

This will outline the key pieces of how to code for Ainneve and make sure your code fits the formatting standards.

PEP8

Some highlights of this:

  • Tabs are 4 spaces, and they are SPACES, not TABS
  • A blank line at the end of every file (no whitespace on this line)
  • 79 characters per line maximum, except for docstrings and comments which are 72.

There are some other pieces that are fairly nitpicky. If you are going to make serious code contributions, please read up in full: https://www.python.org/dev/peps/pep-0008/

Naming Convention

Per allowed conventions by PEP8, we use lowercase and lower_case_with_underscore. All method names are lower_case_with_underscore and data in lists, dicts, etc are simply lowercase, as well as the variable names.

If data may be presented to the user as-is, please format it appropriately for reading.

Sublime Text

Sublime Text 3 with Anaconda will automatically give you PEP8 errors as you code. You can follow this tutorial if using ST3: https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/

Example Sublime Configuration

Here is my Sublime configuration:

{
  "auto_complete": false,
  "caret_style": "solid",
  "color_scheme": "Packages/User/SublimeLinter/Flatland Dark (SL).tmTheme",
  "draw_white_space": "all",
  "ensure_newline_at_eof_on_save": true,
  "file_exclude_patterns":
  [
    ".DS_Store",
    "*.pid",
    "*.pyc"
  ],
  "find_selected_text": true,
  "fold_buttons": false,
  "folder_exclude_patterns":
  [
    ".git",
    "__pycache__",
    "env",
    "env3"
  ],
  "highlight_line": true,
  "highlight_modified_tabs": true,
  "ignored_packages":
  [
    "Vintage"
  ],
  "rulers":
  [
    79
  ],
  "scroll_past_end": false,
  "show_full_path": true,
  "show_minimap": false,
  "sublimelinter": false,
  "tab_size": 4,
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true,
  "wide_caret": true,
  "word_wrap": true,
  "wrap_width": 80
}

Docstrings

All modules, module level functions, and classes for Ainneve should have a docstring in the Google style.

In addition, because Ainneve is a collaborative effort, all contributors are encouraged to include comments throughout their code as needed to clarify the logic for future coders.

Examples can be found here: http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html

Unit Testing

Ainneve and Evennia both have automated "continuous integration" testing configured using Travis CI. Writing unit tests for your code ensures that everything you have written works properly, often bringing to light problems in the code before you ever submit a pull request. It also provides reassurance that future commits won't introduce errors in the tested code.

That said, conceptualizing and writing unit tests can be a bit tricky at first. Below are some links to more info about unit testing:

So far, we have worked to cover as much of the Ainneve code base with tests as possible. It is strongly encouraged that contributors write unit tests for any code they submit. If you need help getting started writing tests, the best place to ask for help is the #evennia channel on freenode IRC.