[Django]-Documenting my Django code

2👍

I use IntellJ IDEA / PyCharm extensively on Django and plain Python projects.

The way to go is definitely reStructuredText and Sphinx, the latter only if you want to generate HTML or PDF documentation. This is also how the Python library itself is documented. I made the switch from epydoc to reStructuredText a few months ago due to much better general support of the latter.

Your docstring would look like this:

def myfunc(p1, p2, p3):
    """myfunc does something interesting.

    some more detail. See :meth:`my_other_func` for more information.

    :param p1: The first parameter.
    :type p1: string
    :param p2: The second parameter.
    :param p3: The third parameter.
    :returns: True if successful, False if not.
    """

    my_code(p1)
    more_code(p2)
    return third_part(p1,p2,p3)

It doesn’t differ all that much from the old epydoc standard for the basic elements. PyCharm is able to parse this information, for example making use of :type: specs to do completion in the body of your function.

1👍

As mentioned in the PyCharm webhelp on supported docstring formats you’ll have three options:

Leave a comment