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>
This commit is contained in:
parent
63c559e781
commit
ef2677f5f3
4 changed files with 51 additions and 57 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue