From cbeb8601d6b3429b75b4a9226e2a8775679b331c Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Mon, 18 Nov 2024 14:09:16 -0800 Subject: [PATCH] docs: efficient rebuild (#28195) if you run `make build start` in one tab, then start editing files, you can efficient rebuild notebooks with `make generate-files md-sync render` --- docs/Makefile | 2 +- docs/scripts/notebook_convert.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index fabed9f041ac5..a3c41260e3dd0 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -38,7 +38,7 @@ install-py-deps: generate-files: mkdir -p $(INTERMEDIATE_DIR) - cp -r $(SOURCE_DIR)/* $(INTERMEDIATE_DIR) + cp -rp $(SOURCE_DIR)/* $(INTERMEDIATE_DIR) $(PYTHON) scripts/tool_feat_table.py $(INTERMEDIATE_DIR) diff --git a/docs/scripts/notebook_convert.py b/docs/scripts/notebook_convert.py index 02b83f8032839..429734f115817 100644 --- a/docs/scripts/notebook_convert.py +++ b/docs/scripts/notebook_convert.py @@ -184,7 +184,18 @@ def _convert_notebook( source_paths_stripped = [p.strip() for p in source_path_strs] source_paths = [intermediate_docs_dir / p for p in source_paths_stripped if p] else: - source_paths = intermediate_docs_dir.glob("**/*.ipynb") + original_paths = list(intermediate_docs_dir.glob("**/*.ipynb")) + # exclude files that exist in output directory and are newer + relative_paths = [p.relative_to(intermediate_docs_dir) for p in original_paths] + out_paths = [ + output_docs_dir / p.parent / (p.stem + ".md") for p in relative_paths + ] + source_paths = [ + p + for p, o in zip(original_paths, out_paths) + if not o.exists() or o.stat().st_mtime < p.stat().st_mtime + ] + print(f"rebuilding {len(source_paths)}/{len(relative_paths)} notebooks") with multiprocessing.Pool() as pool: pool.map(