Skip to content

Commit

Permalink
Add module and function docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
gromero committed Oct 24, 2021
1 parent 2ff3d80 commit 3771745
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions python/tvm/driver/tvmc/fmtopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit 3771745

Please sign in to comment.