[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 03370ea 108/426: Simplify examples-to-docs and exa
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 03370ea 108/426: Simplify examples-to-docs and examples-to-tests with dash |
Date: |
Tue, 04 Aug 2015 19:37:02 +0000 |
branch: externals/dash
commit 03370ea899193e6ea9ed62faab6f9cffff3a8525
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Simplify examples-to-docs and examples-to-tests with dash
---
examples-to-docs.el | 23 ++++++++---------------
examples-to-tests.el | 14 ++++----------
run-tests.sh | 2 +-
3 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/examples-to-docs.el b/examples-to-docs.el
index 3be657f..a16575b 100644
--- a/examples-to-docs.el
+++ b/examples-to-docs.el
@@ -4,36 +4,29 @@
(defun example-to-string (example)
(let ((actual (car example))
- (expected (cadr (cdr example))))
+ (expected (nth 2 example)))
(--> (format "%S ;; => %S" actual expected)
(replace-regexp-in-string "\\\\\\?" "?" it)
(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))))
-(defun examples-to-strings (examples)
- (let (result)
- (while examples
- (setq result (cons (example-to-string examples) result))
- (setq examples (cddr (cdr examples))))
- (nreverse result)))
-
(defun docs--signature (cmd)
(if (eq 'macro (car cmd))
- (car (cddr cmd))
- (cadr cmd)))
+ (nth 2 cmd)
+ (nth 1 cmd)))
(defun docs--docstring (cmd)
(if (eq 'macro (car cmd))
- (cadr (cddr cmd))
- (car (cddr cmd))))
+ (nth 3 cmd)
+ (nth 2 cmd)))
(defmacro defexamples (cmd &rest examples)
`(add-to-list 'functions (list
',cmd
(docs--signature (symbol-function ',cmd))
(docs--docstring (symbol-function ',cmd))
- (examples-to-strings ',examples))))
+ (-map 'example-to-string (-partition 3
',examples)))))
(defun quote-and-downcase (string)
(format "`%s`" (downcase string)))
@@ -47,8 +40,8 @@
(defun function-to-md (function)
(let ((command-name (car function))
(signature (cadr function))
- (docstring (quote-docstring (cadr (cdr function))))
- (examples (cadr (cddr function))))
+ (docstring (quote-docstring (nth 2 function)))
+ (examples (nth 3 function)))
(format "### %s `%s`\n\n%s\n\n```cl\n%s\n```\n"
command-name
signature
diff --git a/examples-to-tests.el b/examples-to-tests.el
index 080a65f..a4cc365 100644
--- a/examples-to-tests.el
+++ b/examples-to-tests.el
@@ -1,19 +1,13 @@
(require 'ert)
+(require 'dash)
-(defun examples-to-should-1 (examples)
+(defun example-to-should (example)
(let ((actual (car examples))
- (expected (cadr (cdr examples))))
+ (expected (nth 2 examples)))
`(should (equal ,actual ,expected))))
-(defun examples-to-should (examples)
- (let (result)
- (while examples
- (setq result (cons (examples-to-should-1 examples) result))
- (setq examples (cddr (cdr examples))))
- (nreverse result)))
-
(defmacro defexamples (cmd &rest examples)
`(ert-deftest ,cmd ()
- ,@(examples-to-should examples)))
+ ,@(-map 'example-to-should (-partition 3 examples))))
(provide 'examples-to-tests)
diff --git a/run-tests.sh b/run-tests.sh
index 697df4b..25ce1fd 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -4,4 +4,4 @@ if [ -z "$EMACS" ] ; then
EMACS="emacs"
fi
-$EMACS -batch -l ert.el -l examples-to-tests.el -l dash.el -l examples.el -f
ert-run-tests-batch-and-exit
+$EMACS -batch -l ert.el -l dash.el -l examples-to-tests.el -l examples.el -f
ert-run-tests-batch-and-exit
- [elpa] externals/dash 38eed45 095/426: Add rainbow-dash, (continued)
- [elpa] externals/dash 38eed45 095/426: Add rainbow-dash, Phillip Lord, 2015/08/04
- [elpa] externals/dash dc6f46c 098/426: Simplify docs-generation using dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash b0da7b2 093/426: Declare macros before using them., Phillip Lord, 2015/08/04
- [elpa] externals/dash 4fedd2e 099/426: Add -partition and -partition-all, Phillip Lord, 2015/08/04
- [elpa] externals/dash 79b56cc 101/426: Use --each, !cons and !cdr to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash a08fc14 102/426: Add -each-while, Phillip Lord, 2015/08/04
- [elpa] externals/dash 49512b9 107/426: Simplify -take and -drop with --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash ed47814 105/426: Add -dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash eb50d17 106/426: Add Melpa back in., Phillip Lord, 2015/08/04
- [elpa] externals/dash 0e5c69b 089/426: Docs: more concise example for anaphoric functions., Phillip Lord, 2015/08/04
- [elpa] externals/dash 03370ea 108/426: Simplify examples-to-docs and examples-to-tests with dash,
Phillip Lord <=
- [elpa] externals/dash ba80875 109/426: Nice indentation for --each, --each-while and --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash f1c8453 083/426: Rename to dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash 51ddc13 110/426: Nice indentation for threading macros., Phillip Lord, 2015/08/04
- [elpa] externals/dash ba60707 103/426: Use --each-while to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash c56925a 111/426: Add font-lock for new functions and the `it` token., Phillip Lord, 2015/08/04
- [elpa] externals/dash a081c72 114/426: Fix tests., Phillip Lord, 2015/08/04
- [elpa] externals/dash a336d78 112/426: Add -only-some?, Phillip Lord, 2015/08/04
- [elpa] externals/dash 81a3247 104/426: Let -each and -each-while take multiple forms., Phillip Lord, 2015/08/04
- [elpa] externals/dash d857f73 118/426: Merge pull request #3 from rejeep/join-alias, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9faa422 115/426: Add -partition-by, Phillip Lord, 2015/08/04