Nyhilo / Duck-Disciple-Bot

A bot for adding helpful tools to the Infinite Nomic discord
http://nomic.gay
MIT License
3 stars 2 forks source link

Add docstrings and type annotations to functions/methods #85

Open Nyhilo opened 2 years ago

Nyhilo commented 2 years ago

This project has essentially become a portfolio project at this point. As such, it should be up to date with good documentation practices.

Add docstrings and type hints/annotations to as many functions and methods as reasonable. These docstrings should be formatted using the reST/Sphinx format, with a personal style caveat for multi-line parameter definitions. Docstrings should use triple-quotes (""") to differentiate them from code-relevant strings. The first line of the docstring should come after the opening triple-quote.

The definitions of all parameters should be tabbed over so they line up visually with each other. If a parameter definition would run longer than a single line, the next line should be a hanging indent that is tabbed over a single additional space. This is non-standard practice for python, but I like it a whole lot.

Example:

    def some_method(self, abcdef: str, abc: str, abcd: str) -> str:
        """
        The first line of this docstring comes after the opening quote. This
        example docstring is for a class method, so our line length should be
        is limited to (79 - 8) = 71 characters.

        :param abcdef: This is a normal-length parameter.
        :param abc:    This definition is tabbed over to align with the above.
        :param abcd:   This parameter definition aligns with the above, and is
                        also long enough that it justifies additional lines
                        beneath the initial. Note that these additional lines
                        are tabbed over an extra space for visual clarity.
        :return:       This is a description of what this method returns. Note
                        that it also follows the additional line indentation
                        standard, which has good visual clarity from the
                        previous block of text.
        """

Consider making a style- or pull-request guidelines document in this project that outlines the above, as well as any other standards that are desired for this project.