Here's our idea of a suitable Docstring for the banner_text function.
def banner_text(text: str = " ", screen_width: int = 80) -> None:
""" Print a string centred, with ** either side.
:param text: The string to print.
An asterisk (*) will result in a row of asterisks.
The default will print a blank line, with a ** border at
the left and right edges.
:param screen_width: The overall width to print within
(including the 4 spaces for the ** either side).
:raises ValueError: if the supplied string is too long to fit.
"""
if len(text) > screen_width - 4:
raise ValueError("String '{0}' is larger than specified width {1}"
.format(text, screen_width))
if text == "*":
print("*" * screen_width)
else:
centred_text = text.center(screen_width - 4)
output_string = "**{0}**".format(centred_text)
print(output_string)
Note that the return value shouldn't be documented. Even though Python automatically returns None, the function isn't intended to return a useful value.
We've included :raises ValueError: to document the function's behaviour, if the caller passes in a string that's too long to fit.