In this section, we will take a look at how to format docstrings for maximum readability and how to transform them into structured and formatted documentation. We're also going to look at how to make examples in the documentation testable so that the documentation is never out of date.
Getting the most out of docstrings
PEP 257 and docutils
PEP 257 documents the expectations of Python programmers and tools with respect to docstrings. The basic rules are quite simple. These are as follows:
The documentation is available at https://www.python.org/dev/peps/pep-0257/.
- Use triple quotes to delimit the docstring. Triple quotes are how Python expresses the idea of a multiline text string.
- The closing triple quotes should be...