summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-05-01 13:27:50 +0800
committerGitHub <noreply@github.com>2021-05-01 07:27:50 +0200
commit9f75e8abc153bafdc5d3a34f001d20a92d36e220 (patch)
tree6c7a374bc90d30a18df2284be6a0cafbe4201edd
parent82996aee3f4ab620a210ab73946f87d44052d999 (diff)
downloadNim-9f75e8abc153bafdc5d3a34f001d20a92d36e220.tar.gz
[std/base64] uses runnableExamples (#17882)
* [std/base64] uses runnableExamples
* Update lib/pure/base64.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
-rw-r--r--lib/pure/base64.nim62
1 files changed, 30 insertions, 32 deletions
diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim
index d5c1fda7a..daba786f2 100644
--- a/lib/pure/base64.nim
+++ b/lib/pure/base64.nim
@@ -16,44 +16,42 @@
 ## Each Base64 digit represents exactly 6 bits of data. Three 8-bit
 ## bytes (i.e., a total of 24 bits) can therefore be represented by
 ## four 6-bit Base64 digits.
-##
-## Basic usage
-## ===========
-##
+
+##[
+# Basic usage
 ## Encoding data
-## -------------
-##
-## .. code-block:: Nim
-##    import std/base64
-##    let encoded = encode("Hello World")
-##    assert encoded == "SGVsbG8gV29ybGQ="
+]##
+
+runnableExamples:
+  let encoded = encode("Hello World")
+  assert encoded == "SGVsbG8gV29ybGQ="
+
 ##
 ## Apart from strings you can also encode lists of integers or characters:
 ##
-## .. code-block:: Nim
-##    import std/base64
-##    let encodedInts = encode([1,2,3])
-##    assert encodedInts == "AQID"
-##    let encodedChars = encode(['h','e','y'])
-##    assert encodedChars == "aGV5"
-##
-##
+
+runnableExamples:
+  let encodedInts = encode([1,2,3])
+  assert encodedInts == "AQID"
+  let encodedChars = encode(['h','e','y'])
+  assert encodedChars == "aGV5"
+
+##[
 ## Decoding data
-## -------------
-##
-## .. code-block:: Nim
-##    import std/base64
-##    let decoded = decode("SGVsbG8gV29ybGQ=")
-##    assert decoded == "Hello World"
-##
+]##
+
+runnableExamples:
+  let decoded = decode("SGVsbG8gV29ybGQ=")
+  assert decoded == "Hello World"
+
+##[
 ## URL Safe Base64
-## ---------------
-##
-## .. code-block:: Nim
-##    import std/base64
-##    doAssert encode("c\xf7>", safe = true) == "Y_c-"
-##    doAssert encode("c\xf7>", safe = false) == "Y/c+"
-##
+]##
+
+runnableExamples:
+  assert encode("c\xf7>", safe = true) == "Y_c-"
+  assert encode("c\xf7>", safe = false) == "Y/c+"
+
 ## See also
 ## ========
 ##