summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorCharles Blake <cblake@csail.mit.edu>2015-08-03 12:34:03 -0400
committerCharles Blake <cblake@csail.mit.edu>2015-08-03 12:34:03 -0400
commit9e8b4475e25adbe76331e6ab799443b1e2b62f7f (patch)
tree5c89e450f328ea04fc8d4980adc5c7100f3b9878 /lib
parent7cb9f363d65d9ad3c52bf4cf35af3eb71988ac06 (diff)
downloadNim-9e8b4475e25adbe76331e6ab799443b1e2b62f7f.tar.gz
Spruce up doc comments as per dom96 suggestions.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/memfiles.nim19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim
index c646c31a1..f78cd8766 100644
--- a/lib/pure/memfiles.nim
+++ b/lib/pure/memfiles.nim
@@ -263,12 +263,12 @@ proc `$`*(ms: MemSlice): string {.inline.} =
 
 iterator memSlices*(mfile: MemFile, delim='\l', eat='\r'): MemSlice {.inline.} =
   ## Iterates over [optional eat]delim-delimited slices in a MemFile.
-  ## Default delimiting is [\\r]\\l which parse Unix or Windows text file lines.
+  ## Default delimiting is [\\r]\\l which parses Unix/Windows text file lines.
   ## Pass eat='\\0' to be strictly delim-delimited.
   ## This zero copy, memchr-limited method is probably the fastest way to
-  ## iterate through lines in a file, however the returned (data,size) objects
-  ## are NOT Nim strings or even terminated C strings.  So, be careful how data
-  ## is accessed (e.g., use C mem* functions, not str* functions). Example:
+  ## iterate through lines in a file.  The returned (data,size) objects are
+  ## NOT Nim strings or even terminated C strings.  So, be careful how data
+  ## is accessed (e.g., think C mem* functions, not str* functions).  Example:
   ##
   ## .. code-block:: nim
   ##   var count = 0
@@ -298,8 +298,13 @@ iterator memSlices*(mfile: MemFile, delim='\l', eat='\r'): MemSlice {.inline.} =
 
 iterator lines*(mfile: MemFile, buf: var TaintedString, delim='\l', eat='\r'): TaintedString {.inline.} =
   ## Replace contents of passed buffer with each new line, like readLine(File).
-  ## Default delimiting is [\\r]\\l which parse Unix or Windows text file lines.
-  ## Pass eat='\\0' to be strictly delim-delimited.
+  ## Default delimiting is [\\r]\\l which parses Unix/Windows text file lines.
+  ## Pass eat='\\0' to be strictly delim-delimited.  Example:
+  ##
+  ## .. code-block:: nim
+  ##   var buffer: TaintedString = ""
+  ##   for line in lines(memfiles.open("foo"), buffer):
+  ##     echo line
   for ms in memSlices(mfile, delim, eat):
     buf.setLen(ms.size)
     c_memcpy(addr(buf[0]), ms.data, ms.size)
@@ -308,7 +313,7 @@ iterator lines*(mfile: MemFile, buf: var TaintedString, delim='\l', eat='\r'): T
 
 iterator lines*(mfile: MemFile, delim='\l', eat='\r'): TaintedString {.inline.} =
   ## Return each line in a file as a Nim string, like lines(File).
-  ## Default delimiting is [\\r]\\l which parse Unix or Windows text file lines.
+  ## Default delimiting is [\\r]\\l which parses Unix/Windows text file lines.
   ## Pass eat='\0' to be strictly delim-delimited.  Example:
   ##
   ## .. code-block:: nim