Function: ad--make-advised-docstring

ad--make-advised-docstring is a byte-compiled function defined in advice.el.gz.

Signature

(ad--make-advised-docstring FUNCTION &optional STYLE)

Documentation

Construct a documentation string for the advised FUNCTION.

Concatenate the original documentation with the documentation strings of the individual pieces of advice. Optional argument STYLE specifies how to format the pieces of advice; it can be plain, or any other value which means the default formatting.

The advice documentation is shown in order of before/around/after advice type, obeying the priority in each of these types.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
(defun ad--make-advised-docstring (function &optional style)
  "Construct a documentation string for the advised FUNCTION.
Concatenate the original documentation with the documentation
strings of the individual pieces of advice.  Optional argument
STYLE specifies how to format the pieces of advice; it can be
`plain', or any other value which means the default formatting.

The advice documentation is shown in order of before/around/after
advice type, obeying the priority in each of these types."
  ;; Retrieve the original function documentation
  (let* ((fun (get function 'function-documentation))
	 (origdoc (unwind-protect
		      (progn (put function 'function-documentation nil)
			     (documentation function t))
		    (put function 'function-documentation fun))))
    (if (and (symbolp function)
	     (string-match "\\`ad-+Advice-" (symbol-name function)))
	(setq function
	      (intern (substring (symbol-name function) (match-end 0)))))
    (let* ((usage (help-split-fundoc origdoc function))
	   paragraphs advice-docstring)
      (setq usage (if (null usage) t (setq origdoc (cdr usage)) (car usage)))
      (if origdoc (setq paragraphs (list origdoc)))
      (dolist (class ad-advice-classes)
	(dolist (advice (ad-get-enabled-advices function class))
	  (setq advice-docstring
		(ad-make-single-advice-docstring advice class style))
	  (if advice-docstring
	      (push advice-docstring paragraphs))))
      (setq origdoc (if paragraphs
			(mapconcat 'identity (nreverse paragraphs)
				   "\n\n")))
      (help-add-fundoc-usage origdoc usage))))