Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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) =
Expand Down
7 changes: 7 additions & 0 deletions compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'"
Expand Down
13 changes: 6 additions & 7 deletions lib/packages/docutils/rstgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
algorithm, parseutils
import "$lib/../compiler/nimpaths"
import "$lib/../compiler/pathutils"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See? This is completely broken.

import ../../std/private/since

const
Expand Down Expand Up @@ -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 ## \
Expand All @@ -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.
Expand Down Expand Up @@ -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)

Expand Down