Skip to content

Commit

Permalink
quote string defaults; handle len of default values
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGoldfarb committed Jan 11, 2022
1 parent 26d3def commit 9c32bf6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/mplfinance/_kwarg_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ def kwarg_help( func_name=None, kwarg_names=None ):
df = df[ df['Kwarg'].isin(kwarg_names) ]
if len(df) < 1:
raise ValueError(' None of specified `kwarg_names` are valid for `func_name` "'+func_name,'"')

df['Default'] = ["'"+d+"'" if isinstance(d,str) else str(d) for d in df['Default']]

wraplen = 80 - (df['Kwarg'].str.len().max()+1 + 8)
klen = df['Kwarg'].str.len().max()+1
dlen = df['Default'].str.len().max()+1

wraplen = 80 - ( klen + dlen )
df = df_wrapcols(df,wrap_columns={'Description':wraplen})

dividers = []
Expand All @@ -135,8 +140,8 @@ def kwarg_help( func_name=None, kwarg_names=None ):

df = dfd.append(df)

formatters = { 'Kwarg' : make_left_formatter(df['Kwarg'].str.len().max()+1),
'Default' : make_left_formatter( 8 ),
formatters = { 'Kwarg' : make_left_formatter( klen ),
'Default' : make_left_formatter( dlen ),
'Description' : make_left_formatter( wraplen ),
}

Expand Down

0 comments on commit 9c32bf6

Please sign in to comment.