code-guidelines.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Code Guidelines
  2. ===============
  3. Patches to DAK are always welcome. However, to avoid the disappointment of
  4. rejection, a few guidelines and expectations need to be established.
  5. For anything that is not a trivial fix, git trees are strongly preferred over
  6. simple patch files. These are much easier to import, review, and so on.
  7. Please keep different features in their own branch and keeep the repository in
  8. an acessible location until merged.
  9. Code related:
  10. - Use readable and self-speaking variable names.
  11. - Its 4 spaces per indentation. No tab.
  12. - You want to make sure to not add useless whitespaces. If your editor
  13. doesn't hilight them, Git can help you with that, just add the following
  14. in your ~/.gitconfig, and a git diff should hilight them.
  15. Even better, if you enable the hook pre-commit in your copy of the dak
  16. code (chmod +x most probably), git will refuse to commit such things.
  17. ~/.gitconfig,::
  18. [color "diff"]
  19. new = green
  20. old = red
  21. frag = yellow
  22. meta = cyan
  23. commit = normal
  24. - Describe *every* function you write using a docstring. No matter how small.
  25. - Also describe every file.
  26. - And every test unit.
  27. - Don't forget the Copyright/License header in a file. We expect GPLv2 :)
  28. - Don't write long functions. If it goes above a sane limit (like 50
  29. lines) - split it up.
  30. - Look at / read http://www.python.org/dev/peps/pep-0008/
  31. VCS related:
  32. - History rewriting is considered bad.
  33. - Always have a "Signed-off-by" line in your commit. `git commit -s`
  34. automatically does it for you. Alternatively you can enable the hook
  35. "prepare-commit-msg, that should also do it for you.
  36. - Write good, meaningful, commit messages. We do not have a Changelog
  37. file anymore, the git commit is *the* place to tell others what you
  38. did.
  39. Also, try to use the standard format used in the Git world:
  40. First comes a summary line, of around 72 caracters at most.
  41. Then, a blank line, and as many lines and paragraphs as needed
  42. to describe the change in detail. Beware, though, of including
  43. in the commit message explanations that would be better to have
  44. as comments in the code itself!
  45. Signed-off-by: Your Name <and@address.com>