diff options
Diffstat (limited to 'lib')
42 files changed, 121 insertions, 121 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index fb23954c0..b73e0295a 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -1459,7 +1459,7 @@ macro expandMacros*(body: typed): untyped = ## For instance, ## ## .. code-block:: nim - ## import sugar, macros + ## import std/[sugar, macros] ## ## let ## x = 10 @@ -1657,7 +1657,7 @@ proc extractDocCommentsAndRunnables*(n: NimNode): NimNode = ## Example: ## ## .. code-block:: nim - ## import macros + ## import std/macros ## macro transf(a): untyped = ## result = quote do: ## proc fun2*() = discard diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index fcc29a205..242ea1b0d 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -31,7 +31,7 @@ ## ---------------------------------- ## ## .. code-block:: Nim -## import db_mysql +## import std/db_mysql ## let db = open("localhost", "user", "password", "dbname") ## db.close() ## @@ -56,7 +56,7 @@ ## ## .. code-block:: Nim ## -## import db_mysql, math +## import std/[db_mysql, math] ## ## let theDb = open("localhost", "nim", "nim", "test") ## diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index d9c8d035a..1e4032b34 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -37,7 +37,7 @@ ## ---------------------------------- ## ## .. code-block:: Nim -## import db_odbc +## import std/db_odbc ## var db = open("localhost", "user", "password", "dbname") ## db.close() ## @@ -62,7 +62,7 @@ ## ## .. code-block:: Nim ## -## import db_odbc, math +## import std/[db_odbc, math] ## ## var theDb = open("localhost", "nim", "nim", "test") ## diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index aea3ece71..034a94852 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -47,7 +47,7 @@ ## To use Unix sockets with `db_postgres`, change the server address to the socket file path: ## ## .. code-block:: Nim -## import db_postgres ## Change "localhost" or "127.0.0.1" to the socket file path +## import std/db_postgres ## Change "localhost" or "127.0.0.1" to the socket file path ## let db = db_postgres.open("/run/postgresql", "user", "password", "database") ## echo db.getAllRows(sql"SELECT version();") ## db.close() @@ -64,7 +64,7 @@ ## ---------------------------------- ## ## .. code-block:: Nim -## import db_postgres +## import std/db_postgres ## let db = open("localhost", "user", "password", "dbname") ## db.close() ## diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index 73657b510..6ca81db9e 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -35,7 +35,7 @@ ## ## .. code-block:: Nim ## -## import db_sqlite +## import std/db_sqlite ## ## # user, password, database name can be empty. ## # These params are not used on db_sqlite module. @@ -66,7 +66,7 @@ ## ## .. code-block:: nim ## -## import db_sqlite, math +## import std/[db_sqlite, math] ## ## let db = open("mytest.db", "", "", "") ## @@ -99,7 +99,7 @@ ## ## .. code-block:: nim ## -## import random +## import std/random ## ## ## Generate random float datas ## var orig = newSeq[float64](150) diff --git a/lib/impure/nre.nim b/lib/impure/nre.nim index a4d0e02ae..7b2d7d3ee 100644 --- a/lib/impure/nre.nim +++ b/lib/impure/nre.nim @@ -26,7 +26,7 @@ when defined(js): ## ## .. code-block:: nim ## -## import nre except toSeq +## import std/nre except toSeq ## ## ## Licencing diff --git a/lib/impure/re.nim b/lib/impure/re.nim index e881e91f6..0c96876b9 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -274,7 +274,7 @@ proc match*(s: string, pattern: Regex, matches: var openArray[string], ## returned. ## runnableExamples: - import sequtils + import std/sequtils var matches: array[2, string] if match("abcdefg", re"c(d)ef(g)", matches, 2): doAssert toSeq(matches) == @["d", "g"] @@ -494,7 +494,7 @@ iterator split*(s: string, sep: Regex; maxsplit = -1): string = ## Substrings are separated by the regular expression `sep` ## (and the portion matched by `sep` is not returned). runnableExamples: - import sequtils + import std/sequtils doAssert toSeq(split("00232this02939is39an22example111", re"\d+")) == @["", "this", "is", "an", "example", ""] var last = 0 diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index ef9188f75..d66597073 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1089,7 +1089,7 @@ template onSignal*(signals: varargs[cint], body: untyped) = ## Example: ## ## .. code-block:: - ## from posix import SIGINT, SIGTERM, onSignal + ## from std/posix import SIGINT, SIGTERM, onSignal ## onSignal(SIGINT, SIGTERM): ## echo "bye from signal ", sig diff --git a/lib/posix/posix_utils.nim b/lib/posix/posix_utils.nim index c53051b27..aeec73a45 100644 --- a/lib/posix/posix_utils.nim +++ b/lib/posix/posix_utils.nim @@ -117,7 +117,7 @@ proc osReleaseFile*(): Config {.since: (1, 5).} = ## `os-release` file is not available on Windows and OS X by design. ## * https://www.freedesktop.org/software/systemd/man/os-release.html runnableExamples: - import parsecfg + import std/parsecfg when defined(linux): let data = osReleaseFile() echo "OS name: ", data.getSectionValue("", "NAME") ## the data is up to each distro. diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim index 4a0db8f71..c51b338e3 100644 --- a/lib/pure/asyncfile.nim +++ b/lib/pure/asyncfile.nim @@ -10,7 +10,7 @@ ## This module implements asynchronous file reading and writing. ## ## .. code-block:: Nim -## import asyncfile, asyncdispatch, os +## import std/[asyncfile, asyncdispatch, os] ## ## proc main() {.async.} = ## var file = openAsync(getTempDir() / "foobar.txt", fmReadWrite) diff --git a/lib/pure/asyncftpclient.nim b/lib/pure/asyncftpclient.nim index 0c29837fe..0ee45785d 100644 --- a/lib/pure/asyncftpclient.nim +++ b/lib/pure/asyncftpclient.nim @@ -22,7 +22,7 @@ ## connect to an FTP server. You can do so with the `connect` procedure. ## ## .. code-block::nim -## import asyncdispatch, asyncftpclient +## import std/[asyncdispatch, asyncftpclient] ## proc main() {.async.} = ## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test") ## await ftp.connect() @@ -42,7 +42,7 @@ ## instead specify an absolute path. ## ## .. code-block::nim -## import asyncdispatch, asyncftpclient +## import std/[asyncdispatch, asyncftpclient] ## proc main() {.async.} = ## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test") ## await ftp.connect() @@ -63,7 +63,7 @@ ## `progressInterval` milliseconds. ## ## .. code-block::nim -## import asyncdispatch, asyncftpclient +## import std/[asyncdispatch, asyncftpclient] ## ## proc onProgressChanged(total, progress: BiggestInt, ## speed: float) {.async.} = diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim index 41c4dec09..f5baf1517 100644 --- a/lib/pure/asynchttpserver.nim +++ b/lib/pure/asynchttpserver.nim @@ -19,7 +19,7 @@ runnableExamples: # respond to all requests with a `200 OK` response code and "Hello World" # as the response body. Run locally with: # `nim doc --doccmd:-d:nimAsyncHttpServerEnableTest --lib:lib lib/pure/asynchttpserver.nim` - import asyncdispatch + import std/asyncdispatch if defined(nimAsyncHttpServerEnableTest): proc main {.async.} = const port = 8080 @@ -78,9 +78,9 @@ func getSocket*(a: AsyncHttpServer): AsyncSocket {.since: (1, 5, 1).} = ## Useful for identifying what port the AsyncHttpServer is bound to, if it ## was chosen automatically. runnableExamples: - from asyncdispatch import Port - from asyncnet import getFd - from nativesockets import getLocalAddr, AF_INET + from std/asyncdispatch import Port + from std/asyncnet import getFd + from std/nativesockets import getLocalAddr, AF_INET let server = newAsyncHttpServer() server.listen(Port(0)) # Socket is not bound until this point let port = getLocalAddr(server.getSocket.getFd, AF_INET)[1] @@ -113,7 +113,7 @@ proc respond*(req: Request, code: HttpCode, content: string, ## Example: ## ## .. code-block::nim - ## import json + ## import std/json ## proc handler(req: Request) {.async.} = ## if req.url.path == "/hello-world": ## let msg = %* {"message": "Hello World"} diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 346e5cbac..7db8ce41e 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -67,7 +67,7 @@ ## ## .. code-block::nim ## -## import asyncnet, asyncdispatch +## import std/[asyncnet, asyncdispatch] ## ## var clients {.threadvar.}: seq[AsyncSocket] ## diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim index a590ac002..bf196b54d 100644 --- a/lib/pure/base64.nim +++ b/lib/pure/base64.nim @@ -24,14 +24,14 @@ ## ------------- ## ## .. code-block::nim -## import base64 +## import std/base64 ## let encoded = encode("Hello World") ## assert encoded == "SGVsbG8gV29ybGQ=" ## ## Apart from strings you can also encode lists of integers or characters: ## ## .. code-block::nim -## import base64 +## import std/base64 ## let encodedInts = encode([1,2,3]) ## assert encodedInts == "AQID" ## let encodedChars = encode(['h','e','y']) @@ -42,7 +42,7 @@ ## ------------- ## ## .. code-block::nim -## import base64 +## import std/base64 ## let decoded = decode("SGVsbG8gV29ybGQ=") ## assert decoded == "Hello World" ## @@ -50,7 +50,7 @@ ## --------------- ## ## .. code-block::nim -## import base64 +## import std/base64 ## doAssert encode("c\xf7>", safe = true) == "Y_c-" ## doAssert encode("c\xf7>", safe = false) == "Y/c+" ## diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index 8cc0284b4..fd5089dbb 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -11,7 +11,7 @@ ## ## .. code-block:: Nim ## -## import strtabs, cgi +## import std/[strtabs, cgi] ## ## # Fill the values when debugging: ## when debug: diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index dd2203e13..e12984995 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -13,7 +13,7 @@ ## (A crit bit tree is a form of `radix tree`:idx: or `patricia trie`:idx:.) runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq var critbitAsSet: CritBitTree[void] = ["kitten", "puppy"].toCritBitTree doAssert critbitAsSet.len == 2 @@ -335,7 +335,7 @@ iterator leaves[T](n: Node[T]): Node[T] = iterator keys*[T](c: CritBitTree[T]): string = ## Yields all keys in lexicographical order. runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 1, "key2": 2}.toCritBitTree doAssert toSeq(c.keys) == @["key1", "key2"] @@ -349,7 +349,7 @@ iterator values*[T](c: CritBitTree[T]): T = ## **See also:** ## * `mvalues iterator <#mvalues.i,CritBitTree[T]>`_ runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 1, "key2": 2}.toCritBitTree doAssert toSeq(c.values) == @[1, 2] @@ -375,7 +375,7 @@ iterator pairs*[T](c: CritBitTree[T]): tuple[key: string, val: T] = ## **See also:** ## * `mpairs iterator <#mpairs.i,CritBitTree[T]>`_ runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 1, "key2": 2}.toCritBitTree doAssert toSeq(c.pairs) == @[(key: "key1", val: 1), (key: "key2", val: 2)] @@ -407,7 +407,7 @@ proc allprefixedAux[T](c: CritBitTree[T], key: string): Node[T] = iterator keysWithPrefix*[T](c: CritBitTree[T], prefix: string): string = ## Yields all keys starting with `prefix`. runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 42, "key2": 43}.toCritBitTree doAssert toSeq(c.keysWithPrefix("key")) == @["key1", "key2"] @@ -422,7 +422,7 @@ iterator valuesWithPrefix*[T](c: CritBitTree[T], prefix: string): T = ## **See also:** ## * `mvaluesWithPrefix iterator <#mvaluesWithPrefix.i,CritBitTree[T],string>`_ runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 42, "key2": 43}.toCritBitTree doAssert toSeq(c.valuesWithPrefix("key")) == @[42, 43] @@ -451,7 +451,7 @@ iterator pairsWithPrefix*[T](c: CritBitTree[T], ## **See also:** ## * `mpairsWithPrefix iterator <#mpairsWithPrefix.i,CritBitTree[T],string>`_ runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let c = {"key1": 42, "key2": 43}.toCritBitTree doAssert toSeq(c.pairsWithPrefix("key")) == @[(key: "key1", val: 42), (key: "key2", val: 43)] diff --git a/lib/pure/collections/deques.nim b/lib/pure/collections/deques.nim index 7614b9d20..a75de0dfb 100644 --- a/lib/pure/collections/deques.nim +++ b/lib/pure/collections/deques.nim @@ -200,7 +200,7 @@ iterator items*[T](deq: Deque[T]): T = ## **See also:** ## * `mitems iterator <#mitems,Deque[T]>`_ runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let a = [10, 20, 30, 40, 50].toDeque assert toSeq(a.items) == @[10, 20, 30, 40, 50] @@ -230,7 +230,7 @@ iterator mitems*[T](deq: var Deque[T]): var T = iterator pairs*[T](deq: Deque[T]): tuple[key: int, val: T] = ## Yields every `(position, value)`-pair of `deq`. runnableExamples: - from sequtils import toSeq + from std/sequtils import toSeq let a = [10, 20, 30].toDeque assert toSeq(a.pairs) == @[(0, 10), (1, 20), (2, 30)] diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim index e1c3808b2..edb852999 100644 --- a/lib/pure/collections/lists.nim +++ b/lib/pure/collections/lists.nim @@ -165,7 +165,7 @@ proc newSinglyLinkedNode*[T](value: T): <//>(SinglyLinkedNode[T]) = func toSinglyLinkedList*[T](elems: openArray[T]): SinglyLinkedList[T] {.since: (1, 5, 1).} = ## Creates a new `SinglyLinkedList` from members of `elems`. runnableExamples: - import sequtils + import std/sequtils let a = [1, 2, 3, 4, 5].toSinglyLinkedList assert a.toSeq == [1, 2, 3, 4, 5] result = initSinglyLinkedList[T]() @@ -175,7 +175,7 @@ func toSinglyLinkedList*[T](elems: openArray[T]): SinglyLinkedList[T] {.since: ( func toDoublyLinkedList*[T](elems: openArray[T]): DoublyLinkedList[T] {.since: (1, 5, 1).} = ## Creates a new `DoublyLinkedList` from members of `elems`. runnableExamples: - import sequtils + import std/sequtils let a = [1, 2, 3, 4, 5].toDoublyLinkedList assert a.toSeq == [1, 2, 3, 4, 5] result = initDoublyLinkedList[T]() @@ -359,7 +359,7 @@ proc prepend*[T: SomeLinkedList](a: var T, b: T) {.since: (1, 5, 1).} = ## * `prependMoved proc <#prependMoved,DoublyLinkedList[T],DoublyLinkedList[T]>`_ ## for moving the second list instead of copying runnableExamples: - import sequtils + import std/sequtils var a = [4, 5].toSinglyLinkedList let b = [1, 2, 3].toSinglyLinkedList a.prepend b @@ -476,7 +476,7 @@ proc prepend*[T](L: var SinglyLinkedList[T], value: T) {.inline.} = func copy*[T](a: SinglyLinkedList[T]): SinglyLinkedList[T] {.since: (1, 5, 1).} = ## Creates a shallow copy of `a`. runnableExamples: - import sequtils + import std/sequtils type Foo = ref object x: int var @@ -675,7 +675,7 @@ proc add*[T: SomeLinkedList](a: var T, b: T) {.since: (1, 5, 1).} = ## * `addMoved proc <#addMoved,DoublyLinkedList[T],DoublyLinkedList[T]>`_ ## for moving the second list instead of copying runnableExamples: - import sequtils + import std/sequtils var a = [1, 2, 3].toSinglyLinkedList let b = [4, 5].toSinglyLinkedList a.add b diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index 0872257f4..e937b8394 100644 --- a/lib/pure/collections/sequtils.nim +++ b/lib/pure/collections/sequtils.nim @@ -39,7 +39,7 @@ ## `method call syntax<manual.html#procedures-method-call-syntax>`_. runnableExamples: - import sugar + import std/sugar # Creating a sequence from 1 to 10, multiplying each member by 2, # keeping only the members which are not divisible by 6. @@ -62,7 +62,7 @@ runnableExamples: runnableExamples: - from strutils import join + from std/strutils import join let vowels = @"aeiou" diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 74f658261..e19298239 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -774,7 +774,7 @@ iterator allValues*[A, B](t: Table[A, B]; key: A): B {.deprecated: ## `add proc<#add,Table[A,B],A,sinkB>`_). ## runnableExamples: - import sequtils, algorithm + import std/[sequtils, algorithm] var a = {'a': 3, 'b': 5}.toTable for i in 1..3: a.add('z', 10*i) diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim index caf2c1ec3..f7f87dee7 100644 --- a/lib/pure/dynlib.nim +++ b/lib/pure/dynlib.nim @@ -24,7 +24,7 @@ ## ## .. code-block::nim ## -## import dynlib +## import std/dynlib ## ## type ## greetFunction = proc(): cstring {.gcsafe, stdcall.} diff --git a/lib/pure/htmlparser.nim b/lib/pure/htmlparser.nim index 05bfbfe4d..c572146a7 100644 --- a/lib/pure/htmlparser.nim +++ b/lib/pure/htmlparser.nim @@ -32,11 +32,11 @@ ## .. code-block:: Nim ## :test: ## -## import htmlparser -## import xmltree # To use '$' for XmlNode -## import strtabs # To access XmlAttributes -## import os # To use splitFile -## import strutils # To use cmpIgnoreCase +## import std/htmlparser +## import std/xmltree # To use '$' for XmlNode +## import std/strtabs # To access XmlAttributes +## import std/os # To use splitFile +## import std/strutils # To use cmpIgnoreCase ## ## proc transformHyperlinks() = ## let html = loadHtml("input.html") @@ -365,7 +365,7 @@ proc htmlTag*(s: string): HtmlTag = proc runeToEntity*(rune: Rune): string = ## converts a Rune to its numeric HTML entity equivalent. runnableExamples: - import unicode + import std/unicode doAssert runeToEntity(Rune(0)) == "" doAssert runeToEntity(Rune(-1)) == "" doAssert runeToEntity("Ü".runeAt(0)) == "#220" @@ -378,7 +378,7 @@ proc entityToRune*(entity: string): Rune = ## or `Ü` to its UTF-8 equivalent. ## Rune(0) is returned if the entity name is unknown. runnableExamples: - import unicode + import std/unicode doAssert entityToRune("") == Rune(0) doAssert entityToRune("a") == Rune(0) doAssert entityToRune("gt") == ">".runeAt(0) diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 2b1672414..65e3dbd16 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -17,7 +17,7 @@ ## `http://google.com`: ## ## .. code-block:: Nim -## import httpclient +## import std/httpclient ## var client = newHttpClient() ## echo client.getContent("http://google.com") ## @@ -25,7 +25,7 @@ ## `AsyncHttpClient`: ## ## .. code-block:: Nim -## import asyncdispatch, httpclient +## import std/[asyncdispatch, httpclient] ## ## proc asyncProc(): Future[string] {.async.} = ## var client = newAsyncHttpClient() @@ -74,7 +74,7 @@ ## and uses a json object for the body ## ## .. code-block:: Nim -## import httpclient, json +## import std/[httpclient, json] ## ## let client = newHttpClient() ## client.headers = newHttpHeaders({ "Content-Type": "application/json" }) @@ -92,7 +92,7 @@ ## progress of the HTTP request. ## ## .. code-block:: Nim -## import asyncdispatch, httpclient +## import std/[asyncdispatch, httpclient] ## ## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = ## echo("Downloaded ", progress, " of ", total) @@ -149,7 +149,7 @@ ## Here is how to set a timeout when creating an `HttpClient` instance: ## ## .. code-block:: Nim -## import httpclient +## import std/httpclient ## ## let client = newHttpClient(timeout = 42) ## @@ -163,7 +163,7 @@ ## Some examples on how to configure a Proxy for `HttpClient`: ## ## .. code-block:: Nim -## import httpclient +## import std/httpclient ## ## let myProxy = newProxy("http://myproxy.network") ## let client = newHttpClient(proxy = myProxy) @@ -171,7 +171,7 @@ ## Get Proxy URL from environment variables: ## ## .. code-block:: Nim -## import httpclient +## import std/httpclient ## ## var url = "" ## try: @@ -195,7 +195,7 @@ ## Here you can see an example about how to set the `maxRedirects` of `HttpClient`: ## ## .. code-block:: Nim -## import httpclient +## import std/httpclient ## ## let client = newHttpClient(maxRedirects = 0) ## @@ -573,7 +573,7 @@ proc newHttpClient*(userAgent = defUserAgent, maxRedirects = 5, ## ## `headers` specifies the HTTP Headers. runnableExamples: - import asyncdispatch, httpclient, strutils + import std/[asyncdispatch, httpclient, strutils] proc asyncProc(): Future[string] {.async.} = var client = newAsyncHttpClient() diff --git a/lib/pure/json.nim b/lib/pure/json.nim index d610edcbf..6d94de9ac 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -34,7 +34,7 @@ ## the ``[]`` operator. The following example shows how to do this: ## ## .. code-block:: Nim -## import json +## import std/json ## ## let jsonNode = parseJson("""{"key": 3.14}""") ## @@ -55,7 +55,7 @@ ## To retrieve the value of ``"key"`` you can do the following: ## ## .. code-block:: Nim -## import json +## import std/json ## ## let jsonNode = parseJson("""{"key": 3.14}""") ## @@ -72,7 +72,7 @@ ## type's default value when called on ``nil``. ## ## .. code-block:: Nim -## import json +## import std/json ## ## let jsonNode = parseJson("{}") ## @@ -88,7 +88,7 @@ ## you to fallback to a default value should the key's values be ``null``: ## ## .. code-block:: Nim -## import json +## import std/json ## ## let jsonNode = parseJson("""{"key": 3.14, "key2": null}""") ## @@ -106,8 +106,8 @@ ## responses, and backticks around keys with a reserved keyword as name. ## ## .. code-block:: Nim -## import json -## import options +## import std/json +## import std/options ## ## type ## User = object @@ -127,7 +127,7 @@ ## operator: ## ## .. code-block:: nim -## import json +## import std/json ## ## var hisName = "John" ## let herAge = 31 diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index 06987d395..ee07cd8f3 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -18,7 +18,7 @@ ## To get started, first create a logger: ## ## .. code-block:: -## import logging +## import std/logging ## ## var logger = newConsoleLogger() ## @@ -60,7 +60,7 @@ ## in the following example: ## ## .. code-block:: -## import logging +## import std/logging ## ## var consoleLog = newConsoleLogger() ## var fileLog = newFileLogger("errors.log", levelThreshold=lvlError) @@ -118,7 +118,7 @@ ## The following example illustrates how to use format strings: ## ## .. code-block:: -## import logging +## import std/logging ## ## var logger = newConsoleLogger(fmtStr="[$time] - $levelname: ") ## logger.log(lvlInfo, "this is a message") diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 00dc907e0..a4d8409d7 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -1593,7 +1593,7 @@ proc execCmdEx*(command: string, options: set[ProcessOption] = { ## ## .. code-block:: Nim ## var result = execCmdEx("nim r --hints:off -", options = {}, input = "echo 3*4") - ## import strutils, strtabs + ## import std/[strutils, strtabs] ## stripLineEnd(result[0]) ## portable way to remove trailing newline, if any ## doAssert result == ("12", 0) ## doAssert execCmdEx("ls --nonexistant").exitCode != 0 diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim index df08135f7..23bb09ac4 100644 --- a/lib/pure/parsecfg.nim +++ b/lib/pure/parsecfg.nim @@ -22,7 +22,7 @@ ## ## .. code-block:: nim ## -## import os, parsecfg, strutils, streams +## import std/[os, parsecfg, strutils, streams] ## ## var f = newFileStream(paramStr(1), fmRead) ## if f != nil: @@ -66,7 +66,7 @@ ## ----------------------------- ## .. code-block:: nim ## -## import parsecfg +## import std/parsecfg ## var dict=newConfig() ## dict.setSectionKey("","charset","utf-8") ## dict.setSectionKey("Package","name","hello") @@ -80,7 +80,7 @@ ## ---------------------------- ## .. code-block:: nim ## -## import parsecfg +## import std/parsecfg ## var dict = loadConfig("config.ini") ## var charset = dict.getSectionValue("","charset") ## var threads = dict.getSectionValue("Package","--threads") @@ -94,7 +94,7 @@ ## ------------------------------ ## .. code-block:: nim ## -## import parsecfg +## import std/parsecfg ## var dict = loadConfig("config.ini") ## dict.setSectionKey("Author","name","lhf") ## dict.writeConfig("config.ini") @@ -103,7 +103,7 @@ ## ---------------------------------------------- ## .. code-block:: nim ## -## import parsecfg +## import std/parsecfg ## var dict = loadConfig("config.ini") ## dict.delSectionKey("Author","email") ## dict.writeConfig("config.ini") @@ -115,7 +115,7 @@ # taken from https://docs.python.org/3/library/configparser.html#supported-ini-file-structure runnableExamples: - import streams + import std/streams var dict = loadConfig(newStringStream("""[Simple Values] key=value diff --git a/lib/pure/parsecsv.nim b/lib/pure/parsecsv.nim index 4a7117dc5..1e34f3649 100644 --- a/lib/pure/parsecsv.nim +++ b/lib/pure/parsecsv.nim @@ -14,9 +14,9 @@ ## =========== ## ## .. code-block:: nim -## import parsecsv -## from os import paramStr -## from streams import newFileStream +## import std/parsecsv +## from std/os import paramStr +## from std/streams import newFileStream ## ## var s = newFileStream(paramStr(1), fmRead) ## if s == nil: @@ -34,7 +34,7 @@ ## reference for item access with `rowEntry <#rowEntry,CsvParser,string>`_: ## ## .. code-block:: nim -## import parsecsv +## import std/parsecsv ## ## # Prepare a file ## let content = """One,Two,Three,Four @@ -120,7 +120,7 @@ proc open*(my: var CsvParser, input: Stream, filename: string, ## * `open proc <#open,CsvParser,string,char,char,char>`_ which creates the ## file stream for you runnableExamples: - import streams + import std/streams var strm = newStringStream("One,Two,Three\n1,2,3\n10,20,30") var parser: CsvParser parser.open(strm, "tmp.csv") @@ -142,7 +142,7 @@ proc open*(my: var CsvParser, filename: string, ## Similar to the `other open proc<#open,CsvParser,Stream,string,char,char,char>`_, ## but creates the file stream for you. runnableExamples: - from os import removeFile + from std/os import removeFile writeFile("tmp.csv", "One,Two,Three\n1,2,3\n10,20,300") var parser: CsvParser parser.open("tmp.csv") @@ -203,7 +203,7 @@ proc processedRows*(my: var CsvParser): int = ## But even if `readRow <#readRow,CsvParser,int>`_ arrived at EOF then ## processed rows counter is incremented. runnableExamples: - import streams + import std/streams var strm = newStringStream("One,Two,Three\n1,2,3") var parser: CsvParser @@ -229,7 +229,7 @@ proc readRow*(my: var CsvParser, columns = 0): bool = ## ## Blank lines are skipped. runnableExamples: - import streams + import std/streams var strm = newStringStream("One,Two,Three\n1,2,3\n\n10,20,30") var parser: CsvParser parser.open(strm, "tmp.csv") @@ -296,7 +296,7 @@ proc readHeaderRow*(my: var CsvParser) = ## See also: ## * `rowEntry proc <#rowEntry,CsvParser,string>`_ runnableExamples: - import streams + import std/streams var strm = newStringStream("One,Two,Three\n1,2,3") var parser: CsvParser @@ -325,7 +325,7 @@ proc rowEntry*(my: var CsvParser, entry: string): var string = ## ## If specified `entry` does not exist, raises KeyError. runnableExamples: - import streams + import std/streams var strm = newStringStream("One,Two,Three\n1,2,3\n\n10,20,30") var parser: CsvParser parser.open(strm, "tmp.csv") diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index e79e53bd8..9de7402d6 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -49,7 +49,7 @@ ## Here is an example: ## ## .. code-block:: -## import parseopt +## import std/parseopt ## ## var p = initOptParser("-ab -e:5 --foo --bar=20 file.txt") ## while true: @@ -99,7 +99,7 @@ ## arguments for those two parameters: ## ## .. code-block:: -## import parseopt +## import std/parseopt ## ## proc printToken(kind: CmdLineKind, key: string, val: string) = ## case kind diff --git a/lib/pure/parseutils.nim b/lib/pure/parseutils.nim index 5ceff26a0..64949428f 100644 --- a/lib/pure/parseutils.nim +++ b/lib/pure/parseutils.nim @@ -26,7 +26,7 @@ ## ## .. code-block:: nim ## :test: -## from strutils import Digits, parseInt +## from std/strutils import Digits, parseInt ## ## let ## input1 = "2019 school start" diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index fd22cb165..06a77af57 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -941,7 +941,7 @@ template eventParser*(pegAst, handlers: untyped): (proc(s: string): int) = ## evaluates an arithmetic expression defined by a simple PEG: ## ## .. code-block:: nim - ## import strutils, pegs + ## import std/[strutils, pegs] ## ## let ## pegAst = """ diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 88def695d..eb1c9cc14 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -29,7 +29,7 @@ ## ## .. code-block:: Nim ## -## import streams +## import std/streams ## ## var strm = newStringStream("""The first line ## the second line @@ -54,7 +54,7 @@ ## ## .. code-block:: Nim ## -## import streams +## import std/streams ## ## var strm = newFileStream("somefile.txt", fmWrite) ## var line = "" @@ -74,7 +74,7 @@ ## ## .. code-block:: Nim ## -## import streams +## import std/streams ## ## var strm = newFileStream("somefile.txt", fmRead) ## var line = "" @@ -144,7 +144,7 @@ proc flush*(s: Stream) = ## See also: ## * `close proc <#close,Stream>`_ runnableExamples: - from os import removeFile + from std/os import removeFile var strm = newFileStream("somefile.txt", fmWrite) @@ -1387,7 +1387,7 @@ proc newFileStream*(filename: string, mode: FileMode = fmRead, ## * `openFileStream proc <#openFileStream,string,FileMode,int>`_ creates a ## file stream from the file name and the mode. runnableExamples: - from os import removeFile + from std/os import removeFile var strm = newFileStream("somefile.txt", fmWrite) if not isNil(strm): strm.writeLine("The first line") diff --git a/lib/pure/streamwrapper.nim b/lib/pure/streamwrapper.nim index b457e1be1..7a501760b 100644 --- a/lib/pure/streamwrapper.nim +++ b/lib/pure/streamwrapper.nim @@ -89,7 +89,7 @@ proc newPipeOutStream*[T](s: sink (ref T)): owned PipeOutStream[T] = ## Example: ## ## .. code-block:: Nim - ## import osproc, streamwrapper + ## import std/[osproc, streamwrapper] ## var ## p = startProcess(exePath) ## outStream = p.outputStream().newPipeOutStream() diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 9c55bf3e3..6bedf2de2 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -175,7 +175,7 @@ overloaded to handle both single characters and sets of character. .. code-block:: nim - import streams + import std/streams template atom(input: Stream; idx: int; c: char): bool = ## Used in scanp for the matching of atoms (usually chars). diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index d04c972d4..ba1c78479 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -38,7 +38,7 @@ runnableExamples: ## `method call syntax<manual.html#procedures-method-call-syntax>`_: runnableExamples: - from sequtils import map + from std/sequtils import map let jenny = "867-5309" assert jenny.split('-').map(parseInt) == @[867, 5309] diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 35dda131b..dc55c34ce 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -21,7 +21,7 @@ ======== .. code-block:: nim - import times, os + import std/[times, os] # Simple benchmarking let time = cpuTime() sleep(100) # Replace this with something to be timed diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim index d7d9600d1..bbe6a7cd4 100644 --- a/lib/std/jsonutils.nim +++ b/lib/std/jsonutils.nim @@ -280,7 +280,7 @@ proc fromJsonHook*[K, V](t: var (Table[K, V] | OrderedTable[K, V]), ## See also: ## * `toJsonHook proc<#toJsonHook>`_ runnableExamples: - import tables, json + import std/[tables, json] var foo: tuple[t: Table[string, int], ot: OrderedTable[string, int]] fromJson(foo, parseJson(""" {"t":{"two":2,"one":1},"ot":{"one":1,"three":3}}""")) @@ -300,7 +300,7 @@ proc toJsonHook*[K, V](t: (Table[K, V] | OrderedTable[K, V])): JsonNode = ## See also: ## * `fromJsonHook proc<#fromJsonHook,,JsonNode>`_ runnableExamples: - import tables, json + import std/[tables, json] let foo = ( t: [("two", 2)].toTable, ot: [("one", 1), ("three", 3)].toOrderedTable) @@ -316,7 +316,7 @@ proc fromJsonHook*[A](s: var SomeSet[A], jsonNode: JsonNode) = ## See also: ## * `toJsonHook proc<#toJsonHook,SomeSet[A]>`_ runnableExamples: - import sets, json + import std/[sets, json] var foo: tuple[hs: HashSet[string], os: OrderedSet[string]] fromJson(foo, parseJson(""" {"hs": ["hash", "set"], "os": ["ordered", "set"]}""")) @@ -336,7 +336,7 @@ proc toJsonHook*[A](s: SomeSet[A]): JsonNode = ## See also: ## * `fromJsonHook proc<#fromJsonHook,SomeSet[A],JsonNode>`_ runnableExamples: - import sets, json + import std/[sets, json] let foo = (hs: ["hash"].toHashSet, os: ["ordered", "set"].toOrderedSet) assert $toJson(foo) == """{"hs":["hash"],"os":["ordered","set"]}""" @@ -350,7 +350,7 @@ proc fromJsonHook*[T](self: var Option[T], jsonNode: JsonNode) = ## See also: ## * `toJsonHook proc<#toJsonHook,Option[T]>`_ runnableExamples: - import options, json + import std/[options, json] var opt: Option[string] fromJsonHook(opt, parseJson("\"test\"")) assert get(opt) == "test" @@ -368,7 +368,7 @@ proc toJsonHook*[T](self: Option[T]): JsonNode = ## See also: ## * `fromJsonHook proc<#fromJsonHook,Option[T],JsonNode>`_ runnableExamples: - import options, json + import std/[options, json] let optSome = some("test") assert $toJson(optSome) == "\"test\"" let optNone = none[string]() @@ -385,7 +385,7 @@ proc fromJsonHook*(a: var StringTableRef, b: JsonNode) = ## See also: ## * `toJsonHook proc<#toJsonHook,StringTableRef>`_ runnableExamples: - import strtabs, json + import std/[strtabs, json] var t = newStringTable(modeCaseSensitive) let jsonStr = """{"mode": 0, "table": {"name": "John", "surname": "Doe"}}""" fromJsonHook(t, parseJson(jsonStr)) @@ -403,7 +403,7 @@ proc toJsonHook*(a: StringTableRef): JsonNode = ## See also: ## * `fromJsonHook proc<#fromJsonHook,StringTableRef,JsonNode>`_ runnableExamples: - import strtabs, json + import std/[strtabs, json] let t = newStringTable("name", "John", "surname", "Doe", modeCaseSensitive) let jsonStr = """{"mode": "modeCaseSensitive", "table": {"name": "John", "surname": "Doe"}}""" diff --git a/lib/system.nim b/lib/system.nim index b2d46ffb8..6d26beb73 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -941,7 +941,7 @@ proc cmp*[T](x, y: T): int = ## This generic implementation uses the `==` and `<` operators. ## ## .. code-block:: Nim - ## import algorithm + ## import std/algorithm ## echo sorted(@[4, 2, 6, 5, 8, 7], cmp[int]) if x == y: return 0 if x < y: return -1 @@ -1745,7 +1745,7 @@ proc instantiationInfo*(index = -1, fullPaths = false): tuple[ ## Example: ## ## .. code-block:: nim - ## import strutils + ## import std/strutils ## ## template testException(exception, code: untyped): typed = ## try: diff --git a/lib/system/channels.nim b/lib/system/channels.nim index 5bf0d4052..bb611a140 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -30,7 +30,7 @@ ## # Be sure to compile with --threads:on. ## # The channels and threads modules are part of system and should not be ## # imported. -## import os +## import std/os ## ## # Channels can either be: ## # - declared at the module level, or diff --git a/lib/system/io.nim b/lib/system/io.nim index 460be516e..5ac9f813e 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -913,7 +913,7 @@ iterator lines*(filename: string): string {.tags: [ReadIOEffect].} = ## character(s) are removed from the iterated lines. Example: ## ## .. code-block:: nim - ## import strutils + ## import std/strutils ## ## proc transformLetters(filename: string) = ## var buffer = "" diff --git a/lib/system/iterators_1.nim b/lib/system/iterators_1.nim index 2bc58c2b7..be61fd62c 100644 --- a/lib/system/iterators_1.nim +++ b/lib/system/iterators_1.nim @@ -12,7 +12,7 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} = ## **Note**: This fails to count to `low(int)` if T = int for ## efficiency reasons. runnableExamples: - import sugar + import std/sugar let x = collect(newSeq): for i in countdown(7, 3): i @@ -49,7 +49,7 @@ iterator countup*[T](a, b: T, step: Positive = 1): T {.inline.} = ## **Note**: This fails to count to `high(int)` if T = int for ## efficiency reasons. runnableExamples: - import sugar + import std/sugar let x = collect(newSeq): for i in countup(3, 7): i @@ -78,7 +78,7 @@ iterator `..`*[T](a, b: T): T {.inline.} = ## See also: ## * [..<](#..<.i,T,T) runnableExamples: - import sugar + import std/sugar let x = collect(newSeq): for i in 3 .. 7: diff --git a/lib/system/threads.nim b/lib/system/threads.nim index cd1cf5e29..7d1f877ff 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -24,7 +24,7 @@ ## ## .. code-block:: Nim ## -## import locks +## import std/locks ## ## var ## thr: array[0..4, Thread[tuple[a,b: int]]] |