Skip to content

Commit ef53031

Browse files
authored
fix prelude regression refs #16238: include prelude doesn't interfere with nim doc (#17111)
* fix bug1 from #16238 nim doc now works with include prelude * fix for windows * fixup
1 parent f07a072 commit ef53031

File tree

3 files changed

+16
-42
lines changed

3 files changed

+16
-42
lines changed

doc/prelude.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/pure/prelude.nim

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77
# distribution, for details about the copyright.
88
#
99

10-
## This is an include file that simply imports common modules for your
11-
## convenience:
12-
##
13-
## .. code-block:: nim
14-
## include std/prelude
15-
##
16-
## Same as:
17-
##
18-
## .. code-block:: nim
19-
## import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt]
10+
when defined(nimdoc) and isMainModule:
11+
from std/compileSettings import nil
12+
when compileSettings.querySetting(compileSettings.SingleValueSetting.projectFull) == currentSourcePath:
13+
## This is an include file that simply imports common modules for your convenience.
14+
runnableExamples:
15+
include std/prelude
16+
# same as:
17+
# import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt]
18+
let x = 1
19+
assert "foo $# $#" % [$x, "bar"] == "foo 1 bar"
20+
assert toSeq(1..3) == @[1, 2, 3]
21+
when not defined(js) or defined(nodejs):
22+
assert getCurrentDir().len > 0
23+
assert ($now()).startsWith "20"
2024

21-
# xxx deduplicate with prelude.rst
25+
# xxx `nim doc -b:js -d:nodejs --doccmd:-d:nodejs lib/pure/prelude.nim` fails for some reason
26+
# specific to `nim doc`, but the code otherwise works with nodejs.
2227

2328
import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt]
24-

tools/kochdocs.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ lib/posix/termios.nim
143143

144144
# some of these are include files so shouldn't be docgen'd
145145
ignoredModules = """
146-
lib/pure/prelude.nim
147146
lib/pure/future.nim
148147
lib/pure/collections/hashcommon.nim
149148
lib/pure/collections/tableimpl.nim

0 commit comments

Comments
 (0)