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

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

[elpa] externals/dash dc6f46c 098/439: Simplify docs-generation using da


From: Phillip Lord
Subject: [elpa] externals/dash dc6f46c 098/439: Simplify docs-generation using dash.
Date: Tue, 04 Aug 2015 20:26:51 +0000

branch: externals/dash
commit dc6f46cff33db7f08cd41b00279e6109f204ff27
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Simplify docs-generation using dash.
---
 examples-to-docs.el |   34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/examples-to-docs.el b/examples-to-docs.el
index 63e7e22..3be657f 100644
--- a/examples-to-docs.el
+++ b/examples-to-docs.el
@@ -1,17 +1,15 @@
+(require 'dash)
+
 (defvar functions '())
 
 (defun example-to-string (example)
   (let ((actual (car example))
         (expected (cadr (cdr example))))
-    (replace-regexp-in-string
-     "\r" "\\r"
-     (replace-regexp-in-string
-      "\t" "\\t"
-      (replace-regexp-in-string
-       "\n" "\\n"
-       (replace-regexp-in-string
-        "\\\\\\?" "?"
-        (format "%S ;; => %S" actual expected)) t t) t t) t t)))
+    (--> (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)
@@ -42,9 +40,9 @@
 
 (defun quote-docstring (docstring)
   (let (case-fold-search)
-    (setq docstring (replace-regexp-in-string "\\b\\([A-Z][A-Z-]*[0-9]*\\)\\b" 
'quote-and-downcase docstring t))
-    (setq docstring (replace-regexp-in-string "`\\([^ ]+\\)'" "`\\1`" 
docstring t)))
-  docstring)
+    (--> docstring
+         (replace-regexp-in-string "\\b\\([A-Z][A-Z-]*[0-9]*\\)\\b" 
'quote-and-downcase it t)
+         (replace-regexp-in-string "`\\([^ ]+\\)'" "`\\1`" it t))))
 
 (defun function-to-md (function)
   (let ((command-name (car function))
@@ -55,7 +53,7 @@
             command-name
             signature
             docstring
-            (mapconcat 'identity (three-first examples) "\n"))))
+            (mapconcat 'identity (-take 3 examples) "\n"))))
 
 (defun docs--chop-suffix (suffix s)
   "Remove SUFFIX if it is at end of S."
@@ -106,13 +104,3 @@
       (insert (mapconcat 'function-to-md functions "\n"))
 
       (simplify-quotes))))
-
-(defun three-first (list)
-  (let (first)
-    (when (car list)
-      (setq first (cons (car list) first))
-      (when (cadr list)
-        (setq first (cons (cadr list) first))
-        (when (car (cddr list))
-          (setq first (cons (car (cddr list)) first)))))
-    (nreverse first)))



reply via email to

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