From 377174558bd3adbf2f0ca4fbc00bec0abd9a1bb6 Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Sun, 24 Oct 2021 19:40:57 +0000 Subject: [PATCH] Add module and function docstrings --- python/tvm/driver/tvmc/fmtopt.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/python/tvm/driver/tvmc/fmtopt.py b/python/tvm/driver/tvmc/fmtopt.py index 2d318c9866973..7f27826d77bfb 100644 --- a/python/tvm/driver/tvmc/fmtopt.py +++ b/python/tvm/driver/tvmc/fmtopt.py @@ -14,7 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - +""" +Utils to format help text for project options. +""" from textwrap import TextWrapper @@ -33,7 +35,32 @@ def format_option(option_text, help_text, default_text, required=True): + """Format option name, choices, and default text into a single help text. + + Parameters + ---------- + options_text: str + String containing the option name and option's choices formatted as: + optname={opt0, opt1, ...} + + help_text: str + Help text string. + + default_text: str + Default text string. + + required: bool + Flag that controls if a "(required)" text mark needs to be added to the final help text to + inform if the option is a required one. + + Returns + ------- + help_text_just: str + Single justified help text formatted as: + optname={opt0, opt1, ... } + HELP_TEXT. "(required)" | "Defaults to 'DEFAULT'." + """ optname, choices_text = option_text.split("=", 1) # Prepare optname + choices text chunck. @@ -85,4 +112,5 @@ def format_option(option_text, help_text, default_text, required=True): if required: help_text_just_chunk += " (required)" - return choices_text_just_chunk + "\n" + help_text_just_chunk + help_text_just = choices_text_just_chunk + "\n" + help_text_just_chunk + return help_text_just