def decorate(name, type):
    """
    Decorate a parameter.
    >>> decorate("FOO", "arg")
    'FOO'
    >>> decorate("FOO", "flag")
    '[FOO]'
    >>> decorate("FOO", "param")
    '[FOO <foo>]'
    >>> decorate("FOO", "group")
    '[FOO <foo> ...]'
    >>> decorate("foo", "argn")
    '[<foo> ...]'
    """
    if type == "arg":
        return name
    elif type == "flag":
        return "[%s]" % name
    elif type == "param":
        return "[%s <%s>]" % (name, name.lower())
    elif type == "group":
        return "[%s <%s> ...]" % (name, name.lower())
    elif type == "argn":
        return "[<%s> ...]" % (name)
    elif type == "example":
        # \example is handled by gen_example_rst
        return None
    return None