1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#!/bin/bash
#
# Creates the API documentation for igraph's Python interface
#
# Usage: ./mkdoc.sh (makes API and tutorial docs)
# ./mkdoc.sh -d (makes a Dash docset based on standalone docs, requires doc2dash)
#
# Add -c to ensure that the documentation is built from scratch and no cached
# assets from previous builds are used.
#
# Make sure we bail out on build errors
set -e
DOC2DASH=0
LINKCHECK=0
CLEAN=0
while getopts ":scjdl" OPTION; do
case $OPTION in
c)
CLEAN=1
;;
d)
DOC2DASH=1
;;
l)
LINKCHECK=1
;;
\?)
echo "Usage: $0 [-sjd]"
exit 1
;;
esac
done
shift $((OPTIND -1))
SCRIPTS_FOLDER=`dirname $0`
cd ${SCRIPTS_FOLDER}/..
ROOT_FOLDER=`pwd`
DOC_SOURCE_FOLDER=${ROOT_FOLDER}/doc/source
DOC_HTML_FOLDER=${ROOT_FOLDER}/doc/html
DOC_LINKCHECK_FOLDER=${ROOT_FOLDER}/doc/linkcheck
SCRIPTS_FOLDER=${ROOT_FOLDER}/scripts
cd ${ROOT_FOLDER}
# Create a virtual environment
if [ ! -d ".venv" ]; then
python3 -m venv .venv
# Install sphinx, matplotlib, pandas, scipy, wheel and pydoctor into the venv.
# doc2dash is optional; it will be installed when -d is given
.venv/bin/pip install -U pip wheel sphinx==7.4.7 matplotlib pandas scipy pydoctor sphinx-rtd-theme
fi
# Make sure that Sphinx, PyDoctor (and maybe doc2dash) are up-to-date in the virtualenv
.venv/bin/pip install -U sphinx==7.4.7 pydoctor sphinx-gallery sphinxcontrib-jquery sphinx-rtd-theme
if [ x$DOC2DASH = x1 ]; then
.venv/bin/pip install -U doc2dash
fi
echo "Removing existing igraph and python-igraph eggs from virtualenv..."
SITE_PACKAGES_DIR=`.venv/bin/python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`
rm -rf "${SITE_PACKAGES_DIR}"/igraph*.egg
rm -rf "${SITE_PACKAGES_DIR}"/igraph*.egg-link
rm -rf "${SITE_PACKAGES_DIR}"/python_igraph*.egg
rm -rf "${SITE_PACKAGES_DIR}"/python_igraph*.egg-link
echo "Installing igraph in virtualenv..."
rm -f dist/*.whl && .venv/bin/pip wheel -q -w dist . && .venv/bin/pip install -q --force-reinstall dist/*.whl
echo "Patching modularized Graph methods"
.venv/bin/python3 ${SCRIPTS_FOLDER}/patch_modularized_graph_methods.py
echo "Clean previous docs"
rm -rf "${DOC_HTML_FOLDER}"
if [ "x$CLEAN" = "x1" ]; then
# This is generated by sphinx-gallery
rm -rf "${DOC_SOURCE_FOLDER}/tutorials"
fi
if [ "x$LINKCHECK" = "x1" ]; then
echo "Check for broken links"
.venv/bin/python -m sphinx \
-T \
-b linkcheck \
-Dtemplates_path='' \
-Dhtml_theme='alabaster' \
${DOC_SOURCE_FOLDER} ${DOC_LINKCHECK_FOLDER}
fi
echo "Generating HTML documentation..."
.venv/bin/pip install -U sphinx-rtd-theme
.venv/bin/python -m sphinx -T -b html ${DOC_SOURCE_FOLDER} ${DOC_HTML_FOLDER}
echo "HTML documentation generated in ${DOC_HTML_FOLDER}"
# doc2dash
if [ "x$DOC2DASH" = "x1" ]; then
PWD=`pwd`
# Output folder of sphinx (before Jekyll if requested)
DOC_API_FOLDER=${ROOT_FOLDER}/doc/html/api
DOC2DASH=`which doc2dash 2>/dev/null || true`
DASH_FOLDER=${ROOT_FOLDER}/doc/dash
if [ "x$DOC2DASH" != x ]; then
echo "Generating Dash docset..."
"$DOC2DASH" \
--online-redirect-url "https://igraph.org/python/api/latest" \
--name "python-igraph" \
-d "${DASH_FOLDER}" \
-f \
-j \
-I "index.html" \
"${DOC_API_FOLDER}"
DASH_READY=1
else
echo "WARNING: doc2dash not installed, skipping Dash docset generation."
DASH_READY=0
fi
echo ""
if [ "x${DASH_READY}" = x1 ]; then
echo "Dash docset generated in ${DASH_FOLDER}/python-igraph.docset"
fi
cd "$PWD"
fi
|