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

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

[elpa] externals/dash 63fa64f 368/439: Add links to references in readme


From: Phillip Lord
Subject: [elpa] externals/dash 63fa64f 368/439: Add links to references in readme
Date: Tue, 04 Aug 2015 20:30:37 +0000

branch: externals/dash
commit 63fa64f7550709d218de794d9e2e3eaffd10d99c
Author: Fredrik Bergroth <address@hidden>
Commit: Fredrik Bergroth <address@hidden>

    Add links to references in readme
---
 dev/examples-to-docs.el |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/dev/examples-to-docs.el b/dev/examples-to-docs.el
index eb2ce7d..0cd5327 100644
--- a/dev/examples-to-docs.el
+++ b/dev/examples-to-docs.el
@@ -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)))
+    (-let [(command-name signature docstring examples) function]
       (format "#### %s `%s`\n\n%s\n\n```cl\n%s\n```\n"
               command-name
               signature
-              docstring
+              (format-docstring docstring)
               (mapconcat 'identity (-take 3 examples) "\n")))))
 
 (defun docs--chop-prefix (prefix s)



reply via email to

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