'Constructor.
Args:
func: The function to parse the docstring for.'

def __init__(self, func):

    self._state = self.State.short
    self._cur_arg_name = None
    self._short_desc_parts = []
    self._long_desc_parts = []
    self.arg_descs = collections.OrderedDict()
    doc = inspect.getdoc(func)
    handlers = {self.State.short: self._parse_short, self.State.desc: self._parse_desc, self.State.desc_hidden: self._skip, self.State.arg_start: self._parse_arg_start, self.State.arg_inside: self._parse_arg_inside, self.State.misc: self._skip}
    if (doc is None):
        if (sys.flags.optimize < 2):
            log.commands.warning('Function    {}()    from    {}    has    no    docstring'.format(utils.qualname(func), inspect.getsourcefile(func)))
        self.long_desc = ''
        self.short_desc = ''
        return
    for line in doc.splitlines():
        handler = handlers[self._state]
        stop = handler(line)
        if stop:
            break
    for (k, v) in self.arg_descs.items():
        desc = '    '.join(v)
        desc = re.sub(',    or    None($|\\.)', '\\1', desc)
        desc = re.sub(',    or    None', ',    or    not    given', desc)
        self.arg_descs[k] = desc
    self.long_desc = '    '.join(self._long_desc_parts)
    self.short_desc = '    '.join(self._short_desc_parts)
