aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Martín2023-02-28 23:15:40 +0100
committerEli Zaretskii2023-03-12 09:54:06 +0200
commit29227e7c19100bed30b3410b399ee6a2c1ca7213 (patch)
tree4cfde01d3e6841d9ea54194c1e3bb785d464c8b7 /test
parent31f18480ca7291070837a305c64685c3e76afde3 (diff)
downloademacs-29227e7c19100bed30b3410b399ee6a2c1ca7213.tar.gz
emacs-29227e7c19100bed30b3410b399ee6a2c1ca7213.zip
Add functions to query Emacs Lisp examples registered in shortdoc
* lisp/emacs-lisp/shortdoc.el (shortdoc--display-function): Add a new shortdoc-example text property so that ELisp examples can be searched for later. (shortdoc--insert-group-in-buffer): New function extracted from the buffer insertion code in 'shortdoc-display-group'. (shortdoc-display-group): Implement in terms of 'shortdoc--insert-group-in-buffer'. (shortdoc-function-examples): New function that returns an alist of Emacs Lisp examples from shortdoc. (shortdoc-help-fns-examples-function): New function to insert Emacs Lisp function examples in *Help* buffers, if added to 'help-fns-describe-function-functions'. * test/lisp/emacs-lisp/shortdoc-tests.el (shortdoc-function-examples-test): Test it. * doc/emacs/help.texi (Name Help): Document in the user manual. * doc/lispref/help.texi (Documentation Groups): Document it. * etc/NEWS: Advertise it. (Bug#61877)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/shortdoc-tests.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/shortdoc-tests.el b/test/lisp/emacs-lisp/shortdoc-tests.el
index 516d095767f..a65a4a5ddc3 100644
--- a/test/lisp/emacs-lisp/shortdoc-tests.el
+++ b/test/lisp/emacs-lisp/shortdoc-tests.el
@@ -65,6 +65,16 @@
65 (when buf 65 (when buf
66 (kill-buffer buf)))))) 66 (kill-buffer buf))))))
67 67
68(ert-deftest shortdoc-function-examples-test ()
69 "Test the extraction of usage examples of some Elisp functions."
70 (should (equal '((list . "(delete 2 (list 1 2 3 4))\n => (1 3 4)\n (delete \"a\" (list \"a\" \"b\" \"c\" \"d\"))\n => (\"b\" \"c\" \"d\")"))
71 (shortdoc-function-examples 'delete)))
72 (should (equal '((alist . "(assq 'foo '((foo . bar) (zot . baz)))\n => (foo . bar)")
73 (list . "(assq 'b '((a . 1) (b . 2)))\n => (b . 2)"))
74 (shortdoc-function-examples 'assq)))
75 (should (equal '((regexp . "(string-match-p \"^[fo]+\" \"foobar\")\n => 0"))
76 (shortdoc-function-examples 'string-match-p))))
77
68(provide 'shortdoc-tests) 78(provide 'shortdoc-tests)
69 79
70;;; shortdoc-tests.el ends here 80;;; shortdoc-tests.el ends here