Support Markdown/Notebook-Friendly Documentation Export for Downstream Integration (copy all markdown and rst files) (#18223)
This commit is contained in:
+15
-1
@@ -41,8 +41,20 @@ compile:
|
|||||||
# Convert Notebook files to Markdown artifacts (no execution)
|
# Convert Notebook files to Markdown artifacts (no execution)
|
||||||
markdown:
|
markdown:
|
||||||
@set -e; \
|
@set -e; \
|
||||||
echo "Exporting notebooks to Markdown..."; \
|
echo "Exporting docs to Markdown..."; \
|
||||||
mkdir -p "$(BUILDDIR)/html/markdown"; \
|
mkdir -p "$(BUILDDIR)/html/markdown"; \
|
||||||
|
\
|
||||||
|
# 1) Copy .md and .rst files under subdirectories only (exclude root-level files) \
|
||||||
|
find $(SOURCEDIR) -mindepth 2 -path "*/_build/*" -prune -o \( -name "*.md" -o -name "*.rst" \) -print0 | \
|
||||||
|
parallel -0 -j3 --halt soon,fail=1 ' \
|
||||||
|
SRC="{}"; \
|
||||||
|
REL_DIR=$$(dirname "$$SRC"); \
|
||||||
|
OUT_DIR="$(BUILDDIR)/html/markdown/$$REL_DIR"; \
|
||||||
|
mkdir -p "$$OUT_DIR"; \
|
||||||
|
cp -f "$$SRC" "$$OUT_DIR/"; \
|
||||||
|
' || exit 1; \
|
||||||
|
\
|
||||||
|
# 2) Convert .ipynb -> .md (all notebooks, including root if any) \
|
||||||
find $(SOURCEDIR) -path "*/_build/*" -prune -o -name "*.ipynb" -print0 | \
|
find $(SOURCEDIR) -path "*/_build/*" -prune -o -name "*.ipynb" -print0 | \
|
||||||
parallel -0 -j3 --halt soon,fail=1 ' \
|
parallel -0 -j3 --halt soon,fail=1 ' \
|
||||||
NB_SRC="{}"; \
|
NB_SRC="{}"; \
|
||||||
@@ -56,8 +68,10 @@ markdown:
|
|||||||
--output-dir "$$OUT_DIR" \
|
--output-dir "$$OUT_DIR" \
|
||||||
>/dev/null; \
|
>/dev/null; \
|
||||||
' || exit 1; \
|
' || exit 1; \
|
||||||
|
\
|
||||||
echo "Markdown artifacts written to: $(BUILDDIR)/html/markdown"
|
echo "Markdown artifacts written to: $(BUILDDIR)/html/markdown"
|
||||||
|
|
||||||
|
|
||||||
# Serve documentation with auto-build and live reload
|
# Serve documentation with auto-build and live reload
|
||||||
serve:
|
serve:
|
||||||
@echo "Starting auto-build server at http://0.0.0.0:$(PORT)"
|
@echo "Starting auto-build server at http://0.0.0.0:$(PORT)"
|
||||||
|
|||||||
Reference in New Issue
Block a user