Function: advice--make-nadvice-docstring

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

Signature

(advice--make-nadvice-docstring SYM)

Documentation

Make docstring for a nadvice function.

Modifies the function's docstring by replacing "<<>>" with the description of the possible HOWs.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/nadvice.el.gz
(defun advice--make-nadvice-docstring (sym)
  "Make docstring for a nadvice function.
Modifies the function's docstring by replacing \"<<>>\" with the
description of the possible HOWs."
  (let* ((main (documentation (symbol-function sym) 'raw))
         (ud (help-split-fundoc main 'pcase))
         (doc (or (cdr ud) main))
         (col1width (apply #'max (mapcar (lambda (x)
                                           (string-width (symbol-name (car x))))
                                         advice--how-alist)))
         (table (mapconcat (lambda (x)
                             (format (format " %%-%ds %%s" col1width)
                                     (car x) (nth 2 x)))
                           advice--how-alist "\n"))
         (table (if global-prettify-symbols-mode
                    (replace-regexp-in-string "(lambda\\>" "(λ" table t t)
                  table))
         (combined-doc
          (if (not (string-match "<<>>" doc))
              doc
            (replace-match table t t doc))))
    (if ud (help-add-fundoc-usage combined-doc (car ud)) combined-doc)))