summary refs log tree commit diff stats
path: root/lib/pure/pathnorm.nim
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-12 17:47:56 +0800
committerGitHub <noreply@github.com>2020-11-12 10:47:56 +0100
commitef2677f5f3f58ad5bd514f82a0efd68d4d17e7f9 (patch)
tree544de6e40861b41d151d5fb90b0c123cd37d5d0a /lib/pure/pathnorm.nim
parent63c559e781cafaab6bcc9e62d5631e93749450bb (diff)
downloadNim-ef2677f5f3f58ad5bd514f82a0efd68d4d17e7f9.tar.gz
change some code-blocks to runnableExamples and correct some errors in docs (#15900)
* original docs are wrong
* fix pathnorm
* Update lib/pure/pathnorm.nim

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
Diffstat (limited to 'lib/pure/pathnorm.nim')
-rw-r--r--lib/pure/pathnorm.nim14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/pure/pathnorm.nim b/lib/pure/pathnorm.nim
index 03a65bd60..5bc66f0b7 100644
--- a/lib/pure/pathnorm.nim
+++ b/lib/pure/pathnorm.nim
@@ -100,15 +100,13 @@ proc addNormalizePath*(x: string; result: var string; state: var int;
   if result == "" and x != "": result = "."
 
 proc normalizePath*(path: string; dirSep = DirSep): string =
-  ## Example:
-  ##
-  ## .. code-block:: nim
-  ##   assert normalizePath("./foo//bar/../baz") == "foo/baz"
-  ##
-  ##
+  runnableExamples:
+    when defined(posix):
+      doAssert normalizePath("./foo//bar/../baz") == "foo/baz"
+
   ## - Turns multiple slashes into single slashes.
-  ## - Resolves '/foo/../bar' to '/bar'.
-  ## - Removes './' from the path (but "foo/.." becomes ".")
+  ## - Resolves `'/foo/../bar'` to `'/bar'`.
+  ## - Removes `'./'` from the path, but `"foo/.."` becomes `"."`.
   result = newStringOfCap(path.len)
   var state = 0
   addNormalizePath(path, result, state, dirSep)