Extract the text from the various sections of a numpy-formatted docstring.

        Parameters
        ----------
        doc: Union[str, None]
            The docstring to parse.

        style: str
            'google' or 'numpy'

        Returns
        -------
        OrderedDict[str, Union[None,str]]
            The extracted numpy-styled docstring sections.

def parse_napoleon_doc(doc, style):
    """ Extract the text from the various sections of a numpy-formatted docstring.

        Parameters
        ----------
        doc: Union[str, None]
            The docstring to parse.

        style: str
            'google' or 'numpy'

        Returns
        -------
        OrderedDict[str, Union[None,str]]
            The extracted numpy-styled docstring sections."""

    napoleon_sections = ["Short Summary", "Attributes", "Methods", "Warning", "Note", "Parameters", "Other Parameters",
                         "Keyword Arguments", "Returns", "Yields", "Raises", "Warns", "See Also", "References", "Todo",
                         "Example", "Examples"]

    aliases = {"Args": "Parameters", "Arguments": "Parameters", "Keyword Args": "Keyword Arguments",
               "Return": "Returns", "Warnings": "Warning", "Yield": "Yields"}

    doc_sections = OrderedDict([(key, None) for key in napoleon_sections])

    if not doc:
        return doc_sections

    assert style in ("google", "numpy")

    doc = cleandoc(doc)
    lines = iter(doc.splitlines())

    key = "Short Summary"
    body = []
    while True:
        try:
            line = next(lines).rstrip()
            header = line if style == "numpy" else (line[:-1] if line.endswith(":") else line)
            if header and (header in doc_sections or header in aliases):
                doc_sections[aliases.get(key, key)] = "\n".join(body).rstrip() if body else None
                body = []
                key = header
                if style == "numpy":
                    next(lines)  # skip section delimiter
            else:
                body.append(line)
        except StopIteration:
            doc_sections[aliases.get(key, key)] = "\n".join(body)
            break
    return doc_sections