Contributing CodingStyle - gazpachoking/deluge GitHub Wiki
Coding Styles
Common
- Max line length
119
rather than usual79
. That said, where possible keep to79
.
Python
Mostly follow PEP8 with the following exceptions:
-
Line length (see above)
-
Code should pass the flake8 source code checker and in ideal cases Pylint too.
-
All byte arrays (byte strings,
str
) should be decoded to strings (unicode strings,unicode
) on input and encoded back to byte arrays on output. From Stackoverflow:
>>> b"abcde"
b'abcde'
>>> b"abcde".decode("utf-8")
'abcde'
Note: PyGTK/GTK+ will accept str
(utf8 encoded) or unicode
but will only return str
. See GTK+ Unicode docs.
- All relative path separators used within code should be converted to posix format
/
, so should not contain\
or\\
. This is to prevent confusion when dealing with cross-platform clients and servers.
Docstrings
You will find a mix of the older reStructuredText and newer, easier to read, Sphinx Napoleon format.
Going forward the Napoleon Google Style will be used for all new doctrings and eventually convert over the rest.
Single or Double Quotes
The python code base should be "double quotes"
.
Python References
Useful links to style guides from other projects:
Javascript
- Classes should follow the Ext coding style.
- Class names should be in CamelCase
- Instances of classes should use camelCase.
Single or Double Quotes
For the javascript code use 'single quotes'
.
Commit Messages
This should probably have it's own page but putting here for now.
Mainly based on git commit guidelines
- If the commit fix/closes a ticket, include the number:
[#1001](/gazpachoking/deluge/wiki/#1001) Add support for magnet uris
To differentiate commit changes at a glance, commits for specific components can optionally include tags. e.g. WebUI, GTKUI, Console, Blocklist etc.
[#1002](/gazpachoking/deluge/wiki/#1002) [GTKUI](/gazpachoking/deluge/wiki/GTKUI) Fix the files tab context menu not being displayed