import pathlib


def find_modules(module_dir):
    """Given a folder, recursively find all the module files to right the documentation
    for.

    :param module_dir: The folder to start the search in
    :type module_dir: str
    """

    root = pathlib.Path(module_dir)
    modules = []

    for path in root.glob("**/*.py"):

        if path.name == "__init__.py":
            path = path.parent

        module = str(path).replace(".py", "").replace("/", ".")
        modules.append(module)

    return modules