Merge remote-tracking branch 'bug#80297-extend-shortdoc-infrastructure'
This commit is contained in:
@@ -1661,6 +1661,7 @@ Tips and Conventions
|
||||
* Compilation Tips:: Making compiled code run fast.
|
||||
* Warning Tips:: Turning off compiler warnings.
|
||||
* Documentation Tips:: Writing readable documentation strings.
|
||||
* Documentation Group Tips:: Writing useful documentation groups.
|
||||
* Comment Tips:: Conventions for writing comments.
|
||||
* Library Headers:: Standard headers for library packages.
|
||||
|
||||
|
||||
@@ -828,14 +828,16 @@ if the user types the help character again.
|
||||
@cindex documentation groups
|
||||
@cindex groups of functions
|
||||
@cindex function groups
|
||||
@cindex shortdoc groups
|
||||
|
||||
Emacs can list functions based on various groupings. For instance,
|
||||
@code{string-trim} and @code{mapconcat} are ``string'' functions, so
|
||||
@kbd{M-x shortdoc RET string RET} will give an overview
|
||||
of functions that operate on strings.
|
||||
@kbd{M-x shortdoc RET string RET} will give an overview of these and
|
||||
other functions that operate on strings.
|
||||
|
||||
The documentation groups are created with the
|
||||
@code{define-short-documentation-group} macro.
|
||||
@code{define-short-documentation-group} macro. @xref{Documentation
|
||||
Group Tips}, for how to write good documentation groups.
|
||||
|
||||
@defmac define-short-documentation-group group &rest functions
|
||||
Define @var{group} as a group of functions, and provide short
|
||||
@@ -846,6 +848,7 @@ summaries of using those functions. The optional argument
|
||||
(@var{func} [@var{keyword} @var{val}]@dots{})
|
||||
@end lisp
|
||||
|
||||
@cindex documentation group keywords
|
||||
The following keywords are recognized:
|
||||
|
||||
@table @code
|
||||
|
||||
@@ -35,6 +35,7 @@ in batch mode, e.g., with a command run by @kbd{@w{M-x compile
|
||||
* Compilation Tips:: Making compiled code run fast.
|
||||
* Warning Tips:: Turning off compiler warnings.
|
||||
* Documentation Tips:: Writing readable documentation strings.
|
||||
* Documentation Group Tips:: Writing useful documentation groups.
|
||||
* Comment Tips:: Conventions for writing comments.
|
||||
* Library Headers:: Standard headers for library packages.
|
||||
@end menu
|
||||
@@ -934,6 +935,89 @@ If you do not anticipate anyone editing your code with older Emacs
|
||||
versions, there is no need for this work-around.
|
||||
@end itemize
|
||||
|
||||
@node Documentation Group Tips
|
||||
@section Tips for Documentation Groups
|
||||
@cindex documentation groups, tips
|
||||
@cindex tips for documentation groups
|
||||
|
||||
@cindex documentation groups, compatibility
|
||||
Documentation groups, available since Emacs 28, are useful to document
|
||||
functions of Lisp packages based on various groupings
|
||||
(@pxref{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.
|
||||
|
||||
@itemize @bullet
|
||||
@item
|
||||
To define documentation groups for your own Lisp package across
|
||||
different Emacs versions, you can use a boilerplate template along the
|
||||
lines of the following to make your package compile and load without
|
||||
errors:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
;;; well-doc.el --- a well-documented package -*- lexical-binding: t; -*-
|
||||
|
||||
@dots{} package header and contents @dots{}
|
||||
@end group
|
||||
|
||||
@group
|
||||
;; 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)))
|
||||
@end group
|
||||
|
||||
@group
|
||||
(define-short-documentation-group well-doc
|
||||
@dots{})
|
||||
|
||||
;;; well-doc.el ends here
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
@findex define-short-documentation-group
|
||||
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 @code{define-short-documentation-group}.
|
||||
|
||||
@item
|
||||
@cindex documentation group keywords, compatibility
|
||||
Newer Emacs versions might introduce newer documentation group features
|
||||
and keywords. However, these features or keywords will never break the
|
||||
display of a documentation group in older Emacs versions. Suppose you
|
||||
use a hypothetical group keyword @code{:super-pretty-print}, available
|
||||
in some future Emacs version, like this in your Lisp package
|
||||
@file{well-doc.el}:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
(define-short-documentation-group well-doc
|
||||
(well-doc-foo
|
||||
:eval (well-doc-foo)
|
||||
:super-pretty-print t))
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
That future Emacs version will then supposedly super-pretty-print the
|
||||
example for function @code{well-doc-foo}. Older Emacs versions will
|
||||
silently ignore keyword @code{:super-pretty-print} and show the example
|
||||
according to their regular display rules.
|
||||
@end itemize
|
||||
|
||||
@node Comment Tips
|
||||
@section Tips on Writing Comments
|
||||
@cindex comments, Lisp convention for
|
||||
|
||||
1528
lisp/emacs-lisp/shortdoc-doc.el
Normal file
1528
lisp/emacs-lisp/shortdoc-doc.el
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5849,7 +5849,7 @@ language."
|
||||
"Pattern matching"
|
||||
(treesit-query-capture
|
||||
:no-eval (treesit-query-capture node '((identifier) @id "return" @ret))
|
||||
:eg-result-string "((id . #<treesit-node (identifier) in 195-196>) (ret . #<treesit-node "return" in 338-344>))")
|
||||
:eg-result-string "((id . #<treesit-node (identifier) in 195-196>) (ret . #<treesit-node \"return\" in 338-344>))")
|
||||
(treesit-query-compile
|
||||
:no-eval (treesit-query-compile 'c '((identifier) @id "return" @ret))
|
||||
:eg-result-string "#<treesit-compiled-query>")
|
||||
|
||||
Reference in New Issue
Block a user