Skip to content

Commit 546d014

Browse files
authored
docs: allow overriding cleaned directories (#199)
* docs: allow overriding cleaned directories * Satisfy linter
1 parent b1fc2be commit 546d014

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

spin/cmds/meson.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,16 @@ def run(ctx, *, args):
767767
)
768768
@click.option("--jobs", "-j", default="auto", help="Number of parallel build jobs")
769769
@click.pass_context
770-
def docs(ctx, *, sphinx_target, clean, first_build, jobs, sphinx_gallery_plot):
770+
def docs(
771+
ctx,
772+
*,
773+
sphinx_target,
774+
clean,
775+
first_build,
776+
jobs,
777+
sphinx_gallery_plot,
778+
clean_dirs=None,
779+
):
771780
"""📖 Build Sphinx documentation
772781
773782
By default, SPHINXOPTS="-W", raising errors on warnings.
@@ -799,13 +808,18 @@ def docs(ctx, *, sphinx_target, clean, first_build, jobs, sphinx_gallery_plot):
799808
sphinx_target = "help"
800809

801810
if clean:
802-
doc_dirs = [
803-
f"./{doc_dir}/build/",
804-
f"./{doc_dir}/source/api/",
805-
f"./{doc_dir}/source/auto_examples/",
806-
f"./{doc_dir}/source/jupyterlite_contents/",
807-
]
808-
for target_dir in doc_dirs:
811+
if clean_dirs is None:
812+
clean_dirs = []
813+
for prefix in ("", "_"):
814+
clean_dirs += [
815+
f"./{doc_dir}/{prefix}build/",
816+
f"./{doc_dir}/{prefix}build/",
817+
f"./{doc_dir}/{prefix}source/api/",
818+
f"./{doc_dir}/{prefix}source/auto_examples/",
819+
f"./{doc_dir}/{prefix}source/jupyterlite_contents/",
820+
]
821+
822+
for target_dir in clean_dirs:
809823
if os.path.isdir(target_dir):
810824
print(f"Removing {target_dir!r}")
811825
shutil.rmtree(target_dir)

0 commit comments

Comments
 (0)