diff options
author | jiro <jiroron666@gmail.com> | 2019-01-01 17:56:59 +0900 |
---|---|---|
committer | Miran <narimiran@disroot.org> | 2019-01-01 09:56:59 +0100 |
commit | e7fa8f3443ebe03d74fb20b7f4d0096756211463 (patch) | |
tree | 46176deed53b21167ef5a8b386f7deb56b0d6d98 /lib/std | |
parent | 7c90e22ddd354692d259c5620578f194757c20e1 (diff) | |
download | Nim-e7fa8f3443ebe03d74fb20b7f4d0096756211463.tar.gz |
Add Example code to Documentation comment of wordWrap proc. (#10146)
Diffstat (limited to 'lib/std')
-rw-r--r-- | lib/std/wordwrap.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/wordwrap.nim b/lib/std/wordwrap.nim index c7898b339..4b0dc4417 100644 --- a/lib/std/wordwrap.nim +++ b/lib/std/wordwrap.nim @@ -24,6 +24,11 @@ proc wrapWords*(s: string, maxLineWidth = 80, seps: set[char] = Whitespace, newLine = "\n"): string {.noSideEffect.} = ## Word wraps `s`. + runnableExamples: + doAssert "12345678901234567890".wrapWords() == "12345678901234567890" + doAssert "123456789012345678901234567890".wrapWords(20) == "12345678901234567890\n1234567890" + doAssert "Hello Bob. Hello John.".wrapWords(13, false) == "Hello Bob.\nHello John." + doAssert "Hello Bob. Hello John.".wrapWords(13, true, {';'}) == "Hello Bob. He\nllo John." result = newStringOfCap(s.len + s.len shr 6) var spaceLeft = maxLineWidth var lastSep = "" |