From 21ca88ced000c80d0c3a7fe850b64dcb8e804ebf Mon Sep 17 00:00:00 2001 From: David Tulloh Date: Thu, 20 Jun 2024 13:42:13 +1000 Subject: [PATCH] Sphinx may not generate an api folder Fix a bug for simple projects where sphinx does not generate a docs/build/html/api/ folder. Without this fix the rename fails because the output_path does not exist. --- pydoctor/sphinx_ext/build_apidocs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydoctor/sphinx_ext/build_apidocs.py b/pydoctor/sphinx_ext/build_apidocs.py index 1247e0071..79e85025d 100644 --- a/pydoctor/sphinx_ext/build_apidocs.py +++ b/pydoctor/sphinx_ext/build_apidocs.py @@ -67,7 +67,8 @@ def on_build_finished(app: Sphinx, exception: Exception) -> None: temp_path = output_path.with_suffix('.pydoctor_temp') shutil.rmtree(sphinx_files, ignore_errors=True) - output_path.rename(sphinx_files) + if output_path.exists(): + output_path.rename(sphinx_files) temp_path.rename(output_path)