Support Markdown/Notebook-Friendly Documentation Export for Downstream Integration(convert rat files to md files and save) (#18278)

This commit is contained in:
Kun Lin
2026-02-04 19:59:40 -08:00
committed by GitHub
parent de6a03260f
commit e616d35847
+9 -3
View File
@@ -44,17 +44,22 @@ markdown:
echo "Exporting docs to 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 | \
# 1) Copy .md and .rst files as-is; additionally convert .rst -> .md \
find $(SOURCEDIR) -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/"; \
case "$$SRC" in \
*.rst) \
BASE=$$(basename "$$SRC" .rst); \
pandoc -f rst -t gfm "$$SRC" -o "$$OUT_DIR/$$BASE.md" ;; \
esac \
' || exit 1; \
\
# 2) Convert .ipynb -> .md (all notebooks, including root if any) \
# 2) Convert .ipynb -> .md \
find $(SOURCEDIR) -path "*/_build/*" -prune -o -name "*.ipynb" -print0 | \
parallel -0 -j3 --halt soon,fail=1 ' \
NB_SRC="{}"; \
@@ -72,6 +77,7 @@ markdown:
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)"