:orphan: .. _docs/contrib/05_documenting_code/documenting-code: Documenting Code ================ When developing a new class or function, or improving current classes in ``pySDC``\ , adding Python docstring to document the code is important, in particular : * to help developer understanding how classes and functions work when reading the code * to help user understanding how classes and functions work when reading the `documentation `_ ``pySDC`` follows the `NumPy Style Python Docstring `_\ , below is simplified example for a class and a function : .. |:bell:| Don't document the ``init`` function, but rather the class itself. Also describe parameters (given to the ``__init__``\ ) and attributes (stored into the class) separately. .. code-block:: python class LagrangeApproximation(object): r""" Class approximating any function on a given set of points using barycentric Lagrange interpolation. Let note :math:`(t_j)_{0\leq j`_. Parameters ---------- points : list, tuple or np.1darray The given interpolation points, no specific scaling, but must be ordered in increasing order. Attributes ---------- points : np.1darray The interpolating points weights : np.1darray The associated barycentric weights """ def __init__(self, points): pass # Implementation ... @property def n(self): """Number of points""" pass # Implementation ... def getInterpolationMatrix(self, times): r""" Compute the interpolation matrix for a given set of discrete "time" points. For instance, if we note :math:`\vec{f}` the vector containing the :math:`f_j=f(t_j)` values, and :math:`(\tau_m)_{0\leq m`_ |:arrow_left:| :doc:`Back to custom implementations <./04_custom_implementations>` --- |:arrow_up:| :doc:`Contributing Summary <./../../CONTRIBUTING>` --- |:arrow_right:| :doc:`Next to Adding a new project <./06_new_project>`