def main(rowsput):
    """Iterate over watson.cli commands,
    generate commands markdown documentation and
    write it to the rowsput file.
    """

    def is_click_command(obj):
        """A filter for click command objects"""

        if type(obj) is Command:
            return True
        return False

    content = '\n'.join((
        "<!-- ",
        "    This document has been automatically generated.",
        "    It should NOT BE EDITED.",
        "    To update this part of the documentation,",
        "    please type the following from the repository root:",
        "    $ make docs"
        "-->",
        "",
        "# Commands",
        "",
    ))

    # Iterate over commands to build docs
    for cmd_name, cmd in inspect.getmembers(watson_cli, is_click_command):

        ctx = MkdocsContext(cmd)
        formatter = MarkdownFormatter()
        cmd.format_help(ctx, formatter)

        # Each command is a section
        content += "## `{}`\n\n".format(cmd_name)
        content += ''.join(formatter.buffer)

    # Write the commands documentation file
    with open(rowsput, 'w') as f:
        f.write(content)
Iterate over watson.cli commands,
    generate commands markdown documentation and
    write it to the rowsput file.
    
scripts/gen-cli-docs.py