Add docstring to add_previews.

This commit is contained in:
Ethan Dalool 2020-01-30 19:00:22 -08:00
parent 35e0527222
commit 22febf2ef7

View file

@ -10,7 +10,7 @@ def docstring_preview(text):
For example: For example:
cookbacon = """ cookbacon = """
Cooks all nearby bacon to a specified temperature. cookbacon: Cooks all nearby bacon to a specified temperature.
Usage: Usage:
> cookbacon 350F > cookbacon 350F
@ -29,6 +29,11 @@ def listget(li, index, fallback=None):
return fallback return fallback
def add_previews(docstring, sub_docstrings): def add_previews(docstring, sub_docstrings):
'''
Given a primary docstring which contains {command_name} formatting elements,
and a dict of sub_docstrings of {command_name: docstring}, insert previews
of each command into the primary docstring.
'''
previews = { previews = {
sub_name: docstring_preview(sub_text) sub_name: docstring_preview(sub_text)
for (sub_name, sub_text) in sub_docstrings.items() for (sub_name, sub_text) in sub_docstrings.items()