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

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

[elpa] externals/dash 41d77ec 034/439: Add function list to readme.


From: Phillip Lord
Subject: [elpa] externals/dash 41d77ec 034/439: Add function list to readme.
Date: Tue, 04 Aug 2015 20:26:05 +0000

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

    Add function list to readme.
---
 README.md           |   23 ++++++++++++++++++++++-
 examples-to-docs.el |   44 +++++++++++++++++++++++++++++++-------------
 readme-prefix.md    |   12 ++++++++----
 3 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md
index 129e4fd..e857fa8 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,28 @@ of course the original can also be written like
 
 which demonstrates the usefulness of both versions.
 
-## Documentation
+## Available functions
+
+```cl
+!map (fn list)
+!reduce-from (fn initial-value list)
+!reduce (fn list)
+!filter (fn list)
+!remove (fn list)
+!concat (&rest lists)
+!mapcat (fn list)
+!partial (fn &rest args)
+!difference (list list2)
+!intersection (list list2)
+!uniq (list)
+!contains? (list element)
+```cl
+
+There are also anaphoric versions of these
+functions where that makes sense, prefixed with two bangs
+instead of one.
+
+## Documentation and examples
 
 ### !map `(fn list)`
 
diff --git a/examples-to-docs.el b/examples-to-docs.el
index 586977b..59f9ef2 100644
--- a/examples-to-docs.el
+++ b/examples-to-docs.el
@@ -14,10 +14,10 @@
 
 (defmacro defexamples (cmd &rest examples)
   `(add-to-list 'functions (list
-    ',cmd ;; command name
-    (cadr (symbol-function ',cmd)) ;; signature
-    (car (cddr (symbol-function ',cmd))) ;; docstring
-    (examples-to-strings ',examples)))) ;; examples
+                            ',cmd ;; command name
+                            (cadr (symbol-function ',cmd)) ;; signature
+                            (car (cddr (symbol-function ',cmd))) ;; docstring
+                            (examples-to-strings ',examples)))) ;; examples
 
 (defun quote-and-downcase (string)
   (format "`%s`" (downcase string)))
@@ -39,16 +39,34 @@
             docstring
             (mapconcat 'identity (three-first examples) "\n"))))
 
+(defun function-summary (function)
+  (let ((command-name (car function))
+        (signature (cadr function)))
+    (format "%s %s" command-name signature)))
+
 (defun create-docs-file ()
-  (with-temp-file "./README.md"
-    (insert-file-contents-literally "./readme-prefix.md")
-    (goto-char (point-max))
-    (newline)
-    (insert "## Documentation")
-    (newline 2)
-    (insert (mapconcat 'function-to-md (nreverse functions) "\n"))
-    (newline)
-    (insert-file-contents-literally "./readme-postfix.md")))
+  (let ((functions (nreverse functions)))
+    (with-temp-file "./README.md"
+      (insert-file-contents-literally "./readme-prefix.md")
+      (goto-char (point-max))
+      (newline)
+      (insert "## Available functions")
+      (newline 2)
+      (insert "```cl")
+      (newline)
+      (insert (mapconcat 'function-summary functions "\n"))
+      (newline)
+      (insert "```cl")
+      (newline 2)
+      (insert "There are also anaphoric versions of these
+functions where that makes sense, prefixed with two bangs
+instead of one.")
+      (newline 2)
+      (insert "## Documentation and examples")
+      (newline 2)
+      (insert (mapconcat 'function-to-md functions "\n"))
+      (newline)
+      (insert-file-contents-literally "./readme-postfix.md"))))
 
 (defun three-first (list)
   (let (first)
diff --git a/readme-prefix.md b/readme-prefix.md
index 78f30bf..1211751 100644
--- a/readme-prefix.md
+++ b/readme-prefix.md
@@ -14,14 +14,18 @@ While `!filter` takes a function to filter the list by, you 
can also use the
 anaphoric form with double bangs - which will then be executed with `it` 
exposed
 as the list item. Here's an example:
 
-    (!filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) ;; normal version
+```cl
+(!filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) ;; normal version
 
-    (!!filter (= 0 (% it 2)) '(1 2 3 4)) ;; anaphoric version
+(!!filter (= 0 (% it 2)) '(1 2 3 4)) ;; anaphoric version
+```
 
 of course the original can also be written like
 
-    (defun even? (num) (= 0 (% num 2)))
+```cl
+(defun even? (num) (= 0 (% num 2)))
 
-    (!filter even? '(1 2 3 4))
+(!filter even? '(1 2 3 4))
+```
 
 which demonstrates the usefulness of both versions.



reply via email to

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