[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.
- [elpa] externals/dash 73204ca 022/439: Change !contains-p to !contains? to match clojure api., (continued)
- [elpa] externals/dash 73204ca 022/439: Change !contains-p to !contains? to match clojure api., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6c39876 003/439: Set up test framework with one basic test, Phillip Lord, 2015/08/04
- [elpa] externals/dash c0f2c8f 026/439: Test that it works with lexical binding., Phillip Lord, 2015/08/04
- [elpa] externals/dash 754dd0d 024/439: Create stand-alone anaphoric macros, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9e74cc0 027/439: Remove dead code., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8eab3d1 028/439: Slight improvements to map., Phillip Lord, 2015/08/04
- [elpa] externals/dash d2dfb11 023/439: Use double-bang for anaphoric functions, Phillip Lord, 2015/08/04
- [elpa] externals/dash 85016d3 029/439: Fix quoted forms like `' in docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6f0636f 032/439: Show only three first examples per function., Phillip Lord, 2015/08/04
- [elpa] externals/dash 4cc4147 035/439: Fix typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash 41d77ec 034/439: Add function list to readme.,
Phillip Lord <=
- [elpa] externals/dash 214a7db 030/439: Quote and lowercase parameter names in docstring., Phillip Lord, 2015/08/04
- [elpa] externals/dash ec27b47 025/439: Turn tests into examples that can both be tested and turned into docs, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1997e52 031/439: Treat dashes in docstring better., Phillip Lord, 2015/08/04
- [elpa] externals/dash 78fc2a3 038/439: Quote and downcase params with digits in them too., Phillip Lord, 2015/08/04
- [elpa] externals/dash 06efd3c 039/439: Slight improvements to docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash de5ff6a 037/439: Simplify quotes in readme., Phillip Lord, 2015/08/04
- [elpa] externals/dash 5f6ea16 036/439: Fix typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash 722fea6 033/439: Include docs in README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 657ee8b 040/439: Slight improvements to docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash 26113a1 041/439: Add pre-commit.sh that runs tests and updates readme., Phillip Lord, 2015/08/04