summary refs log tree commit diff stats
path: root/lib/js
diff options
context:
space:
mode:
authorJuan Carlos <juancarlospaco@gmail.com>2020-09-11 03:57:57 -0300
committerGitHub <noreply@github.com>2020-09-11 08:57:57 +0200
commitc4e03b540e34a37c24794ade073bf708ab17b35d (patch)
tree1cf02bca7dcebd39bf2aa1d6017f86c5c9f0c7a4 /lib/js
parent0c41ac792b64b710b4702cd4ae88d4392744a1ea (diff)
downloadNim-c4e03b540e34a37c24794ade073bf708ab17b35d.tar.gz
Fix #15183 (#15300)
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/jsre.nim23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/js/jsre.nim b/lib/js/jsre.nim
index b4f273d0b..ff80056ea 100644
--- a/lib/js/jsre.nim
+++ b/lib/js/jsre.nim
@@ -1,5 +1,18 @@
 ## Regular Expressions for the JavaScript target.
 ## * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+##
+## Examples
+## ========
+##
+## .. code-block::nim
+##   let jsregex: RegExp = newRegExp(r"\s+", r"i")
+##   jsregex.compile(r"\w+", r"i")
+##   doAssert jsregex.test(r"nim javascript")
+##   doAssert jsregex.exec(r"nim javascript") == @["nim".cstring]
+##   doAssert jsregex.toString() == r"/\w+/i"
+##   jsregex.compile(r"[0-9]", r"i")
+##   doAssert jsregex.test(r"0123456789abcd")
+
 
 when not defined(js) and not defined(Nimdoc):
   {.error: "This module only works on the JavaScript platform".}
@@ -34,13 +47,3 @@ func test*(self: RegExp; pattern: cstring): bool {.importjs: "#.test(#)".}
 
 func toString*(self: RegExp): cstring {.importjs: "#.toString()".}
   ## Returns a string representing the RegExp object.
-
-
-runnableExamples:
-  let jsregex: RegExp = newRegExp(r"\s+", r"i")
-  jsregex.compile(r"\w+", r"i")
-  doAssert jsregex.test(r"nim javascript")
-  doAssert jsregex.exec(r"nim javascript") == @["nim".cstring]
-  doAssert jsregex.toString() == r"/\w+/i"
-  jsregex.compile(r"[0-9]", r"i")
-  doAssert jsregex.test(r"0123456789abcd")