|
7 | 7 | # distribution, for details about the copyright.
|
8 | 8 | #
|
9 | 9 |
|
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" |
20 | 24 |
|
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. |
22 | 27 |
|
23 | 28 | import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt]
|
24 |
| - |
|
0 commit comments