summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-01-30 22:19:16 -0800
committerMiran <narimiran@disroot.org>2019-01-31 07:19:16 +0100
commitabcd9fd2e8120caf6e4588dabe0f22ae0cce07d3 (patch)
tree0808ad09104f4bd3e877404a5e87d625021187d4
parentacac107fe7fbef2b55cef3264e9e5e10e1f69ea3 (diff)
downloadNim-abcd9fd2e8120caf6e4588dabe0f22ae0cce07d3.tar.gz
fixup #10466 to use runnableExamples (#10510)
-rw-r--r--lib/pure/json.nim31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 4a3d5b432..176da1d9d 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -710,23 +710,20 @@ proc pretty*(node: JsonNode, indent = 2): string =
   ## on multiple lines.
   ##
   ## Similar to prettyprint in Python.
-  ##
-  ## **Examples:**
-  ##
-  ## .. code-block:: Nim
-  ##   let j = %* {"name": "Isaac", "books": ["Robot Dreams"],
-  ##               "details": {"age":35, "pi":3.1415}}
-  ##   echo pretty(j)
-  ##   # {
-  ##   #   "name": "Isaac",
-  ##   #   "books": [
-  ##   #     "Robot Dreams"
-  ##   #   ],
-  ##   #   "details": {
-  ##   #     "age": 35,
-  ##   #     "pi": 3.1415
-  ##   #   }
-  ##   # }
+  runnableExamples:
+    let j = %* {"name": "Isaac", "books": ["Robot Dreams"],
+                "details": {"age":35, "pi":3.1415}}
+    doAssert pretty(j) == """
+{
+  "name": "Isaac",
+  "books": [
+    "Robot Dreams"
+  ],
+  "details": {
+    "age": 35,
+    "pi": 3.1415
+  }
+}"""
   result = ""
   toPretty(result, node, indent)