Fixup run_pdflatex script now that bookshelf-doc is no longer used as a

submodule.
main
Joshua Potter 2023-12-15 19:43:18 -07:00
parent 5eb0d9f1de
commit 9bd217dc37
2 changed files with 21 additions and 12 deletions

View File

@ -92,6 +92,18 @@ def getGitUrl (pkg : Package) (lib : LeanLibConfig) (mod : Module) : IO String :
let url := s!"{baseUrl}/blob/{commit}/{basePath}/{path}.lean" let url := s!"{baseUrl}/blob/{commit}/{basePath}/{path}.lean"
return url return url
def runPdfLatex : BuildM PUnit := do
logInfo "Converting TeX to PDF"
let some docGen4 ← findPackage? `«doc-gen4»
| error "no doc-gen4 package found in workspace"
let pdfLatex := docGen4.srcDir / "run_pdflatex.sh"
let srcDir := (← getWorkspace).root.srcDir
let buildDir := (← getWorkspace).root.buildDir
proc {
cmd := pdfLatex.toString
args := #[srcDir.toString, buildDir.toString]
}
module_facet docs (mod) : FilePath := do module_facet docs (mod) : FilePath := do
let some docGen4 ← findLeanExe? `«doc-gen4» let some docGen4 ← findLeanExe? `«doc-gen4»
| error "no doc-gen4 executable configuration found in workspace" | error "no doc-gen4 executable configuration found in workspace"
@ -170,15 +182,7 @@ library_facet docs (lib) : FilePath := do
coreJob.bindAsync fun _ coreInputTrace => do coreJob.bindAsync fun _ coreInputTrace => do
exeJob.bindAsync fun exeFile exeTrace => do exeJob.bindAsync fun exeFile exeTrace => do
moduleJobs.bindSync fun _ inputTrace => do moduleJobs.bindSync fun _ inputTrace => do
logInfo "Converting TeX to PDF" runPdfLatex
let some docGen4 ← findPackage? `«doc-gen4»
| error "no doc-gen4 package found in workspace"
let pdfLatex := docGen4.srcDir / "run_pdflatex.sh"
let buildDir := (←getWorkspace).root.buildDir
proc {
cmd := pdfLatex.toString
args := #[buildDir.toString]
}
let depTrace := mixTraceArray #[inputTrace, exeTrace, coreInputTrace] let depTrace := mixTraceArray #[inputTrace, exeTrace, coreInputTrace]
let trace ← buildFileUnlessUpToDate dataFile depTrace do let trace ← buildFileUnlessUpToDate dataFile depTrace do
logInfo "Documentation indexing" logInfo "Documentation indexing"

View File

@ -5,15 +5,20 @@ if ! command -v pdflatex > /dev/null; then
exit 1 exit 1
fi fi
BUILD_DIR="$1" SRC_DIR="$1"
BUILD_DIR="$2"
cd "$SRC_DIR" || (>&2 echo "Could not cd to $SRC_DIR"; exit 1)
# We run this command twice to allow any cross-references to resolve correctly. # We run this command twice to allow any cross-references to resolve correctly.
# https://tex.stackexchange.com/questions/41539/does-hyperref-work-between-two-files # https://tex.stackexchange.com/questions/41539/does-hyperref-work-between-two-files
TEX_FILES=$(find . -name ".tex" -not -path "*preamble.tex") TEX_FILES=$(find . -name "*.tex" -not -path "*preamble.tex")
for _ in {1..2}; do for _ in {1..2}; do
for f in $TEX_FILES; do for f in $TEX_FILES; do
REL_DIR=$(dirname "$f") REL_DIR=$(dirname "$f")
REL_BASE=$(basename -s ".tex" "$1") REL_BASE=$(basename -s ".tex" "$f")
mkdir -p "$BUILD_DIR/doc/$REL_DIR"
(cd "$REL_DIR" && pdflatex "$REL_BASE.tex")
cp "$REL_DIR/$REL_BASE.pdf" "$BUILD_DIR/doc/$REL_DIR/" cp "$REL_DIR/$REL_BASE.pdf" "$BUILD_DIR/doc/$REL_DIR/"
done done
done done