Version 18 (modified by 14 years ago) ( diff ) | ,
---|
Table of Contents
Code Conventions
These conventions should be followed in all code.
NOTE: These coding conventions are mandatory for code to be accepted for the Stable series!
Code Style
- http://code.google.com/p/soc/wiki/PythonStyleGuide
- Limit line length to 80 characters
- Use " " for strings, UNLESS the string contains a ", in which case use '
PEP8 Script
Use static/scripts/tools/pep8.py to check for PEP8 compliance.
Execute the following in your eden directory:
python static/scripts/tools/pep8.py yourfile.py
Naming conventions
- All functions outside of classes should have the prefix shn_<Model Name>_
- All classes which over-ride existing classed should have the suffix "S3"
Comments and Docstrings
- All files, classes and functions should have docstrings which allow to auto-generate API documentation using epydoc
Suggested style:
""" This function is just an example @param: None """
Internationalisation
- All user-visible strings should be Internationalised:
T("My string")
- Remember to
str()
them before concatenating with strings (such as HTML tags):"<p>" + str(T("My String")) + "</p>"
- Remember to
- All labels should be Internationalised in
controllers/module.py def resource()
:table.field.label = T("My Label")
- DeveloperGuidelinesInternationalisation
Tools
- Some automated bug analysis / code quality checking tools -
- PyLint
- gives detailed report
- code quality score tells exact impact of the changes made
- http://www.logilab.org/card/pylint_tutorial
- PyChecker recommended in PythonStyleGuide
- PyLint
Note:
See TracWiki
for help on using the wiki.