Function: advice--make-docstring
advice--make-docstring is a byte-compiled function defined in
nadvice.el.gz.
Signature
(advice--make-docstring FUNCTION)
Documentation
Build the raw docstring for FUNCTION, presumably advised.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/nadvice.el.gz
(defun advice--make-docstring (function)
"Build the raw docstring for FUNCTION, presumably advised."
(let* ((flist (indirect-function function))
(docfun nil)
(macrop (eq 'macro (car-safe flist)))
(before nil)
(after nil))
(when macrop
(setq flist (cdr flist)))
(if (and (autoloadp flist)
(get function 'advice--pending))
(setq after
(advice--make-single-doc (get function 'advice--pending)
function macrop))
(while (advice--p flist)
;; Hack attack! For advices installed before calling
;; Snarf-documentation, the integer offset into the DOC file will not
;; be installed in the "core unadvised function" but in the advice
;; object instead! So here we try to undo the damage.
(when (integerp (aref flist 4))
(setq docfun flist))
(let ((doc-bit (advice--make-single-doc flist function macrop)))
;; We want :overrides to go to the front, because they mean
;; that the doc string may be irrelevant.
(if (eq (advice--how flist) :override)
(setq before (concat before doc-bit))
(setq after (concat after doc-bit))))
(setq flist (advice--cdr flist))))
(unless docfun
(setq docfun flist))
(let* ((origdoc (unless (eq function docfun) ;Avoid inf-loops.
(documentation docfun t)))
(usage (help-split-fundoc origdoc function)))
(setq usage (if (null usage)
(let ((arglist (help-function-arglist flist)))
;; "[Arg list not available until function
;; definition is loaded]", bug#21299
(if (stringp arglist) t
(help--make-usage-docstring function arglist)))
(setq origdoc (cdr usage)) (car usage)))
(help-add-fundoc-usage
(with-temp-buffer
(when before
(insert before)
(ensure-empty-lines 1))
(when origdoc
(insert origdoc))
(when after
(ensure-empty-lines 1)
(insert after))
(buffer-string))
usage))))