fix ./koch pdf command (#16989)
This commit is contained in:
parent
0d34345f29
commit
635c0b6cb9
2 changed files with 27 additions and 17 deletions
|
|
@ -81,3 +81,10 @@ be rerun in serial fashion so that meaningful error output can be gathered for
|
||||||
inspection. The ``--parallelBuild:n`` switch or configuration option can be
|
inspection. The ``--parallelBuild:n`` switch or configuration option can be
|
||||||
used to force a specific number of parallel jobs or run everything serially
|
used to force a specific number of parallel jobs or run everything serially
|
||||||
from the start (``n == 1``).
|
from the start (``n == 1``).
|
||||||
|
|
||||||
|
pdf command
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The `pdf`:idx: command builds PDF versions of Nim documentation: Manual,
|
||||||
|
Tutorial and a few other documents. To run it one needs to
|
||||||
|
`install Latex/pdflatex <https://www.latex-project.org/get>`_ first.
|
||||||
|
|
|
||||||
|
|
@ -112,15 +112,15 @@ proc getRst2html(): seq[string] =
|
||||||
doAssert "doc/manual/var_t_return.rst".unixToNativePath in result # sanity check
|
doAssert "doc/manual/var_t_return.rst".unixToNativePath in result # sanity check
|
||||||
|
|
||||||
const
|
const
|
||||||
pdf = """
|
rstList = """
|
||||||
doc/manual.rst
|
manual.rst
|
||||||
doc/lib.rst
|
lib.rst
|
||||||
doc/tut1.rst
|
tut1.rst
|
||||||
doc/tut2.rst
|
tut2.rst
|
||||||
doc/tut3.rst
|
tut3.rst
|
||||||
doc/nimc.rst
|
nimc.rst
|
||||||
doc/niminst.rst
|
niminst.rst
|
||||||
doc/gc.rst
|
gc.rst
|
||||||
""".splitWhitespace()
|
""".splitWhitespace()
|
||||||
|
|
||||||
doc0 = """
|
doc0 = """
|
||||||
|
|
@ -188,7 +188,8 @@ lib/system/widestrs.nim
|
||||||
""".splitWhitespace()
|
""".splitWhitespace()
|
||||||
|
|
||||||
proc follow(a: PathEntry): bool =
|
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")
|
not a.path.isRelativeTo("lib/fusion")
|
||||||
for entry in walkDirRecFilter("lib", follow = follow):
|
for entry in walkDirRecFilter("lib", follow = follow):
|
||||||
let a = entry.path
|
let a = entry.path
|
||||||
|
|
@ -282,30 +283,32 @@ proc buildDoc(nimArgs, destPath: string) =
|
||||||
# to be transient with `--project` (eg all in memory).
|
# to be transient with `--project` (eg all in memory).
|
||||||
|
|
||||||
proc buildPdfDoc*(nimArgs, destPath: string) =
|
proc buildPdfDoc*(nimArgs, destPath: string) =
|
||||||
|
var pdfList: seq[string]
|
||||||
createDir(destPath)
|
createDir(destPath)
|
||||||
if os.execShellCmd("pdflatex -version") != 0:
|
if os.execShellCmd("pdflatex -version") != 0:
|
||||||
echo "pdflatex not found; no PDF documentation generated"
|
echo "pdflatex not found; no PDF documentation generated"
|
||||||
else:
|
else:
|
||||||
const pdflatexcmd = "pdflatex -interaction=nonstopmode "
|
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])
|
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:
|
# call LaTeX twice to get cross references right:
|
||||||
exec(pdflatexcmd & changeFileExt(d, "tex"))
|
exec(pdflatexcmd & texFile)
|
||||||
exec(pdflatexcmd & changeFileExt(d, "tex"))
|
exec(pdflatexcmd & texFile)
|
||||||
# delete all the crappy temporary files:
|
|
||||||
let pdf = splitFile(d).name & ".pdf"
|
let pdf = splitFile(d).name & ".pdf"
|
||||||
let dest = destPath / pdf
|
let dest = destPath / pdf
|
||||||
removeFile(dest)
|
removeFile(dest)
|
||||||
moveFile(dest=dest, source=pdf)
|
moveFile(dest=dest, source=pdf)
|
||||||
|
pdfList.add dest
|
||||||
|
# delete all the crappy temporary files:
|
||||||
removeFile(changeFileExt(pdf, "aux"))
|
removeFile(changeFileExt(pdf, "aux"))
|
||||||
if fileExists(changeFileExt(pdf, "toc")):
|
if fileExists(changeFileExt(pdf, "toc")):
|
||||||
removeFile(changeFileExt(pdf, "toc"))
|
removeFile(changeFileExt(pdf, "toc"))
|
||||||
removeFile(changeFileExt(pdf, "log"))
|
removeFile(changeFileExt(pdf, "log"))
|
||||||
removeFile(changeFileExt(pdf, "out"))
|
removeFile(changeFileExt(pdf, "out"))
|
||||||
removeFile(changeFileExt(d, "tex"))
|
removeFile(changeFileExt(d, "tex"))
|
||||||
|
echo "\nOutput PDF files: \n ", pdfList.join(" ")
|
||||||
|
|
||||||
proc buildJS(): string =
|
proc buildJS(): string =
|
||||||
let nim = findNim()
|
let nim = findNim()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue