mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes bootstrapping for any machine that has a Nim already installed [backport:1.4] (#15660)
This commit is contained in:
@@ -168,7 +168,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||
result.module = module
|
||||
result.conf = conf
|
||||
result.cache = cache
|
||||
result.outDir = conf.outDir
|
||||
result.outDir = conf.outDir.string
|
||||
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
||||
conf.configVars, filename.string, {roSupportRawDirective, roSupportMarkdown},
|
||||
docgenFindFile, compilerMsgHandler)
|
||||
@@ -230,8 +230,8 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||
if gotten != status:
|
||||
rawMessage(conf, errGenerated, "snippet failed: cmd: '$1' status: $2 expected: $3 output: $4" % [cmd, $gotten, $status, output])
|
||||
result.emitted = initIntSet()
|
||||
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false)
|
||||
result.thisDir = result.destFile.splitFile.dir
|
||||
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false).string
|
||||
result.thisDir = result.destFile.AbsoluteFile.splitFile.dir
|
||||
|
||||
template dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
||||
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,
|
||||
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
|
||||
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",
|
||||
"tableofcontents", "moduledesc", "date", "time", "content", "deprecationMsg", "theindexhref", "body_toc_groupsection"],
|
||||
[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:
|
||||
# XXX what is this hack doing here? 'optCompileOnly' means raw output!?
|
||||
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), [
|
||||
"nimdoccss", "dochackjs", "title", "tableofcontents", "moduledesc", "date", "time",
|
||||
"content", "author", "version", "analytics", "deprecationMsg"],
|
||||
[relLink(d.conf.outDir, d.destFile, nimdocOutCss.RelativeFile),
|
||||
relLink(d.conf.outDir, d.destFile, docHackJsFname.RelativeFile),
|
||||
[relLink(d.conf.outDir, d.destFile.AbsoluteFile, nimdocOutCss.RelativeFile),
|
||||
relLink(d.conf.outDir, d.destFile.AbsoluteFile, docHackJsFname.RelativeFile),
|
||||
title.rope, toc, d.modDesc, rope(getDateStr()), rope(getClockStr()),
|
||||
content, d.meta[metaAuthor].rope, d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
|
||||
else:
|
||||
@@ -1271,7 +1271,7 @@ proc writeOutput*(d: PDoc, useWarning = false, groupedToc = false) =
|
||||
if optStdout in d.conf.globalOptions:
|
||||
writeRope(stdout, content)
|
||||
else:
|
||||
template outfile: untyped = d.destFile
|
||||
template outfile: untyped = d.destFile.AbsoluteFile
|
||||
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt)
|
||||
let dir = outfile.splitFile.dir
|
||||
createDir(dir)
|
||||
@@ -1300,13 +1300,13 @@ proc writeOutputJson*(d: PDoc, useWarning = false) =
|
||||
write(stdout, $content)
|
||||
else:
|
||||
var f: File
|
||||
if open(f, d.destFile.string, fmWrite):
|
||||
if open(f, d.destFile, fmWrite):
|
||||
write(f, $content)
|
||||
close(f)
|
||||
updateOutfile(d, d.destFile)
|
||||
updateOutfile(d, d.destFile.AbsoluteFile)
|
||||
else:
|
||||
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")
|
||||
|
||||
proc handleDocOutputOptions*(conf: ConfigRef) =
|
||||
|
||||
@@ -230,6 +230,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||
doAssert err.firstMismatch.formal != nil
|
||||
candidates.add("\n required type for " & nameParam & ": ")
|
||||
candidates.add typeToString(wanted)
|
||||
when false:
|
||||
if wanted.sym != nil:
|
||||
candidates.add "(" & (c.config $ wanted.sym.info) & ")"
|
||||
candidates.add "\n but expression '"
|
||||
if err.firstMismatch.kind == kVarNeeded:
|
||||
candidates.add renderNotLValue(nArg)
|
||||
@@ -239,6 +242,10 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||
candidates.add "' is of type: "
|
||||
var got = nArg.typ
|
||||
candidates.add typeToString(got)
|
||||
when false:
|
||||
if got.sym != nil:
|
||||
candidates.add "(" & (c.config $ got.sym.info) & ")"
|
||||
|
||||
doAssert wanted != nil
|
||||
if got != nil: effectProblem(wanted, got, candidates, c)
|
||||
of kUnknown: discard "do not break 'nim check'"
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
|
||||
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
|
||||
algorithm, parseutils
|
||||
import "$lib/../compiler/nimpaths"
|
||||
import "$lib/../compiler/pathutils"
|
||||
|
||||
import ../../std/private/since
|
||||
|
||||
const
|
||||
@@ -58,8 +57,8 @@ type
|
||||
options*: RstParseOptions
|
||||
findFile*: FindFileHandler
|
||||
msgHandler*: MsgHandler
|
||||
outDir*: AbsoluteDir ## output directory, initialized by docgen.nim
|
||||
destFile*: AbsoluteFile ## output (HTML) file, initialized by docgen.nim
|
||||
outDir*: string ## output directory, initialized by docgen.nim
|
||||
destFile*: string ## output (HTML) file, initialized by docgen.nim
|
||||
filename*: string ## source Nim or Rst file
|
||||
meta*: array[MetaEnum, string]
|
||||
currentSection: string ## \
|
||||
@@ -84,7 +83,7 @@ type
|
||||
status: int
|
||||
|
||||
proc prettyLink*(file: string): string =
|
||||
changeFileExt(file, "").replace(dotdotMangle, "..")
|
||||
changeFileExt(file, "").replace("_._", "..")
|
||||
|
||||
proc init(p: var CodeBlockParams) =
|
||||
## 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.
|
||||
assert n.level >= 0
|
||||
let
|
||||
htmlFileRelPath = if d.outDir.isEmpty():
|
||||
htmlFileRelPath = if d.outDir.len == 0:
|
||||
# /foo/bar/zoo.nim -> zoo.html
|
||||
changeFileExt(extractFilename(d.filename), HtmlExt)
|
||||
else: # d is initialized in docgen.nim
|
||||
# outDir = /foo -\
|
||||
# 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,
|
||||
spaces(max(0, n.level)) & tmp)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user