Last active
December 10, 2015 20:08
-
-
Save kidd/4486639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun fetch-defuns (buffer) | |
(save-excursion | |
(goto-char (point-min)) | |
(let (sexp | |
(defuns nil) | |
(defmacros nil)) | |
(condition-case nil | |
(while t | |
(setq sexp (read buffer)) | |
(when (listp sexp) | |
(case (car sexp) | |
(defun (push (cons (cadr sexp) (doc-if-any sexp)) defuns)) | |
(defmacro (push (cons (cadr sexp) (doc-if-any sexp)) defmacros))))) | |
(error nil)) | |
;; reverse the reversed defuns | |
(setq defuns (reverse defuns)) | |
(generate-docs defuns)))) | |
(defun doc-if-any (sexp) | |
"search for the doc" | |
(when (stringp (cadddr sexp)) | |
(cadddr sexp))) | |
(defun generate-docs (defuns) | |
"generate a simple org with the docs" | |
(mapconcat | |
(lambda (x) | |
(format "\n* %s\n %s" | |
(car x) (or (cdr x) "-undocumented-"))) | |
defuns "\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment