Merge pull request #104 from fbergroth/linkify-docs

Linkify docs
master
Matus Goljer 11 years ago
commit d0c6fc06f8
  1. 328
      README.md
  2. 23
      dev/examples-to-docs.el
  3. 4
      readme-template.md

File diff suppressed because it is too large Load Diff

@ -53,24 +53,31 @@ FUNCTION may reference an elisp function, alias, macro or a subr."
(defun quote-and-downcase (string)
(format "`%s`" (downcase string)))
(defun quote-docstring (docstring)
(defun unquote-and-link (string)
(format-link (substring string 1 -1)))
(defun format-link (string-name)
(-let* ((name (intern string-name))
((_ signature _ _) (assoc name functions)))
(if signature
(format "[`%s`](#%s)" name (github-id name signature))
(format "`%s`" name))))
(defun format-docstring (docstring)
(let (case-fold-search)
(--> 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)
(replace-regexp-in-string "`\\([^ ]+\\)'" 'unquote-and-link it t)
(replace-regexp-in-string "^ " " " it))))
(defun function-to-md (function)
(if (stringp function)
(concat "\n" (s-replace "### " "## " function) "\n")
(let ((command-name (car function))
(signature (cadr function))
(docstring (quote-docstring (nth 2 function)))
(examples (nth 3 function)))
(format "#### %s `%s`\n\n%s\n\n```cl\n%s\n```\n"
(-let [(command-name signature docstring examples) function]
(format "#### %s `%s`\n\n%s\n\n```el\n%s\n```\n"
command-name
signature
docstring
(format-docstring docstring)
(mapconcat 'identity (-take 3 examples) "\n")))))
(defun docs--chop-prefix (prefix s)

@ -45,7 +45,7 @@ While `-map` takes a function to map over the list, you can also use
the anaphoric form with double dashes - which will then be executed
with `it` exposed as the list item. Here's an example:
```cl
```el
(-map (lambda (n) (* n n)) '(1 2 3 4)) ;; normal version
(--map (* it it) '(1 2 3 4)) ;; anaphoric version
@ -53,7 +53,7 @@ with `it` exposed as the list item. Here's an example:
of course the original can also be written like
```cl
```el
(defun square (n) (* n n))
(-map 'square '(1 2 3 4))

Loading…
Cancel
Save