summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorAndrey Makarov <ph.makarov@gmail.com>2021-02-10 00:46:51 +0300
committerGitHub <noreply@github.com>2021-02-09 22:46:51 +0100
commit635c0b6cb9c225a247ab2aeb136458c14fb711e8 (patch)
treee6f25e63ffc1908a1fe38316e410b4ed5216b0c9 /tools
parent0d34345f29aa3b862f21c8dcff6b94b5ac5b9572 (diff)
downloadNim-635c0b6cb9c225a247ab2aeb136458c14fb711e8.tar.gz
fix ./koch pdf command (#16989)
Diffstat (limited to 'tools')
-rw-r--r--tools/kochdocs.nim37
1 files changed, 20 insertions, 17 deletions
diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim
index 6fa64c73b..ee09afd6f 100644
--- a/tools/kochdocs.nim
+++ b/tools/kochdocs.nim
@@ -112,15 +112,15 @@ proc getRst2html(): seq[string] =
   doAssert "doc/manual/var_t_return.rst".unixToNativePath in result # sanity check
 
 const
-  pdf = """
-doc/manual.rst
-doc/lib.rst
-doc/tut1.rst
-doc/tut2.rst
-doc/tut3.rst
-doc/nimc.rst
-doc/niminst.rst
-doc/gc.rst
+  rstList = """
+manual.rst
+lib.rst
+tut1.rst
+tut2.rst
+tut3.rst
+nimc.rst
+niminst.rst
+gc.rst
 """.splitWhitespace()
 
   doc0 = """
@@ -188,7 +188,8 @@ lib/system/widestrs.nim
 """.splitWhitespace()
 
   proc follow(a: PathEntry): bool =
-    result = a.path.lastPathPart notin ["nimcache", "htmldocs", "includes", "deprecated", "genode"] and
+    result = a.path.lastPathPart notin ["nimcache", htmldocsDirname,
+                                        "includes", "deprecated", "genode"] and
       not a.path.isRelativeTo("lib/fusion")
   for entry in walkDirRecFilter("lib", follow = follow):
     let a = entry.path
@@ -282,30 +283,32 @@ proc buildDoc(nimArgs, destPath: string) =
     # to be transient with `--project` (eg all in memory).
 
 proc buildPdfDoc*(nimArgs, destPath: string) =
+  var pdfList: seq[string]
   createDir(destPath)
   if os.execShellCmd("pdflatex -version") != 0:
     echo "pdflatex not found; no PDF documentation generated"
   else:
     const pdflatexcmd = "pdflatex -interaction=nonstopmode "
-    for d in items(pdf):
+    for file in items(rstList):
+      let d = "doc" / file
+      let texFile = "doc" / htmldocsDirname / changeFileExt(file, "tex")
       exec(findNim().quoteShell() & " rst2tex $# $#" % [nimArgs, d])
-      let tex = splitFile(d).name & ".tex"
-      removeFile("doc" / tex)
-      moveFile(tex, "doc" / tex)
       # call LaTeX twice to get cross references right:
-      exec(pdflatexcmd & changeFileExt(d, "tex"))
-      exec(pdflatexcmd & changeFileExt(d, "tex"))
-      # delete all the crappy temporary files:
+      exec(pdflatexcmd & texFile)
+      exec(pdflatexcmd & texFile)
       let pdf = splitFile(d).name & ".pdf"
       let dest = destPath / pdf
       removeFile(dest)
       moveFile(dest=dest, source=pdf)
+      pdfList.add dest
+      # delete all the crappy temporary files:
       removeFile(changeFileExt(pdf, "aux"))
       if fileExists(changeFileExt(pdf, "toc")):
         removeFile(changeFileExt(pdf, "toc"))
       removeFile(changeFileExt(pdf, "log"))
       removeFile(changeFileExt(pdf, "out"))
       removeFile(changeFileExt(d, "tex"))
+  echo "\nOutput PDF files: \n  ", pdfList.join(" ")
 
 proc buildJS(): string =
   let nim = findNim()
pre>