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`
This commit is contained in:
Erick Friis 2024-11-18 14:09:16 -08:00 committed by GitHub
parent 018f4102f4
commit cbeb8601d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -38,7 +38,7 @@ install-py-deps:
generate-files: generate-files:
mkdir -p $(INTERMEDIATE_DIR) mkdir -p $(INTERMEDIATE_DIR)
cp -r $(SOURCE_DIR)/* $(INTERMEDIATE_DIR) cp -rp $(SOURCE_DIR)/* $(INTERMEDIATE_DIR)
$(PYTHON) scripts/tool_feat_table.py $(INTERMEDIATE_DIR) $(PYTHON) scripts/tool_feat_table.py $(INTERMEDIATE_DIR)

View File

@ -184,7 +184,18 @@ if __name__ == "__main__":
source_paths_stripped = [p.strip() for p in source_path_strs] 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] source_paths = [intermediate_docs_dir / p for p in source_paths_stripped if p]
else: 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: with multiprocessing.Pool() as pool:
pool.map( pool.map(