Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
A couple of minor enhancements to the doc tester
Browse files Browse the repository at this point in the history
 - Ignore code blocks where the info string contains ":no-test". Anything
   after the first word will be ignored (as per the Common Mark spec).
 - Mark all syntactically-invalid tests as pending (it previously didn't
   do this if the first line didn't start with '>').
  • Loading branch information
SquidDev committed Aug 4, 2017
1 parent 5659401 commit 4df597f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions plugins/doc-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@
(unless (string/starts-with? k "_/")
(with (docs (-> (or (_/var-docstring v) "")
_/parse-docstring
(filter (lambda (x) (and (= (type x) "mono") (string/starts-with? (.> x :whole) "```"))) <>)
(filter (lambda (x) (and (= (type x) "mono")
(string/starts-with? (.> x :whole) "```")
(! (string/find (.> x :whole) "^```[^\n]*:no%-test[^\n]*\n")))) <>)
(map (cut .> <> :contents) <>)))
(for-each entry docs
(with (lines (string/split entry "\n"))
(let [(lines (string/split entry "\n"))
(asserts `(_/test/it ,(.. "has tests for " (.> v :full-name))))]
(push-cdr! tests asserts)
(cond
;; Just do a couple of sanity checks on the code
[(empty? lines) (_/var-warning! v "This example is empty.")]
[(/= (string/char-at (car lines) 1) ">") (_/var-warning! v "Example is expected to begin with \">\".")]
[(empty? lines)
(_/var-warning! v "This example is empty.")
(.<! asserts 1 `_/test/pending)]
;; Everything is OK so let's build a list
[true
(let* [(asserts `(_/test/it ,$"has tests for ${k}"))
(subst {})
(i 1)]
(push-cdr! tests asserts)
(let [(subst {})
(i 1)]
(loop []
[(> i (n lines))]
(if (/= (string/char-at (nth lines i) 1) ">")
Expand Down
2 changes: 1 addition & 1 deletion urn/documentation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"The primary tokens for the documentation string"
:hidden
'(("arg" "(%f[%a]%u+%f[%A])")
("mono" "```[a-z]*\n([^`]*)\n```")
("mono" "```[^\n]*\n(.-)\n```")
("mono" "`([^`]*)`")
("bolic" "(%*%*%*%w.-%w%*%*%*)")
("bold" "(%*%*%w.-%w%*%*)")
Expand Down

0 comments on commit 4df597f

Please sign in to comment.