fixup #10466 to use runnableExamples (#10510)

This commit is contained in:
Timothee Cour
2019-01-30 22:19:16 -08:00
committed by Miran
parent acac107fe7
commit abcd9fd2e8

View File

@@ -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)