Skip to content

Commit 9a05965

Browse files
authored
fixes bootstrapping for any machine that has a Nim already installed [backport:1.4] (#15660)
1 parent 94a4b57 commit 9a05965

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

compiler/docgen.nim

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
168168
result.module = module
169169
result.conf = conf
170170
result.cache = cache
171-
result.outDir = conf.outDir
171+
result.outDir = conf.outDir.string
172172
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
173173
conf.configVars, filename.string, {roSupportRawDirective, roSupportMarkdown},
174174
docgenFindFile, compilerMsgHandler)
@@ -230,8 +230,8 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
230230
if gotten != status:
231231
rawMessage(conf, errGenerated, "snippet failed: cmd: '$1' status: $2 expected: $3 output: $4" % [cmd, $gotten, $status, output])
232232
result.emitted = initIntSet()
233-
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false)
234-
result.thisDir = result.destFile.splitFile.dir
233+
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false).string
234+
result.thisDir = result.destFile.AbsoluteFile.splitFile.dir
235235

236236
template dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
237237
if conf.cmd != cmdRst2tex: dest.addf(xml, args)
@@ -849,7 +849,7 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind, docFlags: DocFlags) =
849849
symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope,
850850
deprecationMsgRope]))
851851

852-
let external = d.destFile.relativeTo(d.conf.outDir, '/').changeFileExt(HtmlExt).string
852+
let external = d.destFile.AbsoluteFile.relativeTo(d.conf.outDir, '/').changeFileExt(HtmlExt).string
853853

854854
var attype: Rope
855855
if k in routineKinds and nameNode.kind == nkSym:
@@ -1237,14 +1237,14 @@ proc genOutFile(d: PDoc, groupedToc = false): Rope =
12371237
content = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, bodyname), ["title",
12381238
"tableofcontents", "moduledesc", "date", "time", "content", "deprecationMsg", "theindexhref", "body_toc_groupsection"],
12391239
[title.rope, toc, d.modDesc, rope(getDateStr()),
1240-
rope(getClockStr()), code, d.modDeprecationMsg, relLink(d.conf.outDir, d.destFile, theindexFname.RelativeFile), groupsection.rope])
1240+
rope(getClockStr()), code, d.modDeprecationMsg, relLink(d.conf.outDir, d.destFile.AbsoluteFile, theindexFname.RelativeFile), groupsection.rope])
12411241
if optCompileOnly notin d.conf.globalOptions:
12421242
# XXX what is this hack doing here? 'optCompileOnly' means raw output!?
12431243
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), [
12441244
"nimdoccss", "dochackjs", "title", "tableofcontents", "moduledesc", "date", "time",
12451245
"content", "author", "version", "analytics", "deprecationMsg"],
1246-
[relLink(d.conf.outDir, d.destFile, nimdocOutCss.RelativeFile),
1247-
relLink(d.conf.outDir, d.destFile, docHackJsFname.RelativeFile),
1246+
[relLink(d.conf.outDir, d.destFile.AbsoluteFile, nimdocOutCss.RelativeFile),
1247+
relLink(d.conf.outDir, d.destFile.AbsoluteFile, docHackJsFname.RelativeFile),
12481248
title.rope, toc, d.modDesc, rope(getDateStr()), rope(getClockStr()),
12491249
content, d.meta[metaAuthor].rope, d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
12501250
else:
@@ -1271,7 +1271,7 @@ proc writeOutput*(d: PDoc, useWarning = false, groupedToc = false) =
12711271
if optStdout in d.conf.globalOptions:
12721272
writeRope(stdout, content)
12731273
else:
1274-
template outfile: untyped = d.destFile
1274+
template outfile: untyped = d.destFile.AbsoluteFile
12751275
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt)
12761276
let dir = outfile.splitFile.dir
12771277
createDir(dir)
@@ -1300,13 +1300,13 @@ proc writeOutputJson*(d: PDoc, useWarning = false) =
13001300
write(stdout, $content)
13011301
else:
13021302
var f: File
1303-
if open(f, d.destFile.string, fmWrite):
1303+
if open(f, d.destFile, fmWrite):
13041304
write(f, $content)
13051305
close(f)
1306-
updateOutfile(d, d.destFile)
1306+
updateOutfile(d, d.destFile.AbsoluteFile)
13071307
else:
13081308
localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1),
1309-
warnUser, "unable to open file \"" & d.destFile.string &
1309+
warnUser, "unable to open file \"" & d.destFile &
13101310
"\" for writing")
13111311

13121312
proc handleDocOutputOptions*(conf: ConfigRef) =

compiler/semcall.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
230230
doAssert err.firstMismatch.formal != nil
231231
candidates.add("\n required type for " & nameParam & ": ")
232232
candidates.add typeToString(wanted)
233+
when false:
234+
if wanted.sym != nil:
235+
candidates.add "(" & (c.config $ wanted.sym.info) & ")"
233236
candidates.add "\n but expression '"
234237
if err.firstMismatch.kind == kVarNeeded:
235238
candidates.add renderNotLValue(nArg)
@@ -239,6 +242,10 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
239242
candidates.add "' is of type: "
240243
var got = nArg.typ
241244
candidates.add typeToString(got)
245+
when false:
246+
if got.sym != nil:
247+
candidates.add "(" & (c.config $ got.sym.info) & ")"
248+
242249
doAssert wanted != nil
243250
if got != nil: effectProblem(wanted, got, candidates, c)
244251
of kUnknown: discard "do not break 'nim check'"

lib/packages/docutils/rstgen.nim

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
2929
algorithm, parseutils
30-
import "$lib/../compiler/nimpaths"
31-
import "$lib/../compiler/pathutils"
30+
3231
import ../../std/private/since
3332

3433
const
@@ -58,8 +57,8 @@ type
5857
options*: RstParseOptions
5958
findFile*: FindFileHandler
6059
msgHandler*: MsgHandler
61-
outDir*: AbsoluteDir ## output directory, initialized by docgen.nim
62-
destFile*: AbsoluteFile ## output (HTML) file, initialized by docgen.nim
60+
outDir*: string ## output directory, initialized by docgen.nim
61+
destFile*: string ## output (HTML) file, initialized by docgen.nim
6362
filename*: string ## source Nim or Rst file
6463
meta*: array[MetaEnum, string]
6564
currentSection: string ## \
@@ -84,7 +83,7 @@ type
8483
status: int
8584

8685
proc prettyLink*(file: string): string =
87-
changeFileExt(file, "").replace(dotdotMangle, "..")
86+
changeFileExt(file, "").replace("_._", "..")
8887

8988
proc init(p: var CodeBlockParams) =
9089
## Default initialisation of CodeBlockParams to sane values.
@@ -759,13 +758,13 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
759758
# Generate index entry using spaces to indicate TOC level for the output HTML.
760759
assert n.level >= 0
761760
let
762-
htmlFileRelPath = if d.outDir.isEmpty():
761+
htmlFileRelPath = if d.outDir.len == 0:
763762
# /foo/bar/zoo.nim -> zoo.html
764763
changeFileExt(extractFilename(d.filename), HtmlExt)
765764
else: # d is initialized in docgen.nim
766765
# outDir = /foo -\
767766
# destFile = /foo/bar/zoo.html -|-> bar/zoo.html
768-
d.destFile.relativeTo(d.outDir, '/').string
767+
d.destFile.relativePath(d.outDir, '/')
769768
setIndexTerm(d, htmlFileRelPath, refname, tmp.stripTocHtml,
770769
spaces(max(0, n.level)) & tmp)
771770

0 commit comments

Comments
 (0)