manual
.PHONY: reference-manual users-guide $(STAN)src/docs/users-guide/users-guide.tex $(STAN)src/docs/functions/stan-functions.txt
STAN_MAJOR := $(shell grep "\#define STAN_MAJOR" $(STAN)src/stan/version.hpp | sed -e 's/.*STAN_MAJOR \(.*\)/\1/')
STAN_MINOR := $(shell grep "\#define STAN_MINOR" $(STAN)src/stan/version.hpp | sed -e 's/.*STAN_MINOR \(.*\)/\1/')
STAN_PATCH := $(shell grep "\#define STAN_PATCH" $(STAN)src/stan/version.hpp | sed -e 's/.*STAN_PATCH \(.*\)/\1/')
VERSION_STRING := $(STAN_MAJOR).$(STAN_MINOR).$(STAN_PATCH)
doc: users-guide reference-manual
users-guide: $(STAN)src/docs/users-guide/users-guide.pdf $(STAN)src/docs/functions/functions-reference.pdf $(STAN)src/docs/functions/stan-functions.txt
@mkdir -p doc/
$(foreach artifact, $^, cp $(artifact) doc/$(basename $(notdir $(artifact)))-$(VERSION_STRING)$(suffix $(artifact));)
$(STAN)src/docs/functions/stan-functions.txt: $(STAN)src/docs/functions/functions-reference.pdf
@echo ' building $@'
@echo '# This file is semicolon delimited' > $@
@echo 'StanFunction; Arguments; ReturnType; Page' >> $@
@sed 's/^\\indexentry{{\\tt \\bfseries //g' $(STAN)src/docs/functions/functions-reference.idx | \
sed 's/ }!{\\tt /;/g' | \
sed 's/{\\tt \\slshape //g' | \
sed 's/:.*T}\[.*\]}/;T\[\]/g' | \
sed 's/:.*em}/;/g' | \
sed 's/}|hyperpage}{/;/g' | \
sed 's/ }!sampling statement|hyperpage}{/;~;real;/g' | \
sed 's/|hyperpage/;/g' | \
sed 's/}//g' | \
sed 's/\\_/_/g' | \
sed 's/^ //g' | \
sed 's/"\(.*\)"/\1/g' | \
sed 's/"!/!/g' | \
sed 's/{\\\&\\\&/\&\&/g' | \
sed 's/{//g' | \
sed 's/\\textasciicircum/\^/g' | \
sed 's/\\textbackslash /\\/g' | \
sed 's/\\textbar \\/|/g' | \
sed 's/\\nobreakspace//g' | \
sed 's/@.*(/;(/g' | \
sed 's/ ;/;/g' | \
sed 's/^phi/Phi/g' | \
sort >> $@
MANUAL_FLAGS=
%.pdf: %.tex
cd $(dir $@); latexmk -pdf -pdflatex="pdflatex -file-line-error" -use-make $(notdir $^)
reference-manual: $(STAN)doc/reference-manual-$(VERSION_STRING).pdf $(STAN)doc/reference-manual/index.html
$(STAN)doc/reference-manual-$(VERSION_STRING).pdf: $(STAN)src/docs/reference-manual/*.Rmd $(STAN)src/docs/reference-manual/*.yml $(STAN)src/docs/reference-manual/*.R $(STAN)src/docs/reference-manual/*.css $(STAN)src/docs/reference-manual/*.tex
cd $(STAN)src/docs/reference-manual; Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')"
mkdir -p $(STAN)doc
mv -f src/docs/reference-manual/_book/_main.pdf doc/reference-manual-$(VERSION_STRING).pdf
$(STAN)doc/reference-manual/index.html: $(STAN)src/docs/reference-manual/*.Rmd $(STAN)src/docs/reference-manual/*.yml $(STAN)src/docs/reference-manual/*.R $(STAN)src/docs/reference-manual/*.css $(STAN)src/docs/reference-manual/*.tex
cd $(STAN)src/docs/reference-manual; Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
rm -rf $(STAN)doc/reference-manual
mkdir -p $(STAN)doc/reference-manual
mv -f $(STAN)src/docs/reference-manual/_book/* $(STAN)doc/reference-manual
clean-manual:
rm -rf $(STAN)doc
cd $(STAN)src/docs/stan-reference; $(RM) *.brf *.aux *.bbl *.blg *.log *.toc *.pdf *.out *.idx *.ilg *.ind *.cb *.cb2 *.upa
rm -rf $(STAN)src/docs/functions/functions-reference.pdf
rm -rf $(STAN)src/docs/functions/stan-functions.txt
rm -rf $(STAN)src/docs/users-guide/users-guide.pdf
rm -rf $(STAN)src/docs/reference-manual/_book/
rm -rf $(STAN)src/docs/reference-manual/_main.rds