|
StyleGuide
Style guide for Ganeti code and documentation
IntroductionThese are a few guidelines for Ganeti code and documentation. DocstringsNote: PEP 257 is the canonical document, unless epydoc overrules it (e.g. in how to document the type of an argument). For docstrings, the recommended format is epytext, to be processed via epydoc. There is an apidoc target that builds the documentation and puts it into the doc/api subdir. Note that we currently use epydoc version 3.0. Note that one-line docstrings are only accepted in the unittests. Rules for writing the docstrings (mostly standard Python rules):
Example (see also http://epydoc.sourceforge.net/manual-epytext.html): def fn(foo, bar):
"""Compute the sum of foo and bar.
This functions builds the sum of foo and bar. It's a simple function.
@type foo: int
@param foo: First parameter.
@type bar: float
@param bar: The second parameter. This line is longer
to show wrapping.
@rtype: float
@return: the sum of the two numbers
"""
return foo + barRules for classes and modulesAs PEP 257 says, the docstrings of classes should document their attributes, and the docstrings of modules should shortly document the exported functions/variables/etc. See for example the pydoc output for the os or ConfigParser standard modules. |
Sign in to add a comment
