I personally use the Google style python docstrings.
Example:
class Cat():
'''Retains information about a particular cat and performs cat-like actions
Note:
Cats are cute
Args:
color (str): Color of cat
legs (int): Number of legs a cat has
Attributes:
color (str): color of cat
count (int): Number of cats in existence
legs (int): Number of legs a cat has
'''
count = 0
def __init__(self, color, legs):
self.color = color
self.legs = legs
self.count += 1
def meow(self, times: int = 3):
'''Cat meows "times" times
A cat will meow "times" times in a row
Args:
times (int): Number of times to meow
Returns:
str: The string "meow" repeated a number of times as given. Each
meow is separated by a space.
Raises:
ValueError: If 'times' is not a positive integer
'''
if times < 1 or type(times) is not int:
raise ValueError('A cat must meow at least once!')
meow = "meow " * times
return meow
pdoc is an API documentation auto-generator. It can generate html documentation pages in a single line.
To install: pip3 install pdoc3
Usage: pdoc --html <File, Directory, or Package path>
--skip-errors
The html files will be saved in html/
If you want to use a linter to find code that could be written better (and pull out your hair while doing so) pylint is for you! To make you feel extra bad, pylint even gives you a score out of 10!
To install: pip3 install pylint
Usage: pylint <Directory or File>