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:
- RestructuredText (rst) for docutils. You don’t have to use Sphinx to generate HTML. You can keep it as lightweight as you like.
- epytext format. (see also: epydoc fields documentation)
- plain text. This offers nothing in terms of parameter or return value hooks. PyCharm will only show the plain docstring.
- [Django]-Django-Userena: adding extra non-null fields to a user's profile
- [Django]-Weird error with – python manage.py runserver (Exception in thread django-main-thread)
Source:stackexchange.com