Documentation groups, available since Emacs 28, are useful to document functions of Lisp packages based on various groupings (see Documentation Groups). This section gives some tips on how you can define documentation groups in your Lisp package in a way such that users of different Emacs versions can equally well use these groups.
;;; well-doc.el --- a well-documented package -*- lexical-binding: t; -*- ... package header and contents ...
;; Explicitly require shortdoc for Emacs 28, which does not have an
;; autoload for macro `define-short-documentation-group'. And for
;; Emacs 30, so that we can redefine `shortdoc--check' later.
(require 'shortdoc nil t)
(eval-when-compile
;; Default macro `define-short-documentation-group' for Emacs 27
;; and older, which do not have the shortdoc feature at all.
(unless (fboundp 'define-short-documentation-group)
(defmacro define-short-documentation-group (&rest _)))
;; Disable too rigid shortdoc checks for Emacs 30, which let it
;; error out on newer shortdoc keywords.
(when (eq emacs-major-version 30)
(fset 'shortdoc--check #'ignore)))
(define-short-documentation-group well-doc ...) ;;; well-doc.el ends here
If you do not intend to support some of the Emacs versions mentioned
above, you can safely omit the corresponding forms from the template.
If you intend to support only Emacs 31 and newer, you do not need any
of the above and can just use define-short-documentation-group.
:super-pretty-print, available
in some future Emacs version, like this in your Lisp package
well-doc.el:
(define-short-documentation-group well-doc (well-doc-foo :eval (well-doc-foo) :super-pretty-print t))
That future Emacs version will then supposedly super-pretty-print the
example for function well-doc-foo. Older Emacs versions will
silently ignore keyword :super-pretty-print and show the example
according to their regular display rules.