Function: shortdoc-function-examples
shortdoc-function-examples is a byte-compiled function defined in
shortdoc.el.gz.
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.
Probably introduced at or before Emacs version 30.1.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/shortdoc.el.gz
(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--insert-group-in-buffer group)
(goto-char (point-min))
(let ((match (text-property-search-forward
'shortdoc-example function t)))
(push `(,group . ,(string-trim
(buffer-substring-no-properties
(prop-match-beginning match)
(prop-match-end match))))
examples))))
groups)
examples))