Update nimweb.nim to work w/ non-hardcoded --docSeeSrcUrl argument to nim doc

This commit is contained in:
Nick Greenfield
2014-12-19 21:56:12 -05:00
parent fb93cee95d
commit fda9da5f1e

View File

@@ -19,6 +19,7 @@ type
authors, projectName, projectTitle, logo, infile, outdir, ticker: string
vars: StringTableRef
nimArgs: string
gitRepo: string
gitCommit: string
quotations: Table[string, tuple[quote, author: string]]
numProcessors: int # Set by parallelBuild:n, only works for values > 0.
@@ -44,6 +45,7 @@ proc initConfigData(c: var TConfigData) =
c.logo = ""
c.ticker = ""
c.vars = newStringTable(modeStyleInsensitive)
c.gitRepo = "https://github.com/Araq/Nimrod/tree"
c.gitCommit = "master"
c.numProcessors = countProcessors()
# Attempts to obtain the git current commit.
@@ -263,18 +265,18 @@ proc buildDoc(c: var TConfigData, destPath: string) =
commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2))
i = 0
for d in items(c.doc):
commands[i] = "nim rst2html $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
[c.nimArgs, c.gitCommit,
commands[i] = "nim rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, splitFile(d).dir,
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
for d in items(c.srcdoc):
commands[i] = "nim doc $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
[c.nimArgs, c.gitCommit,
commands[i] = "nim doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, splitFile(d).dir,
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
for d in items(c.srcdoc2):
commands[i] = "nim doc2 $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
[c.nimArgs, c.gitCommit,
commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, splitFile(d).dir,
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
@@ -306,8 +308,8 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
# build additional documentation (without the index):
var commands = newSeq[string](c.webdoc.len)
for i, doc in pairs(c.webdoc):
commands[i] = "nim doc $# --docSeeSrcUrl:$# -o:$# $#" %
[c.nimArgs, c.gitCommit,
commands[i] = "nim doc $# --docSeeSrcUrl:$#/$#/$# -o:$# $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, splitFile(doc).dir,
destPath / changeFileExt(splitFile(doc).name, "html"), doc]
mexec(commands, c.numProcessors)