Skip to content

Commit 3b141a2

Browse files
committed
issue #10740 Guide the user to doxygen_manual.log when building the manual PDF fails
There will be an error message when generating the pdf for this snippet, but it is not clear (when using the batch mode) where to find the error message ``` /// \file /** Lets crash the LaTex Party * \latexonly * \lets crash * \endlatexonly * Done */ void fie(); ``` Similar code use to test the doxygen manual
1 parent 987a8c3 commit 3b141a2

File tree

2 files changed

+65
-12
lines changed

2 files changed

+65
-12
lines changed

doc/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ add_custom_target(doxygen_pdf
228228
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/doc/doxygen_logo.pdf .
229229
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_BINARY_DIR}/latex ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/replace_version.py "${PROJECT_BINARY_DIR}/doc/doxygen_manual.tex" "${PROJECT_BINARY_DIR}/latex/doxygen_manual.tex" "${VERSION}"
230230
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_BINARY_DIR}/latex ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/replace_version.py "${PROJECT_BINARY_DIR}/doc/manual.sty" "${PROJECT_BINARY_DIR}/latex/manual.sty" "${VERSION}"
231-
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex
231+
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex || (${CMAKE_COMMAND} -E echo "See ${PROJECT_BINARY_DIR}/latex/doxygen_manual.log for error messages" && ${CMAKE_COMMAND} -E false)
232232
COMMAND ${MAKEINDEX} doxygen_manual.idx
233-
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex
233+
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex || (${CMAKE_COMMAND} -E echo "See ${PROJECT_BINARY_DIR}/latex/doxygen_manual.log for error messages" && ${CMAKE_COMMAND} -E false)
234234
COMMAND ${MAKEINDEX} doxygen_manual.idx
235-
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex
235+
COMMAND ${PDFLATEX} -shell-escape doxygen_manual.tex || (${CMAKE_COMMAND} -E echo "See ${PROJECT_BINARY_DIR}/latex/doxygen_manual.log for error messages" && ${CMAKE_COMMAND} -E false)
236236
DEPENDS ${PROJECT_BINARY_DIR}/doc/manual.sty ${PROJECT_SOURCE_DIR}/doc/doxygen_logo.pdf
237237
DEPENDS run_doxygen ${PROJECT_SOURCE_DIR}/doc/replace_version.py ${PROJECT_BINARY_DIR}/doc/doxygen_manual.tex
238238
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/latex

src/latexgen.cpp

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,23 @@ static void writeLatexMakefile()
375375
t << "\tps2pdf $(MANUAL_FILE).ps $(MANUAL_FILE).pdf\n\n";
376376
t << "$(MANUAL_FILE).dvi: clean $(MANUAL_FILE).tex doxygen.sty\n"
377377
<< "\techo \"Running latex...\"\n"
378-
<< "\t$(LATEX_CMD) $(MANUAL_FILE).tex\n"
378+
<< "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
379+
<< "\tif [ $$? != 0 ] ; then \\\n"
380+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
381+
<< "\t false; \\\n"
382+
<< "\tfi\n"
379383
<< "\techo \"Running makeindex...\"\n"
380384
<< "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n";
381385
if (generateBib)
382386
{
383387
t << "\techo \"Running bibtex...\"\n";
384388
t << "\t$(BIBTEX_CMD) $(MANUAL_FILE)\n";
385389
t << "\techo \"Rerunning latex....\"\n";
386-
t << "\t$(LATEX_CMD) $(MANUAL_FILE).tex\n";
390+
t << "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
391+
<< "\tif [ $$? != 0 ] ; then \\\n"
392+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
393+
<< "\t false; \\\n"
394+
<< "\tfi\n";
387395
}
388396
t << "\techo \"Rerunning latex....\"\n"
389397
<< "\t$(LATEX_CMD) $(MANUAL_FILE).tex\n"
@@ -392,10 +400,19 @@ static void writeLatexMakefile()
392400
<< "\t do \\\n"
393401
<< "\t echo \"Rerunning latex....\" ;\\\n"
394402
<< "\t $(LATEX_CMD) $(MANUAL_FILE).tex ; \\\n"
403+
<< "\t $(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
404+
<< "\t if [ $$? != 0 ] ; then \\\n"
405+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
406+
<< "\t false; \\\n"
407+
<< "\t fi; \\\n"
395408
<< "\t latex_count=`expr $$latex_count - 1` ;\\\n"
396409
<< "\t done\n"
397410
<< "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n"
398-
<< "\t$(LATEX_CMD) $(MANUAL_FILE).tex\n\n"
411+
<< "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
412+
<< "\tif [ $$? != 0 ] ; then \\\n"
413+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
414+
<< "\t false; \\\n"
415+
<< "\tfi\n"
399416
<< "$(MANUAL_FILE).ps: $(MANUAL_FILE).ps\n"
400417
<< "\tpsnup -2 $(MANUAL_FILE).ps >$(MANUAL_FILE).ps\n"
401418
<< "\n"
@@ -407,23 +424,43 @@ static void writeLatexMakefile()
407424
t << "all: $(MANUAL_FILE).pdf\n\n"
408425
<< "pdf: $(MANUAL_FILE).pdf\n\n";
409426
t << "$(MANUAL_FILE).pdf: clean $(MANUAL_FILE).tex\n";
410-
t << "\t$(LATEX_CMD) $(MANUAL_FILE)\n";
427+
t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
428+
<< "\tif [ $$? != 0 ] ; then \\\n"
429+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
430+
<< "\t false; \\\n"
431+
<< "\tfi\n";
411432
t << "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n";
412433
if (generateBib)
413434
{
414435
t << "\t$(BIBTEX_CMD) $(MANUAL_FILE)\n";
415-
t << "\t$(LATEX_CMD) $(MANUAL_FILE)\n";
436+
t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
437+
<< "\tif [ $$? != 0 ] ; then \\\n"
438+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
439+
<< "\t false; \\\n"
440+
<< "\tfi\n";
416441
}
417-
t << "\t$(LATEX_CMD) $(MANUAL_FILE)\n"
442+
t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
443+
<< "\tif [ $$? != 0 ] ; then \\\n"
444+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
445+
<< "\t false; \\\n"
446+
<< "\tfi\n"
418447
<< "\tlatex_count=$(LATEX_COUNT) ; \\\n"
419448
<< "\twhile grep -E -s 'Rerun (LaTeX|to get cross-references right|to get bibliographical references right)' $(MANUAL_FILE).log && [ $$latex_count -gt 0 ] ;\\\n"
420449
<< "\t do \\\n"
421450
<< "\t echo \"Rerunning latex....\" ;\\\n"
422-
<< "\t $(LATEX_CMD) $(MANUAL_FILE) ;\\\n"
451+
<< "\t $(LATEX_CMD) $(MANUAL_FILE) || \\\n"
452+
<< "\t if [ $$? != 0 ] ; then \\\n"
453+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
454+
<< "\t false; \\\n"
455+
<< "\t fi; \\\n"
423456
<< "\t latex_count=`expr $$latex_count - 1` ;\\\n"
424457
<< "\t done\n"
425458
<< "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n"
426-
<< "\t$(LATEX_CMD) $(MANUAL_FILE)\n\n";
459+
<< "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
460+
<< "\tif [ $$? != 0 ] ; then \\\n"
461+
<< "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
462+
<< "\t false; \\\n"
463+
<< "\tfi\n";
427464
}
428465

