Skip to content

Commit

Permalink
mconf: Limit the line length of the choices column
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda authored and jpakkane committed Feb 17, 2019
1 parent 683c768 commit ea1ad71
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mesonbuild/mconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, build_dir):
if 'meson.build' in [os.path.basename(self.build_dir), self.build_dir]:
self.build_dir = os.path.dirname(self.build_dir)
self.build = None
self.max_choices_line_length = 60

if os.path.isdir(os.path.join(self.build_dir, 'meson-private')):
self.build = build.load(self.build_dir)
Expand Down Expand Up @@ -100,7 +101,20 @@ def print_aligned(self, arr):
if opt['choices']:
choices_found = True
if isinstance(opt['choices'], list):
choices_col.append('[{0}]'.format(', '.join(make_lower_case(opt['choices']))))
choices_list = make_lower_case(opt['choices'])
current = '['
while choices_list:
i = choices_list.pop(0)
if len(current) + len(i) >= self.max_choices_line_length:
choices_col.append(current + ',')
name_col.append('')
value_col.append('')
descr_col.append('')
current = ' '
if len(current) > 1:
current += ', '
current += i
choices_col.append(current + ']')
else:
choices_col.append(make_lower_case(opt['choices']))
else:
Expand Down

0 comments on commit ea1ad71

Please sign in to comment.