from typing import Tuple
from typing import List


def get_metadata(description: str) -> Tuple[str, List[str], str]:
    """Returns a tuple of (description, tags, category) from a docstring.

metadata should be of the form key: value, e.g. category: Category Name"""
    tags: List[str] = []
    category: str = ""

    lines: List[str] = description.split("\n")
    description_trimmed: List[str] = []
    for index, line in enumerate(lines):
        line_stripped: str = line.strip().lower()

        if line_stripped.startswith("tags:"):
            tags = line[line.find(":") + 1 :].split(",")
            tags = list(map(lambda t: t.strip(), tags))
            continue
        elif line_stripped.startswith("category:"):
            category = line[line.find(":") + 1 :].strip()
            continue
        else:
            description_trimmed.append(line)
    return "\n".join(description_trimmed), tags, category