Created
November 17, 2014 02:32
-
-
Save jleechpe/bc1ef519964d7bd8bd13 to your computer and use it in GitHub Desktop.
Extract function information for use in an org file
This file contains hidden or 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 extract-information (sym) | |
(if (fboundp sym) | |
(cons 'function (or (help-split-fundoc (documentation sym) sym) | |
(documentation sym))) | |
(cons 'variable (documentation-property sym 'variable-documentation)))) | |
(defun def-to-org-headline (sym &optional level) | |
(let* ((toplevel (or level 1)) | |
(info (extract-information sym)) | |
(name (format "%s" sym)) | |
(type (format "%s" (car info))) | |
(arglist (if (and (equal (car info) 'function) | |
(consp (cdr info))) | |
(cadr info))) | |
(docstring (if (consp (cdr info)) | |
(cddr info) | |
(cdr info))) | |
construct args props docs) | |
(setq construct `(headline (:title ,name :level ,toplevel))) | |
(setq props | |
`(property-drawer | |
() | |
(node-property (:key "Type" | |
:value ,type)))) | |
(setq docs | |
`(paragraph () ,docstring)) | |
(if arglist | |
(setq args | |
`(headline (:title "Argument List" :level ,(1+ toplevel)) | |
(paragraph () ,arglist)))) | |
(setq construct | |
(org-element-adopt-elements construct | |
props docs)) | |
(if args (setq construct (org-element-adopt-elements construct args))) | |
construct)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment