Support Markdown/Notebook-Friendly Documentation Export for Downstream Integration (#18131)
Co-authored-by: 赵晨阳 <zhaochen20@outlook.com>
This commit is contained in:
@@ -38,6 +38,26 @@ compile:
|
||||
echo "Total execution time: $${TOTAL_ELAPSED}s" >> logs/timing.log; \
|
||||
echo "All Notebook execution timings:" && cat logs/timing.log
|
||||
|
||||
# Convert Notebook files to Markdown artifacts (no execution)
|
||||
markdown:
|
||||
@set -e; \
|
||||
echo "Exporting notebooks to Markdown..."; \
|
||||
mkdir -p "$(BUILDDIR)/html/markdown"; \
|
||||
find $(SOURCEDIR) -path "*/_build/*" -prune -o -name "*.ipynb" -print0 | \
|
||||
parallel -0 -j3 --halt soon,fail=1 ' \
|
||||
NB_SRC="{}"; \
|
||||
REL_DIR=$$(dirname "$$NB_SRC"); \
|
||||
NB_NAME=$$(basename "$$NB_SRC"); \
|
||||
NB_BASE=$${NB_NAME%.ipynb}; \
|
||||
OUT_DIR="$(BUILDDIR)/html/markdown/$$REL_DIR"; \
|
||||
mkdir -p "$$OUT_DIR"; \
|
||||
jupyter nbconvert --to markdown "$$NB_SRC" \
|
||||
--output "$$NB_BASE.md" \
|
||||
--output-dir "$$OUT_DIR" \
|
||||
>/dev/null; \
|
||||
' || exit 1; \
|
||||
echo "Markdown artifacts written to: $(BUILDDIR)/html/markdown"
|
||||
|
||||
# Serve documentation with auto-build and live reload
|
||||
serve:
|
||||
@echo "Starting auto-build server at http://0.0.0.0:$(PORT)"
|
||||
|
||||
Reference in New Issue
Block a user