Cleaning some unnecessary whitespace, overall cleanup of various source codes.

This commit is contained in:
Griatch 2012-03-30 23:47:22 +02:00
parent d4c97d7df8
commit c0322c9eae
27 changed files with 1342 additions and 1318 deletions

View file

@ -1,59 +1,63 @@
Evennia Code Style
------------------
All code submitted or committed to the Evennia project needs to follow the
guidelines outlined in Python PEP 8, which may be found at:
All code submitted or committed to the Evennia project needs to follow
the guidelines outlined in Python PEP 8, which may be found at:
http://www.python.org/dev/peps/pep-0008/
A quick list of code style points
---------------------------------
* 4-space indendation, NO TABS!
* Unix line endings.
* CamelCase is only used for classes, nothing else.
* All non-global variable names and all function names are to be lowercase,
words separated by underscores. Variable names should always be more than
two letters long.
* CamelCase is only used for classes, nothing else.
* All non-global variable names and all function names are to be
lowercase, words separated by underscores. Variable names should
always be more than two letters long.
* Module-level global variables (only) are to be in CAPITAL letters.
* Imports are to be done in this order:
- Python modules (builtins and modules otherwise unrelated to Evennia)
- Twisted
- Django
* (Evennia-specific): Imports should normally be done in this order:
- Python modules (builtins and standard library)
- Twisted modules
- Django modules
- Evennia src/ modules
- Evennia game/ modules
- Evennia 'ev' API imports
Documentation
-------------
Remember that Evennia's source code is intended to be read - and will be read - by
game admins trying to implement various features. Evennia prides itself with being
extensively documented. Modules, functions, classes and class methods should all
start with at least one line of docstring summing up the function's purpose. Ideally
also explain eventual arguments and caveats. Add comments where appropriate.
Remember that Evennia's source code is intended to be read - and will
be read - by game admins trying to implement their game. Evennia
prides itself with being extensively documented. Modules, functions,
classes and class methods should all start with at least one line of
docstring summing up the function's purpose. Ideally also explain
eventual arguments and caveats. Add comments where appropriate.
Pylint
------
The program 'pylint' (http://www.logilab.org/857) is a useful tool for checking
your Python code for errors. It will also check how well your code adheres to
the PEP 8 guidelines (such as lack of docstrings) and tells you what can be improved.
The program 'pylint' (http://www.logilab.org/857) is a useful tool for
checking your Python code for errors. It will also check how well your
code adheres to the PEP 8 guidelines (such as lack of docstrings) and
tells you what can be improved.
Since pylint cannot catch dynamically created variables used in commands and
elsewhere in Evennia, one needs to reduce some checks to avoid false errors and
warnings. For best results, run pylint like this:
Since pylint cannot catch dynamically created variables used in
commands and elsewhere in Evennia, one needs to reduce some checks to
avoid false errors and warnings. For best results, run pylint like
this:
> pylint --disable=E1101,E0102,F0401,W0232,R0903 filename.py
To avoid entering the options every time, you can auto-create a pylintrc file by
using the option --generate-rcfile. You need to dump this output into a
file .pylintrc, for example like this (linux):
To avoid entering the options every time, you can auto-create a
pylintrc file by using the option --generate-rcfile. You need to dump
this output into a file .pylintrc, for example like this (linux):
> pylint --disable=E1101,E0102,F0401,W0232,R0903 --generate-rcfile > ~/.pylintrc
From now on you can then just run
From now on you can then just run
> pylint filename.py
Ask Questions!
--------------
If any of the rules outlined in PEP 8 or in the sections above doesn't make sense, please
don't hesitate to ask on the Evennia mailing list at http://evennia.com.
Keeping our code style uniform makes this project much easier for a wider group
of people to participate in.
If any of the rules outlined in PEP 8 or in the sections above doesn't
make sense, please don't hesitate to ask on the Evennia mailing list
at http://evennia.com. Keeping our code style uniform makes this
project much easier for a wider group of people to participate in.