2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, sage-with-env
|
2020-12-25 13:55:36 +00:00
|
|
|
, python3
|
2022-05-18 14:49:53 +00:00
|
|
|
, jupyter-kernel-specs
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
version = src.version;
|
|
|
|
pname = "sagedoc";
|
|
|
|
src = sage-with-env.env.lib.src;
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
export SAGE_DOC_OVERRIDE="$PWD/share/doc/sage"
|
|
|
|
export SAGE_DOC_SRC_OVERRIDE="$PWD/docsrc"
|
|
|
|
|
|
|
|
cp -r "${src}/src/doc" "$SAGE_DOC_SRC_OVERRIDE"
|
|
|
|
chmod -R 755 "$SAGE_DOC_SRC_OVERRIDE"
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export SAGE_NUM_THREADS="$NIX_BUILD_CORES"
|
|
|
|
export HOME="$TMPDIR/sage_home"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
|
|
|
|
# needed to link them in the sage docs using intersphinx
|
2020-12-25 13:55:36 +00:00
|
|
|
export PPLPY_DOCS=${python3.pkgs.pplpy.doc}/share/doc/pplpy
|
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
# adapted from src/doc/bootstrap (which we don't run)
|
2020-12-25 13:55:36 +00:00
|
|
|
OUTPUT_DIR="$SAGE_DOC_SRC_OVERRIDE/en/reference/repl"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
OUTPUT="$OUTPUT_DIR/options.txt"
|
|
|
|
${sage-with-env}/bin/sage -advanced > "$OUTPUT"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# jupyter-sphinx calls the sagemath jupyter kernel during docbuild
|
|
|
|
export JUPYTER_PATH=${jupyter-kernel-specs}
|
|
|
|
|
|
|
|
# sage --docbuild unsets JUPYTER_PATH, so we call sage_docbuild directly
|
|
|
|
# https://trac.sagemath.org/ticket/33650#comment:32
|
|
|
|
${sage-with-env}/bin/sage --python3 -m sage_docbuild \
|
2020-04-24 23:36:52 +00:00
|
|
|
--mathjax \
|
|
|
|
--no-pdf-links \
|
2022-05-18 14:49:53 +00:00
|
|
|
all html < /dev/null
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cd "$SAGE_DOC_OVERRIDE"
|
|
|
|
|
|
|
|
mkdir -p "$out/share/doc/sage"
|
|
|
|
cp -r html "$out"/share/doc/sage
|
|
|
|
|
|
|
|
# Replace duplicated files by symlinks (Gentoo)
|
|
|
|
cd "$out"/share/doc/sage
|
|
|
|
mv html/en/_static{,.tmp}
|
|
|
|
for _dir in `find -name _static` ; do
|
|
|
|
rm -r $_dir
|
2021-06-01 10:57:12 +00:00
|
|
|
ln -rs html/en/_static $_dir
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
mv html/en/_static{.tmp,}
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
2022-05-18 14:49:53 +00:00
|
|
|
# sagemath_doc_html tests assume sage tests are being run, so we
|
|
|
|
# compromise: we run standard tests, but only on files containing
|
|
|
|
# relevant tests. as of Sage 9.6, there are only 4 such files.
|
|
|
|
grep -PRl "#.*optional.*sagemath_doc_html" ${src}/src/sage{,_docbuild} | \
|
|
|
|
xargs ${sage-with-env}/bin/sage -t --optional=sage,sagemath_doc_html
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
}
|