From 895a22335941f78430879afc17bd547304cc2503 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 30 Jan 2020 18:52:02 -0800 Subject: [PATCH] Add docstring to docstring_preview. --- voussoirkit/betterhelp.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/voussoirkit/betterhelp.py b/voussoirkit/betterhelp.py index b77f627..af4f050 100644 --- a/voussoirkit/betterhelp.py +++ b/voussoirkit/betterhelp.py @@ -4,6 +4,21 @@ import textwrap HELPSTRINGS = {'', 'help', '-h', '--help'} def docstring_preview(text): + ''' + This function assumes that your docstring is formatted with a single blank + line separating the command's primary summary and the rest of the text. + For example: + + cookbacon = """ + Cooks all nearby bacon to a specified temperature. + + Usage: + > cookbacon 350F + > cookbacon 175C + """ + + and will return the first portion. + ''' text = text.split('\n\n')[0].strip() return text