TesterNick / Textual-Minesweeper

2 stars 1 forks source link

Code issue: use docstrings instead of plain comments #7

Open earshinov opened 6 years ago

earshinov commented 6 years ago

Functions in the code are already well documented, but I think it would be nice to add some structure to the comments.

First of all, I think it is worth to convert them to docstrings. At least there will be a better chance that your IDE / text editor shows these comments is documentation popups.

Second, in case when arguments and return values are documented, this documentation is at the moment mixed with the summary of the function. For instance:

# Opens cells and changes data arrays. Returns False if player died and True otherwise.
def check_cell(x, y):
    # ...

I would suggest documenting arguments and return values in separate blocks like people do in Google. Applying this suggestion for the example above will give:

def check_cell(x, y):
    """Opens cells and changes data arrays.

    Returns: False if player died and True otherwise.
    """
    # ...

This docstring may seem too long and clumsy, but the "Returns" block really stands out, which makes it easier to find the information you are looking for.