fixes bootstrapping for any machine that has a Nim already installed [backport:1.4] (#15660)
This commit is contained in:
parent
94a4b57280
commit
9a059657ca
3 changed files with 24 additions and 18 deletions
|
|
@ -168,7 +168,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||||
result.module = module
|
result.module = module
|
||||||
result.conf = conf
|
result.conf = conf
|
||||||
result.cache = cache
|
result.cache = cache
|
||||||
result.outDir = conf.outDir
|
result.outDir = conf.outDir.string
|
||||||
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
||||||
conf.configVars, filename.string, {roSupportRawDirective, roSupportMarkdown},
|
conf.configVars, filename.string, {roSupportRawDirective, roSupportMarkdown},
|
||||||
docgenFindFile, compilerMsgHandler)
|
docgenFindFile, compilerMsgHandler)
|
||||||
|
|
@ -230,8 +230,8 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||||
if gotten != status:
|
if gotten != status:
|
||||||
rawMessage(conf, errGenerated, "snippet failed: cmd: '$1' status: $2 expected: $3 output: $4" % [cmd, $gotten, $status, output])
|
rawMessage(conf, errGenerated, "snippet failed: cmd: '$1' status: $2 expected: $3 output: $4" % [cmd, $gotten, $status, output])
|
||||||
result.emitted = initIntSet()
|
result.emitted = initIntSet()
|
||||||
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false)
|
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false).string
|
||||||
result.thisDir = result.destFile.splitFile.dir
|
result.thisDir = result.destFile.AbsoluteFile.splitFile.dir
|
||||||
|
|
||||||
template dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
template dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
||||||
if conf.cmd != cmdRst2tex: dest.addf(xml, args)
|
if conf.cmd != cmdRst2tex: dest.addf(xml, args)
|
||||||
|
|
@ -849,7 +849,7 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind, docFlags: DocFlags) =
|
||||||
symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope,
|
symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope,
|
||||||
deprecationMsgRope]))
|
deprecationMsgRope]))
|
||||||
|
|
||||||
let external = d.destFile.relativeTo(d.conf.outDir, '/').changeFileExt(HtmlExt).string
|
let external = d.destFile.AbsoluteFile.relativeTo(d.conf.outDir, '/').changeFileExt(HtmlExt).string
|
||||||
|
|
||||||
var attype: Rope
|
var attype: Rope
|
||||||
if k in routineKinds and nameNode.kind == nkSym:
|
if k in routineKinds and nameNode.kind == nkSym:
|
||||||
|
|
@ -1237,14 +1237,14 @@ proc genOutFile(d: PDoc, groupedToc = false): Rope =
|
||||||
content = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, bodyname), ["title",
|
content = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, bodyname), ["title",
|
||||||
"tableofcontents", "moduledesc", "date", "time", "content", "deprecationMsg", "theindexhref", "body_toc_groupsection"],
|
"tableofcontents", "moduledesc", "date", "time", "content", "deprecationMsg", "theindexhref", "body_toc_groupsection"],
|
||||||
[title.rope, toc, d.modDesc, rope(getDateStr()),
|
[title.rope, toc, d.modDesc, rope(getDateStr()),
|
||||||
rope(getClockStr()), code, d.modDeprecationMsg, relLink(d.conf.outDir, d.destFile, theindexFname.RelativeFile), groupsection.rope])
|
rope(getClockStr()), code, d.modDeprecationMsg, relLink(d.conf.outDir, d.destFile.AbsoluteFile, theindexFname.RelativeFile), groupsection.rope])
|
||||||
if optCompileOnly notin d.conf.globalOptions:
|
if optCompileOnly notin d.conf.globalOptions:
|
||||||
# XXX what is this hack doing here? 'optCompileOnly' means raw output!?
|
# XXX what is this hack doing here? 'optCompileOnly' means raw output!?
|
||||||
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), [
|
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), [
|
||||||
"nimdoccss", "dochackjs", "title", "tableofcontents", "moduledesc", "date", "time",
|
"nimdoccss", "dochackjs", "title", "tableofcontents", "moduledesc", "date", "time",
|
||||||
"content", "author", "version", "analytics", "deprecationMsg"],
|
"content", "author", "version", "analytics", "deprecationMsg"],
|
||||||
[relLink(d.conf.outDir, d.destFile, nimdocOutCss.RelativeFile),
|
[relLink(d.conf.outDir, d.destFile.AbsoluteFile, nimdocOutCss.RelativeFile),
|
||||||
relLink(d.conf.outDir, d.destFile, docHackJsFname.RelativeFile),
|
relLink(d.conf.outDir, d.destFile.AbsoluteFile, docHackJsFname.RelativeFile),
|
||||||
title.rope, toc, d.modDesc, rope(getDateStr()), rope(getClockStr()),
|
title.rope, toc, d.modDesc, rope(getDateStr()), rope(getClockStr()),
|
||||||
content, d.meta[metaAuthor].rope, d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
|
content, d.meta[metaAuthor].rope, d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
|
||||||
else:
|
else:
|
||||||
|
|
@ -1271,7 +1271,7 @@ proc writeOutput*(d: PDoc, useWarning = false, groupedToc = false) =
|
||||||
if optStdout in d.conf.globalOptions:
|
if optStdout in d.conf.globalOptions:
|
||||||
writeRope(stdout, content)
|
writeRope(stdout, content)
|
||||||
else:
|
else:
|
||||||
template outfile: untyped = d.destFile
|
template outfile: untyped = d.destFile.AbsoluteFile
|
||||||
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt)
|
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt)
|
||||||
let dir = outfile.splitFile.dir
|
let dir = outfile.splitFile.dir
|
||||||
createDir(dir)
|
createDir(dir)
|
||||||
|
|
@ -1300,13 +1300,13 @@ proc writeOutputJson*(d: PDoc, useWarning = false) =
|
||||||
write(stdout, $content)
|
write(stdout, $content)
|
||||||
else:
|
else:
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, d.destFile.string, fmWrite):
|
if open(f, d.destFile, fmWrite):
|
||||||
write(f, $content)
|
write(f, $content)
|
||||||
close(f)
|
close(f)
|
||||||
updateOutfile(d, d.destFile)
|
updateOutfile(d, d.destFile.AbsoluteFile)
|
||||||
else:
|
else:
|
||||||
localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1),
|
localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1),
|
||||||
warnUser, "unable to open file \"" & d.destFile.string &
|
warnUser, "unable to open file \"" & d.destFile &
|
||||||
"\" for writing")
|
"\" for writing")
|
||||||
|
|
||||||
proc handleDocOutputOptions*(conf: ConfigRef) =
|
proc handleDocOutputOptions*(conf: ConfigRef) =
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||||
doAssert err.firstMismatch.formal != nil
|
doAssert err.firstMismatch.formal != nil
|
||||||
candidates.add("\n required type for " & nameParam & ": ")
|
candidates.add("\n required type for " & nameParam & ": ")
|
||||||
candidates.add typeToString(wanted)
|
candidates.add typeToString(wanted)
|
||||||
|
when false:
|
||||||
|
if wanted.sym != nil:
|
||||||
|
candidates.add "(" & (c.config $ wanted.sym.info) & ")"
|
||||||
candidates.add "\n but expression '"
|
candidates.add "\n but expression '"
|
||||||
if err.firstMismatch.kind == kVarNeeded:
|
if err.firstMismatch.kind == kVarNeeded:
|
||||||
candidates.add renderNotLValue(nArg)
|
candidates.add renderNotLValue(nArg)
|
||||||
|
|
@ -239,6 +242,10 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||||
candidates.add "' is of type: "
|
candidates.add "' is of type: "
|
||||||
var got = nArg.typ
|
var got = nArg.typ
|
||||||
candidates.add typeToString(got)
|
candidates.add typeToString(got)
|
||||||
|
when false:
|
||||||
|
if got.sym != nil:
|
||||||
|
candidates.add "(" & (c.config $ got.sym.info) & ")"
|
||||||
|
|
||||||
doAssert wanted != nil
|
doAssert wanted != nil
|
||||||
if got != nil: effectProblem(wanted, got, candidates, c)
|
if got != nil: effectProblem(wanted, got, candidates, c)
|
||||||
of kUnknown: discard "do not break 'nim check'"
|
of kUnknown: discard "do not break 'nim check'"
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@
|
||||||
|
|
||||||
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
|
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
|
||||||
algorithm, parseutils
|
algorithm, parseutils
|
||||||
import "$lib/../compiler/nimpaths"
|
|
||||||
import "$lib/../compiler/pathutils"
|
|
||||||
import ../../std/private/since
|
import ../../std/private/since
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -58,8 +57,8 @@ type
|
||||||
options*: RstParseOptions
|
options*: RstParseOptions
|
||||||
findFile*: FindFileHandler
|
findFile*: FindFileHandler
|
||||||
msgHandler*: MsgHandler
|
msgHandler*: MsgHandler
|
||||||
outDir*: AbsoluteDir ## output directory, initialized by docgen.nim
|
outDir*: string ## output directory, initialized by docgen.nim
|
||||||
destFile*: AbsoluteFile ## output (HTML) file, initialized by docgen.nim
|
destFile*: string ## output (HTML) file, initialized by docgen.nim
|
||||||
filename*: string ## source Nim or Rst file
|
filename*: string ## source Nim or Rst file
|
||||||
meta*: array[MetaEnum, string]
|
meta*: array[MetaEnum, string]
|
||||||
currentSection: string ## \
|
currentSection: string ## \
|
||||||
|
|
@ -84,7 +83,7 @@ type
|
||||||
status: int
|
status: int
|
||||||
|
|
||||||
proc prettyLink*(file: string): string =
|
proc prettyLink*(file: string): string =
|
||||||
changeFileExt(file, "").replace(dotdotMangle, "..")
|
changeFileExt(file, "").replace("_._", "..")
|
||||||
|
|
||||||
proc init(p: var CodeBlockParams) =
|
proc init(p: var CodeBlockParams) =
|
||||||
## Default initialisation of CodeBlockParams to sane values.
|
## Default initialisation of CodeBlockParams to sane values.
|
||||||
|
|
@ -759,13 +758,13 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
|
||||||
# Generate index entry using spaces to indicate TOC level for the output HTML.
|
# Generate index entry using spaces to indicate TOC level for the output HTML.
|
||||||
assert n.level >= 0
|
assert n.level >= 0
|
||||||
let
|
let
|
||||||
htmlFileRelPath = if d.outDir.isEmpty():
|
htmlFileRelPath = if d.outDir.len == 0:
|
||||||
# /foo/bar/zoo.nim -> zoo.html
|
# /foo/bar/zoo.nim -> zoo.html
|
||||||
changeFileExt(extractFilename(d.filename), HtmlExt)
|
changeFileExt(extractFilename(d.filename), HtmlExt)
|
||||||
else: # d is initialized in docgen.nim
|
else: # d is initialized in docgen.nim
|
||||||
# outDir = /foo -\
|
# outDir = /foo -\
|
||||||
# destFile = /foo/bar/zoo.html -|-> bar/zoo.html
|
# destFile = /foo/bar/zoo.html -|-> bar/zoo.html
|
||||||
d.destFile.relativeTo(d.outDir, '/').string
|
d.destFile.relativePath(d.outDir, '/')
|
||||||
setIndexTerm(d, htmlFileRelPath, refname, tmp.stripTocHtml,
|
setIndexTerm(d, htmlFileRelPath, refname, tmp.stripTocHtml,
|
||||||
spaces(max(0, n.level)) & tmp)
|
spaces(max(0, n.level)) & tmp)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue