def METHOD_NAME(path: str) -> bool:
    assert path[-3:].lower() == ".py", "Can only run literate on python (*.py) files."
    with open(path, "r") as file:
        output_path = get_literate_output_path(file)
        if output_path is None:
            return False
        output_lines = [
            f"<!-- DO NOT EDIT THIS FILE. --> ",
            f"<!-- THIS FILE WAS AUTOGENERATED FROM"
            f" 'ALLENACT_BASE_DIR/{os.path.relpath(path, ABS_PATH_OF_TOP_LEVEL_DIR)}', EDIT IT INSTEAD. -->\n",
        ]
        md_lines: List[str] = []
        code_lines = md_lines
        lines = file.readlines()
        mode = None
        for line in lines:
            line = line.rstrip()
            stripped_line = line.strip()
            if (mode is None or mode == "change") and line.strip() == "":
                continue
            if mode == "markdown":
                if stripped_line in ['"""', "'''"]:
                    output_lines.extend(_strip_empty_lines(md_lines) + [""])
                    md_lines.clear()
                    mode = None
                elif stripped_line.endswith(('"""', "'''")):
                    output_lines.extend(
                        _strip_empty_lines(md_lines) + [stripped_line[:-3]]
                    )
                    md_lines.clear()
                    mode = None
                    # TODO: Does not account for the case where a string is ended with a comment.
                else:
                    md_lines.append(line.strip())
            elif stripped_line.startswith(("# %%", "#%%")):
                last_mode = mode
                mode = "change"
                if last_mode == "code":
                    output_lines.extend(
                        ["```python"] + _strip_empty_lines(code_lines) + ["```"]
                    )
                    code_lines.clear()
                if " import " in stripped_line:
                    path = stripped_line.split(" import ")[-1].strip()
                    output_lines.append(
                        "```python\n" + source_to_markdown(path) + "\n```"
                    )
                elif " import_summary " in stripped_line:
                    path = stripped_line.split(" import_summary ")[-1].strip()
                    output_lines.append(
                        "```python\n"
                        + source_to_markdown(path, summarize=True)
                        + "\n```"
                    )
                elif " hide" in stripped_line:
                    mode = "hide"
            elif mode == "hide":
                continue
            elif mode == "change":
                if stripped_line.startswith(('"""', "'''")):
                    mode = "markdown"
                    if len(stripped_line) != 3:
                        if stripped_line.endswith(('"""', "'''")):
                            output_lines.append(stripped_line[3:-3])
                            mode = "change"
                        else:
                            output_lines.append(stripped_line[3:])
                else:
                    mode = "code"
                    code_lines.append(line)
            elif mode == "code":
                code_lines.append(line)
            else:
                raise NotImplementedError(
                    f"mode {mode} is not implemented. Last 5 lines: "
                    + "\n".join(output_lines[-5:])
                )
        if mode == "code" and len(code_lines) != 0:
            output_lines.extend(
                ["```python"] + _strip_empty_lines(code_lines) + ["```"]
            )
    with open(output_path, "w") as f:
        f.writelines([l + "\n" for l in output_lines])
    return True