def METHOD_NAME(rucio_src: str):
    RenderParams = namedtuple("RenderParams", ["title", "fh", "args", "out_file"])
    def render_done(par: RenderParams):
        def inner(cmd, success, exit_code):
            if success:
                print(f"{par.title} doc was generated to {par.out_file}")
            else:
                print(f"Error running {cmd}\n  exit code: {exit_code}")
        return inner
    def print_line(par: RenderParams):
        def inner(line: str):
            print(escape_doc_line(line), end="", file=par.fh)
        return inner
    def render(params: list[RenderParams]):
        python = sys.executable
        if not python:
            python = "python3"
        python = sh.Command(python)
        procs = []
        for par in params:
            print("Adding header for", par.title)
            print("---", file=par.fh)
            print("title:", par.title, file=par.fh)
            print("---", file=par.fh)
            print(file=par.fh)
            print("Rendering", par.title)
            procs.append(
                python(
                    "-m",
                    "pydoc_markdown.main",
                    *par.args,
                    "--render-toc",
                    _out=print_line(par),
                    _bg=True,
                    _done=render_done(par),
                )
            )
        for handle in procs:
            with CommandErrorWrapper(procs):
                handle.wait(timeout=60)
    def create_parent_directory(file: str):
        directory = os.path.dirname(file)
        if directory:
            try:
                os.mkdir(directory, mode=0o755)
            except FileExistsError:
                pass  # ignore existing
    lib_path = os.path.join(rucio_src, "lib")
    client_module_path = pathlib.Path(lib_path, "rucio/client")
    client_module_excludes = {"__pycache__", "__init__", "dq2client"}
    client_modules = [
        module_path.with_suffix("").name
        for module_path in client_module_path.iterdir()
        if module_path.with_suffix("").name not in client_module_excludes
    ]
    client_modules_args = list(itertools.chain(*(("--module", "rucio.client." + mod) for mod in client_modules)))
    client_api_output_file = os.environ.get("RUCIO_CLIENT_API_OUTPUT", default="docs/rucio_client_api.md")
    create_parent_directory(client_api_output_file)
    rest_api_path = os.path.join(lib_path, "rucio/web/rest/flaskapi/v1/")
    rest_api_output_file = os.environ.get("RUCIO_REST_API_OUTPUT", default="docs/rucio_rest_api.md")
    create_parent_directory(rest_api_output_file)
    with open(client_api_output_file, "w") as client_api_fh, open(rest_api_output_file, "w") as rest_api_fh:
        render(
            [
                RenderParams(
                    title="Rucio client API",
                    fh=client_api_fh,
                    args=("--search-path", lib_path, *client_modules_args),
                    out_file=client_api_output_file,
                ),
                RenderParams(
                    title="Rucio REST API",
                    fh=rest_api_fh,
                    args=("--search-path", rest_api_path),
                    out_file=rest_api_output_file,
                ),
            ]
        )