Docs: Better generation of github urls.

master
Magnar Sveen 14 years ago
parent f8d74ff99e
commit eacb6f2884
  1. 64
      README.md
  2. 24
      examples-to-docs.el

@ -12,38 +12,38 @@ Or you can just dump `dash.el` in your load path somewhere.
## Functions
* [-map](#map-fn-list) `(fn list)`
* [-reduce-from](#reduce-from-fn-initial-value-list) `(fn initial-value list)`
* [-reduce](#reduce-fn-list) `(fn list)`
* [-filter](#filter-fn-list) `(fn list)`
* [-remove](#remove-fn-list) `(fn list)`
* [-keep](#keep-fn-list) `(fn list)`
* [-flatten](#flatten-l) `(l)`
* [-concat](#concat-rest-lists) `(&rest lists)`
* [-mapcat](#mapcat-fn-list) `(fn list)`
* [-any?](#any-fn-list) `(fn list)`
* [-all?](#all-fn-list) `(fn list)`
* [-none?](#none-fn-list) `(fn list)`
* [-each](#each-list-fn) `(list fn)`
* [-take](#take-n-list) `(n list)`
* [-drop](#drop-n-list) `(n list)`
* [-take-while](#take-while-fn-list) `(fn list)`
* [-drop-while](#drop-while-fn-list) `(fn list)`
* [-split-at](#split-at-n-list) `(n list)`
* [-split-with](#split-with-fn-list) `(fn list)`
* [-interpose](#interpose-sep-list) `(sep list)`
* [-interleave](#interleave-rest-lists) `(&rest lists)`
* [-replace-where](#replace-where-pred-rep-list) `(pred rep list)`
* [-first](#first-fn-list) `(fn list)`
* [-difference](#difference-list-list2) `(list list2)`
* [-intersection](#intersection-list-list2) `(list list2)`
* [-distinct](#distinct-list) `(list)`
* [-contains?](#contains-list-element) `(list element)`
* [-partial](#partial-fn-rest-args) `(fn &rest args)`
* [-rpartial](#rpartial-fn-rest-args) `(fn &rest args)`
* [->](#x-optional-form-rest-more) `(x &optional form &rest more)`
* [->>](#x-form-rest-more) `(x form &rest more)`
* [-->](#x-form-rest-more) `(x form &rest more)`
* [-map](#-map-fn-list) `(fn list)`
* [-reduce-from](#-reduce-from-fn-initial-value-list) `(fn initial-value list)`
* [-reduce](#-reduce-fn-list) `(fn list)`
* [-filter](#-filter-fn-list) `(fn list)`
* [-remove](#-remove-fn-list) `(fn list)`
* [-keep](#-keep-fn-list) `(fn list)`
* [-flatten](#-flatten-l) `(l)`
* [-concat](#-concat-rest-lists) `(&rest lists)`
* [-mapcat](#-mapcat-fn-list) `(fn list)`
* [-any?](#-any-fn-list) `(fn list)`
* [-all?](#-all-fn-list) `(fn list)`
* [-none?](#-none-fn-list) `(fn list)`
* [-each](#-each-list-fn) `(list fn)`
* [-take](#-take-n-list) `(n list)`
* [-drop](#-drop-n-list) `(n list)`
* [-take-while](#-take-while-fn-list) `(fn list)`
* [-drop-while](#-drop-while-fn-list) `(fn list)`
* [-split-at](#-split-at-n-list) `(n list)`
* [-split-with](#-split-with-fn-list) `(fn list)`
* [-interpose](#-interpose-sep-list) `(sep list)`
* [-interleave](#-interleave-rest-lists) `(&rest lists)`
* [-replace-where](#-replace-where-pred-rep-list) `(pred rep list)`
* [-first](#-first-fn-list) `(fn list)`
* [-difference](#-difference-list-list) `(list list2)`
* [-intersection](#-intersection-list-list) `(list list2)`
* [-distinct](#-distinct-list) `(list)`
* [-contains?](#-contains-list-element) `(list element)`
* [-partial](#-partial-fn-rest-args) `(fn &rest args)`
* [-rpartial](#-rpartial-fn-rest-args) `(fn &rest args)`
* [->](#--x-optional-form-rest-more) `(x &optional form &rest more)`
* [->>](#--x-form-rest-more) `(x form &rest more)`
* [-->](#---x-form-rest-more) `(x form &rest more)`
There are also anaphoric versions of these functions where that makes sense,
prefixed with two dashs instead of one.

@ -57,22 +57,18 @@
docstring
(mapconcat 'identity (three-first examples) "\n"))))
(defun split-name (s)
"Split name into list of words"
(split-string
(let ((case-fold-search nil))
(downcase
(replace-regexp-in-string "\\([a-z]\\)\\([A-Z]\\)" "\\1 \\2" s)))
"[^A-Za-z0-9]+" t))
(defun dashed-words (s)
"Convert string S to snake-case string."
(mapconcat 'identity (mapcar
'(lambda (word) (downcase word))
(split-name s)) "-"))
(defun docs--chop-suffix (suffix s)
"Remove SUFFIX if it is at end of S."
(let ((pos (- (length suffix))))
(if (and (>= (length s) (length suffix))
(string= suffix (substring s pos)))
(substring s 0 pos)
s)))
(defun github-id (command-name signature)
(dashed-words (format "%s %s" command-name signature)))
(docs--chop-suffix
"-"
(replace-regexp-in-string "[^a-zA-Z-]+" "-" (format "%S %S" command-name signature))))
(defun function-summary (function)
(let ((command-name (car function))

Loading…
Cancel
Save