From 7db4fd8749e7606bd6dc6fb50392df3b5c47f23b Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 31 Oct 2024 23:50:16 +0900 Subject: [PATCH] Add a docstring --- src/sage_docbuild/conf.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 7ab0e036cca..88cd836b52c 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -919,9 +919,17 @@ class will be properly documented inside its surrounding class. return skip def clean_jupyter_execute(app, exception): - jupyter_execute_path = os.path.join(app.outdir, 'jupyter_execute') - if os.path.exists(jupyter_execute_path): - shutil.rmtree(jupyter_execute_path) + """ + If there was no exception during the doc build, we remove the useless + ``jupyter_execute`` directory, which would only bloat the doc tree. + + If there was an exception, the ``jupyter_execute`` directory may be useful + for debugging and hence we don't remove it. + """ + if exception is None: # only proceed if there were no build errors + jupyter_execute_path = os.path.join(app.outdir, 'jupyter_execute') + if os.path.exists(jupyter_execute_path): + shutil.rmtree(jupyter_execute_path) class SagecodeTransform(SphinxTransform):