Version 6 (modified by 18 years ago) ( diff ) | ,
---|
Trac Coding Style
Like most Python projects, we try to adhere to PEP 8 (Style Guide for Python Code) and PEP 257 (Docstring Conventions). Be sure to read those documents if you intend to contribute code to Trac.
Note that some of the current Trac code violates a couple of the rules below. We are currently in the process of refactoring the offending modules so that all code uses the same conventions.
Naming conventions
- Package and module names should be all lower-case, words may be separated by underscores.
- Class names use CamelCase.
- The names of functions, variables and class members use all lower-case, with words separated by underscores.
- Internal methods and variables are prefixed with a single underscore.
Miscellaneous
- Lines shouldn't exceed a length of 80 characters.
- Prefer list comprehension to the built-in functions
filter()
andmap()
when appropriate. - Use
raise TracError("message")
instead ofraise TracError, "message"
- A little difference from PEP:0257: we usually don't inserting a blank line between the last paragraph in a multi-line docstring and its closing quotes.
- Also, in Docstring, we make quite a liberal usage of WikiFormatting. This is even useful in some case, like for Macro classes docstrings, which are rendered to HTML using the [[MacroList]].
See also: TracDev
Note:
See TracWiki
for help on using the wiki.