From a47fcfb98936a8d24e5750ece79fbe606e0cf629 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Sat, 7 Oct 2023 17:30:25 +0200
Subject: [PATCH] Fix userdoc generation and set "--no-exec-stat" option for
 doc

---
 cmake/PugsDoc.cmake             | 14 +++++++++++++-
 doc/build-userdoc-pdf.sh.in     |  5 +++++
 doc/lisp/build-doc-config.el    |  4 +---
 doc/lisp/share/ob-pugs-error.el |  2 +-
 doc/lisp/share/ob-pugs.el       |  2 +-
 doc/userdoc.org                 |  9 ++++-----
 6 files changed, 25 insertions(+), 11 deletions(-)
 create mode 100644 doc/build-userdoc-pdf.sh.in

diff --git a/cmake/PugsDoc.cmake b/cmake/PugsDoc.cmake
index b067a5cc8..2be770b3a 100644
--- a/cmake/PugsDoc.cmake
+++ b/cmake/PugsDoc.cmake
@@ -97,7 +97,19 @@ if (EMACS AND GNUPLOT_FOUND AND GMSH)
       COMMENT "Building user documentation in doc/userdoc.pdf"
       VERBATIM)
 
-    add_custom_target(userdoc-pdf DEPENDS pugsdoc-dir "${PUGS_BINARY_DIR}/doc/userdoc.pdf" )
+    configure_file("${PUGS_SOURCE_DIR}/doc/build-userdoc-pdf.sh.in"
+      "${PUGS_BINARY_DIR}/doc/build-userdoc-pdf.sh"
+      FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+      @ONLY)
+
+    set_source_files_properties(
+      ${PUGS_BINARY_DIR}/build-pdf.sh2
+      PROPERTIES
+      GENERATED TRUE
+      HEADER_FILE_ONLY TRUE
+    )
+
+    add_custom_target(userdoc-pdf DEPENDS pugsdoc-dir "${PUGS_BINARY_DIR}/doc/userdoc.pdf" "${PUGS_BINARY_DIR}/doc/build-userdoc-pdf.sh")
 
     add_dependencies(userdoc userdoc-pdf)
 
diff --git a/doc/build-userdoc-pdf.sh.in b/doc/build-userdoc-pdf.sh.in
new file mode 100644
index 000000000..9445e7e75
--- /dev/null
+++ b/doc/build-userdoc-pdf.sh.in
@@ -0,0 +1,5 @@
+#! /usr/bin/env bash
+
+@PDFLATEX_COMPILER@ -shell-escape -interaction nonstopmode userdoc
+@PDFLATEX_COMPILER@ -shell-escape -interaction nonstopmode userdoc
+@PDFLATEX_COMPILER@ -shell-escape -interaction nonstopmode userdoc
diff --git a/doc/lisp/build-doc-config.el b/doc/lisp/build-doc-config.el
index 1da3a5c9f..6f06400a6 100644
--- a/doc/lisp/build-doc-config.el
+++ b/doc/lisp/build-doc-config.el
@@ -64,9 +64,7 @@
 (setq org-latex-listings 'minted
       org-latex-packages-alist '(("" "minted"))
       org-latex-pdf-process
-      '("cd ${PUGS_BINARY_DIR}/doc; pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
-        "cd ${PUGS_BINARY_DIR}/doc; pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
-        "cd ${PUGS_BINARY_DIR}/doc; pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
+      '("cd ${PUGS_BINARY_DIR}/doc; ./build-userdoc-pdf.sh"))
 
 (setq python-indent-guess-indent-offset-verbose nil)
 
diff --git a/doc/lisp/share/ob-pugs-error.el b/doc/lisp/share/ob-pugs-error.el
index 1e4680cbc..e2228f9f4 100644
--- a/doc/lisp/share/ob-pugs-error.el
+++ b/doc/lisp/share/ob-pugs-error.el
@@ -131,7 +131,7 @@
     (with-temp-file in-file
       (insert body))
     (org-babel-eval
-		(format "${PUGS} --no-preamble --no-color %s 2>&1 | sed 's@/.*\.pgs:@test.pgs:@'"
+		(format "${PUGS} --no-exec-stat --no-preamble --no-color --threads=1 %s 2>&1 | sed 's@/.*\.pgs:@test.pgs:@'"
 			(org-babel-process-file-name in-file))
 		"")))
 
diff --git a/doc/lisp/share/ob-pugs.el b/doc/lisp/share/ob-pugs.el
index 6c3d72956..fb346b80b 100644
--- a/doc/lisp/share/ob-pugs.el
+++ b/doc/lisp/share/ob-pugs.el
@@ -130,7 +130,7 @@
     (with-temp-file in-file
       (insert body))
     (org-babel-eval
-		(format "${PUGS} --no-preamble --no-color %s"
+		(format "${PUGS} --no-exec-stat --no-preamble --no-color --threads=1 %s"
 			(org-babel-process-file-name in-file))
 		"")))
 
diff --git a/doc/userdoc.org b/doc/userdoc.org
index 490db8652..b80850ee5 100644
--- a/doc/userdoc.org
+++ b/doc/userdoc.org
@@ -391,8 +391,8 @@ answer a specific need. It must not be done /because it is possible to
 do it/!
 
 #+begin_verse
-When designing a language, the difficulty is not to offer new functionalities,\\
-it is generally to decide not to offer them.\\
+When designing a language, the difficulty is not to offer new functionalities,
+it is generally to decide not to offer them.
 --- Bjarne Stroustrup, C++ conference 2021.
 #+end_verse
 
@@ -1390,7 +1390,7 @@ they follow a few rules.
   When comparing a boolean value (type ~B~) with another scalar value
   type (~N~, ~Z~ or ~R~), the value ~true~ is interpreted as $1$ and the value
   ~false~ as $0$.
-\\
+  \\
   For vector and matrix basic types, the only allowed operators are ~==~
   and ~!=~.
   #+begin_src latex :results drawer :exports results
@@ -1406,7 +1406,7 @@ they follow a few rules.
       \right.
     \end{equation*}
   #+end_src
-\\
+
   This is also the case for ~string~ values: only allowed operators are
   ~==~ and ~!=~.
   #+begin_src latex :results drawer :exports results
@@ -3136,7 +3136,6 @@ available in parallel
 
 ***** Item types
 
-\\
 The following functions are used to designate a specific ~item_type~
 - ~cell: void -> item_type~
 - ~face: void -> item_type~
-- 
GitLab