3

I've been using reST style docstrings for a while, but I was browsing through the sphinx docs again to refresh my memory and realized that I'm not quite sure if there's a "standardized" way to document the side effects of a function. For instance, if we have this stripped-down example function:

def HandleMsgFromClient(my_list, my_int):
    '''
    Called when a msg is received from the client
    :param my_list: a list holding some info
    :param my_int: the int received from the client
    '''
    if my_int > 0:
        my_list.append(':)')
    elif my_int < 0:
        my_list.append(':(')
    else:
        my_list.append(':/')

Should the side effect of adding something to my_list be included in the summary line? In the expanded explanation on the next line? Maybe in a :meta: field? Is it possible to highlight the side effect in the same way that we can highlight a parameter, return value, or their types? What's considered best practice to document the side effects of a function in this style?

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Pacopenguin
  • 194
  • 1
  • 9

0 Answers0