Z
Z
zelsky2016-10-14 16:58:52
Django
zelsky, 2016-10-14 16:58:52

Documentation/comments in Django?

Is there any style guide on how to comment classes correctly and what to write there? They did a code review for me, and so here is an example of a comment, as is approximately clear. But if the style guide?

"""
        Check if current user role matches to given.
        @:param role: user role.
        @:type role: int.
        @:rtype bool.
        @:return True if user matches given role. Else returns false.
        """

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-10-14
@zelsky

There are style guides and formats.
Official guide: PEP 257
Everything else there is IDE convenience. I see your format for the first time, they usually use reST for PyCharm.

"""
Описание, что делает метод/функция

:param param1: Что за параметр принимается
:param param2: Ещё один параметр, который принимается
:returns: Какое значение возвращается
:raises KeyError: В каком случае рейзится эта ошибка
"""

All this makes sense, there is a really big project and it is planned to support it with a whole camp for a long time. Otherwise, it's a waste of time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question