Function: shortdoc-function-examples

shortdoc-function-examples is a byte-compiled function defined in elisp-doc-extract.el.

Signature

(shortdoc-function-examples FUNCTION)

Documentation

Return all shortdoc examples for FUNCTION.

The result is an alist with items of the form (GROUP . EXAMPLES), where GROUP is a shortdoc group where FUNCTION appears, and EXAMPLES is a string with the usage examples of FUNCTION defined in GROUP. Return nil if FUNCTION is not a function or if it doesn't has any shortdoc information.

Source Code

;; Defined in /nix/store/796qy5jz9b0ygikp41xidcplg2vxxpi4-emacs-29-4/share/emacs/29.4/site-lisp/elisp-doc-extract.el
(when (not (fboundp 'shortdoc-function-examples))
  (defun shortdoc-function-examples (function)
    "Return all shortdoc examples for FUNCTION.
The result is an alist with items of the form (GROUP . EXAMPLES),
where GROUP is a shortdoc group where FUNCTION appears, and
EXAMPLES is a string with the usage examples of FUNCTION defined
in GROUP.  Return nil if FUNCTION is not a function or if it
doesn't has any shortdoc information."
    (let ((groups (and (symbolp function)
                       (shortdoc-function-groups function)))
          (examples nil))
      (mapc
       (lambda (group)
         (with-temp-buffer
           (shortdoc--display-function (assq function (assq group shortdoc--groups)))
           (goto-char (point-min))
           (forward-line 2)
           (push `(,group . ,(string-trim
                              (buffer-substring-no-properties
                               (point)
                               (point-max))))
                 examples)))
       groups)
      examples)))