After most recent improvements to doc generation I see this error running nim doc :
/home/lxuser/.cache/nim/cxtimeb_d/runnableExamples/cxtimeb_examples1.nim(15, 12) Error: undeclared identifier: 'toSeq'
[runnableExamples] failed: generated file: '/home/lxuser/.cache/nim/cxtimeb_d/runnableExamples/cxtimeb_group0_examples.nim' group: '(rdoccmd: "", docCmd: "", code: "# autogenerated by docgen\n#
There are no runnableExamples in cxtimeb.nim .
The module itself compiles and works fine.
The autogenerated cxtimeb_examples1.nim does not import sequtils hence toSeq causes an error.
runnableExamples:
import sequtils
echo toSeq(1..10)
There are no runnableExamples in my module.
The module imports sequtils
The only way I found to circumvent this error in docgen is to add following line
in my module :
export sequtils
I think this should not be required.
Here a mini example which displays this error on nim-devel :
#cxtimeb.nim
import sequtils
template doit():untyped =
## doit
## return output only
toSeq([1,2,3,4,5])
echo doit()
Output ok :
@[1, 2, 3, 4, 5]
nim doc cxtimeb.nim
/home/lxuser/.cache/nim/cxtimeb_d/runnableExamples/cxtimeb_examples1.nim(15, 12) Error: undeclared identifier: 'toSeq'
[runnableExamples] failed: generated file: '/home/lxuser/.cache/nim/cxtimeb_d/runnableExamples/cxtimeb_group0_examples.nim' group: '(rdoccmd: "", docCmd: ""
hmm... I did not occured error.
My environment is here.
$ nim --version
Nim Compiler Version 1.2.0 [Linux: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
⟩ cat /etc/os-release
NAME="Ubuntu"
VERSION="19.10 (Eoan Ermine)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.10"
VERSION_ID="19.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=eoan
UBUNTU_CODENAME=eoan
⟩ cat main.nim
import sequtils
template doit():untyped =
## doit
## return output only
toSeq([1,2,3,4,5])
echo doit()
/tmp
⟩ nim doc main.nim
Hint: used config file '/home/vagrant/.choosenim/toolchains/nim-1.2.0/config/nim.cfg' [Conf]
Hint: used config file '/home/vagrant/.choosenim/toolchains/nim-1.2.0/config/nimdoc.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: main [Processing]
Hint: sequtils [Processing]
Hint: macros [Processing]
Hint: 17834 LOC; 0.108 sec; 15.91MiB peakmem; Debug build; proj: /tmp/main.nim; out: /tmp/main.html [SuccessX]
I have seen a similar issue on nim devel too. I am trying to create a reproducible example for that.
I also see runnableExamples trying to get executed from sequtils.. My Nim module does import sequtils, but there are no runnableExamples in it.
Also, I think this issue happens when I have --path switches in my config.nims .. the nim doc doesn't seem to find modules that are specified via --path or --NimblePath. It only recognizes packages installed in the default ~/.nimble.