@ECHO OFF

REM Command file for Sphinx documentation

pushd %~dp0

REM latexmkrc is read then overridden by latexmkjarc
set PDFLATEX=latexmk -r latexmkjarc -pdfdvi -dvi- -ps-

set "LATEXOPTS= "

if "%1" == "" goto all-pdf

if "%1" == "all-pdf" (
	:all-pdf
	for %%i in (*.png *.gif *.jpg *.jpeg *.pdf) do (
		extractbb %%i
	)
	for %%i in (*.tex) do (
		%PDFLATEX% %LATEXMKOPTS% %%i
	)
	goto end
)

if "%1" == "all-pdf-ja" (
	goto all-pdf
)

if "%1" == "clean" (
	del /q /s *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla *.ps *.tar *.tar.gz *.tar.bz2 *.tar.xz *.fls *.fdb_latexmk
	goto end
)

:end
popd