Skip to content

Instantly share code, notes, and snippets.

@kidd
Last active December 10, 2015 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidd/4486639 to your computer and use it in GitHub Desktop.
Save kidd/4486639 to your computer and use it in GitHub Desktop.
(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