429466
t << "\n"
@@ -467,13 +504,15 @@ static void writeMakeBat()
467504
if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
468505
{
469506
t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
507+
t << "@if ERRORLEVEL 1 goto :error\r\n";
470508
t << "echo ----\r\n";
471509
t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
472510
if (generateBib)
473511
{
474512
t << "%BIBTEX_CMD% %MANUAL_FILE%\r\n";
475513
t << "echo ----\r\n";
476514
t << "\t%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
515+
t << "@if ERRORLEVEL 1 goto :error\r\n";
477516
}
478517
t << "setlocal enabledelayedexpansion\r\n";
479518
t << "set count=%LAT#EX_COUNT%\r\n";
@@ -487,11 +526,13 @@ static void writeMakeBat()
487526
t << "if !count! EQU 0 goto :skip\r\n\r\n";
488527
t << "echo ----\r\n";
489528
t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
529+
t << "@if ERRORLEVEL 1 goto :error\r\n";
490530
t << "goto :repeat\r\n";
491531
t << ":skip\r\n";
492532
t << "endlocal\r\n";
493533
t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
494534
t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
535+
t << "@if ERRORLEVEL 1 goto :error\r\n";
495536
t << "dvips -o %MANUAL_FILE%.ps %MANUAL_FILE%.dvi\r\n";
496537
t << Portable::ghostScriptCommand();
497538
t << " -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
@@ -500,15 +541,19 @@ static void writeMakeBat()
500541
else // use pdflatex
501542
{
502543
t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
544+
t << "@if ERRORLEVEL 1 goto :error\r\n";
503545
t << "echo ----\r\n";
504546
t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
505547
if (generateBib)
506548
{
507549
t << "%BIBTEX_CMD% %MANUAL_FILE%\r\n";
508550
t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
551+
t << "@if ERRORLEVEL 1 goto :error\r\n";
509552
}
510553
t << "echo ----\r\n";
511-
t << "%LATEX_CMD% %MANUAL_FILE%\r\n\r\n";
554+
t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
555+
t << "@if ERRORLEVEL 1 goto :error\r\n";
556+
t << "\r\n";
512557
t << "setlocal enabledelayedexpansion\r\n";
513558
t << "set count=%LATEX_COUNT%\r\n";
514559
t << ":repeat\r\n";
@@ -521,13 +566,21 @@ static void writeMakeBat()
521566
t << "if !count! EQU 0 goto :skip\r\n\r\n";
522567
t << "echo ----\r\n";
523568
t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
569+
t << "@if ERRORLEVEL 1 goto :error\r\n";
524570
t << "goto :repeat\r\n";
525571
t << ":skip\r\n";
526572
t << "endlocal\r\n";
527573
t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
528574
t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
575+
t << "@if ERRORLEVEL 1 goto :error\r\n";
529576
}
530577
t<< "\r\n";
578+
t << "goto :end\r\n";
579+
t << ":error\r\n";
580+
t << "@echo ===============\r\n";
581+
t << "@echo Please consult %MANUAL_FILE%.log to see the error messages\r\n";
582+
t << "@echo ===============\r\n";
583+
t<< "\r\n";
531584
t<< "@REM reset environment\r\n";
532585
t<< "popd\r\n";
533586
t<< "set LATEX_CMD=%ORG_LATEX_CMD%\r\n";

0 commit comments

Comments
 (0)