emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash 609ac28 245/316: Improve Texinfo markup when docum


From: ELPA Syncer
Subject: [elpa] externals/dash 609ac28 245/316: Improve Texinfo markup when documenting errors
Date: Mon, 15 Feb 2021 15:58:10 -0500 (EST)

branch: externals/dash
commit 609ac28bab13c7f8a107b0f2dc78353763c84086
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Improve Texinfo markup when documenting errors
    
    * dev/examples-to-docs.el (example-to-string): Simplify.
    * dev/examples-to-info.el (example-to-string): Use @error{} instead
    of @result{} for errors.  Use error-message-string to translate
    error lists to their corresponding message.
    * dev/examples-to-tests.el (example-to-should): Add support for
    checking whole error lists, not just error symbols.
    
    * dev/examples.el (-running-sum, -running-product, -iota): Specify
    whole error list, not just error symbol.
    
    * dash.texi: Regenerate.
---
 dash.texi                |  6 +++---
 dev/examples-to-docs.el  | 16 +++++++---------
 dev/examples-to-info.el  | 12 ++++++++----
 dev/examples-to-tests.el |  6 ++++--
 dev/examples.el          |  6 +++---
 5 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/dash.texi b/dash.texi
index c6035bc..97969a6 100644
--- a/dash.texi
+++ b/dash.texi
@@ -1416,7 +1416,7 @@ Return a list with running sums of items in @var{list}.
 @end group
 @group
 (-running-sum nil)
-    @result{} wrong-type-argument
+    @error{} "Wrong type argument: consp, nil"
 @end group
 @end example
 @end defun
@@ -1457,7 +1457,7 @@ Return a list with running products of items in 
@var{list}.
 @end group
 @group
 (-running-product nil)
-    @result{} wrong-type-argument
+    @error{} "Wrong type argument: consp, nil"
 @end group
 @end example
 @end defun
@@ -2727,7 +2727,7 @@ the @var{apl} language.
 @end group
 @group
 (-iota -1)
-    @result{} wrong-type-argument
+    @error{} "Wrong type argument: natnump, -1"
 @end group
 @end example
 @end defun
diff --git a/dev/examples-to-docs.el b/dev/examples-to-docs.el
index d2ac648..0d30aee 100644
--- a/dev/examples-to-docs.el
+++ b/dev/examples-to-docs.el
@@ -30,16 +30,14 @@
 (defvar functions ())
 
 (defun example-to-string (example)
-  (-let* (((actual sym expected) example)
-      (comment
-       (cond
-        ((eq sym '=>) (format "=> %S" expected))
-        ((eq sym '~>) (format "~> %S" expected))
-        ((eq sym '!!>) (format "Error"))
-        (t (error "Invalid test case: %S" `(,actual ,sym ,expected))))))
-    (--> comment
+  (-let [(actual sym expected) example]
+    (--> (cond
+          ((eq sym '=>) (format "=> %S" expected))
+          ((eq sym '~>) (format "~> %S" expected))
+          ((eq sym '!!>) "Error")
+          ((error "Invalid test case: %S" example)))
       (format "%S ;; %s" actual it)
-      (replace-regexp-in-string "\\\\\\?" "?" it)
+      (replace-regexp-in-string "\\\\\\?" "?" it t t)
       (replace-regexp-in-string "\n" "\\n" it t t)
       (replace-regexp-in-string "\t" "\\t" it t t)
       (replace-regexp-in-string "\r" "\\r" it t t))))
diff --git a/dev/examples-to-info.el b/dev/examples-to-info.el
index 67ee5af..a011a41 100644
--- a/dev/examples-to-info.el
+++ b/dev/examples-to-info.el
@@ -28,12 +28,16 @@
 
 (setq text-quoting-style 'grave)
 
-(defvar functions '())
+(defvar functions ())
 
 (defun example-to-string (example)
-  (let ((actual (car example))
-        (expected (nth 2 example)))
-    (--> (format "@group\n%S\n    @result{} %S\n@end group" actual expected)
+  (let ((actual (pop example))
+        (err (eq (pop example) '!!>))
+        (expected (pop example)))
+    (and err (consp expected)
+         (setq expected (error-message-string expected)))
+    (--> (format "@group\n%S\n    %s %S\n@end group"
+                 actual (if err "@error{}" "@result{}") expected)
       (replace-regexp-in-string "\\\\\\?" "?" it)
       (replace-regexp-in-string "{\"" "@{\"" it t t)
       (replace-regexp-in-string "}\"" "@}\"" it t t)
diff --git a/dev/examples-to-tests.el b/dev/examples-to-tests.el
index 7673cbe..8fe6c02 100644
--- a/dev/examples-to-tests.el
+++ b/dev/examples-to-tests.el
@@ -28,10 +28,12 @@
          `(should (equal ,actual ,expected)))
         ((eq sym '~>)
          `(should (approx-equal ,actual ,expected)))
-        ((eq sym '!!>)
+        ((not (eq sym '!!>))
+         (error "Invalid test case: %S" `(,actual ,sym ,expected)))
+        ((symbolp expected)
          ;; FIXME: Tests fail on Emacs 24-25 without `eval' for some reason.
          `(should-error (eval ',actual ,lexical-binding) :type ',expected))
-        ((error "Invalid test case: %S" `(,actual ,sym ,expected)))))
+        (`(should (equal (should-error ,actual) ',expected)))))
 
 (defmacro defexamples (cmd &rest examples)
   (let (tests)
diff --git a/dev/examples.el b/dev/examples.el
index d854224..f298300 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -472,7 +472,7 @@ new list."
   (defexamples -running-sum
     (-running-sum '(1 2 3 4)) => '(1 3 6 10)
     (-running-sum '(1)) => '(1)
-    (-running-sum ()) !!> wrong-type-argument)
+    (-running-sum ()) !!> (wrong-type-argument consp ()))
 
   (defexamples -product
     (-product '()) => 1
@@ -482,7 +482,7 @@ new list."
   (defexamples -running-product
     (-running-product '(1 2 3 4)) => '(1 2 6 24)
     (-running-product '(1)) => '(1)
-    (-running-product ()) !!> wrong-type-argument)
+    (-running-product ()) !!> (wrong-type-argument consp ()))
 
   (defexamples -inits
     (-inits '(1 2 3 4)) => '(nil (1) (1 2) (1 2 3) (1 2 3 4))
@@ -886,7 +886,7 @@ value rather than consuming a list to produce a single 
value."
   (defexamples -iota
     (-iota 6) => '(0 1 2 3 4 5)
     (-iota 4 2.5 -2) => '(2.5 0.5 -1.5 -3.5)
-    (-iota -1) !!> wrong-type-argument
+    (-iota -1) !!> (wrong-type-argument natnump -1)
     (-iota 0) => ()
     (-iota 0 nil 0) => ()
     (-iota 1 nil 0) => '(0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]