Skip to content

Commit

Permalink
changed to get_doc function, since that makes use simpler
Browse files Browse the repository at this point in the history
commit right version this time :-)

Changed implementation to now return the doc correctly, test with `mx help unittest`

typo fix
  • Loading branch information
JornVernee committed Nov 12, 2018
1 parent b4ceab6 commit 6caf618
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
11 changes: 1 addition & 10 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13654,16 +13654,7 @@ def help_(args):
abort('mx: command \'{0}\' is ambiguous\n {1}'.format(name, ' '.join(hits)))

command = _mx_commands.commands()[name]
doc = command.command_function.__doc__
if command.has_documentation():
format_args = []
if command.usage_msg:
format_args.append(command.usage_msg)
if command.doc_function:
format_args.append(command.doc_function())

doc = doc.format(*format_args)
print 'mx {0} {1}\n\n{2}\n'.format(name, command.usage_msg, doc)
print '\nmx {0} {1}\n\n{2}\n'.format(name, command.usage_msg, command.get_doc())

def _parse_multireleasejar_version(value):
try:
Expand Down
6 changes: 4 additions & 2 deletions mx_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ def __init__(self, mx_commands, command_function, suite_name, command, usage_msg
def command_function(self):
return self._command_function

def has_documentation(self):
return self.doc_function != None
def get_doc(self):
if self.doc_function:
return self.doc_function()
return '<no documentation>'

def __call__(self, *args, **kwargs):
for callback in self._mx_commands.command_before_callbacks:
Expand Down
3 changes: 1 addition & 2 deletions mx_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def _run_vm(vmArgs, mainClass, mainClassArgs):
os.remove(testfile)

unittestHelpSuffix = """
To avoid conflicts with VM options '--' can be used as delimiter.
If test filters are supplied, only tests whose fully qualified name
Expand Down Expand Up @@ -351,7 +350,7 @@ def is_strictly_positive(value):
@mx.command(suite_name="mx",
command_name='unittest',
usage_msg='[unittest options] [--] [VM options] [filters...]',
doc_function=unittestHelpSuffix,
doc_function=lambda: unittestHelpSuffix,
auto_add=False)
def unittest(args):
"""run the JUnit tests"""
Expand Down

0 comments on commit 6caf618

Please sign in to comment.