File: checkdoc.el.html
The Emacs Lisp manual has a nice chapter on how to write documentation strings. Many stylistic suggestions are fairly deterministic and easy to check for syntactically, but also easy to forget. The main checkdoc engine will perform the stylistic checks needed to make sure these styles are remembered.
There are four ways to use checkdoc:
1) Use flymake-mode(var)/flymake-mode(fun). Type M-x flymake-mode in any Emacs Lisp
buffer; the checkdoc back-end is enabled by default.
2) Periodically use checkdoc or checkdoc-current-buffer.
The checkdoc command is a more interactive version of
checkdoc-current-buffer.
3) Use checkdoc-minor-mode(var)/checkdoc-minor-mode(fun) to automatically check your
documentation whenever you evaluate Lisp code with C-M-x
or [menu-bar emacs-lisp eval-buffer]. Additional key-bindings
are also provided under C-c ? KEY
(add-hook 'emacs-lisp-mode-hook 'checkdoc-minor-mode)
4) Use checkdoc-ispell to spellcheck docstrings interactively.
Using checkdoc:
Most users will probably use checkdoc through flymake. The
commands checkdoc and checkdoc-ispell are the top-level entry
points to all of the different checks that are available. It
breaks examination of your Lisp file into four sections (comments,
documentation, messages, and spacing) and indicates its current
state in a status buffer.
The Comments check examines your headers, footers, and
various tags (such as "Code:") to make sure that your code is ready
for easy integration into existing systems.
The Documentation check deals with documentation strings
and their elements that help make Emacs easier to use.
The Messages check ensures that the strings displayed in the
minibuffer by some commands (such as error and y-or-n-p)
are consistent with the Emacs environment.
The Spacing check cleans up white-space at the end of lines.
The interface while working with documentation and messages is
slightly different when being run in the interactive mode. The
interface offers several options, including the ability to skip to
the next error, or back up to previous errors. Auto-fixing is
turned off at this stage, but you can use the f or F key to fix
a given error (if the fix is available).
Auto-fixing:
There are four classifications of style errors in terms of how
easy they are to fix. They are simple, complex, really complex,
and impossible. (Impossible really means that checkdoc does not
have a fixing routine yet.) Typically white-space errors are
classified as simple, and are auto-fixed by default. Typographic
changes are considered complex, and the user is asked if they want
the problem fixed before checkdoc makes the change. These changes
can be done without asking if checkdoc-autofix-flag is properly
set. Potentially redundant changes are considered really complex,
and the user is always asked before a change is inserted. The
variable checkdoc-autofix-flag controls how these types of errors
are fixed.
Spell checking text:
The variable checkdoc-spellcheck-documentation-flag can be set
to customize how spell checking is to be done. Since spell
checking can be quite slow, you can optimize how best you want your
checking done. The default is defun, which spell checks each time
checkdoc-defun or checkdoc-eval-defun is used. Setting to nil
prevents spell checking during normal usage.
Setting this variable to nil does not mean you cannot take
advantage of the spell checking. You can instead use the
interactive functions checkdoc-ispell-* to check the spelling of
your documentation.
There is a list of Lisp-specific words which checkdoc will
install into Ispell on the fly, but only if Ispell is not already
running. Use ispell-kill-ispell to make checkdoc restart it with
these words enabled.
See also the flyspell-prog-mode minor mode.
Checking parameters:
You might not always want a function to have its parameters listed
in order. When this is the case, put the following comment just in
front of the documentation string: "; checkdoc-order: nil" This
overrides the value of checkdoc-arguments-in-order-flag.
If you specifically wish to avoid mentioning a parameter of a
function in the doc string (such as a hidden parameter, or a
parameter which is very obvious like events), you can have checkdoc
skip looking for it by putting the following comment just in front
of the documentation string: "; checkdoc-params: (args go here)"
Checking message strings:
The text that follows the error and y-or-n-p commands is
also checked. The documentation for error clearly states some
simple style rules to follow which checkdoc will auto-fix for you.
y-or-n-p and yes-or-no-p should also end in "?".
Adding your own checks:
You can experiment with adding your own checks by setting the
hooks checkdoc-style-functions and checkdoc-comment-style-functions.
Return a string which is the error you wish to report. The cursor
position should be preserved.
Error errors:
Checkdoc does not always flag errors correctly. There are a
couple ways you can coax your file into passing all of checkdoc's
tests through buffer local variables.
The variable checkdoc-verb-check-experimental-flag can be used
to turn off the check for verb-voice in case you use words that are
not semantically verbs, but are still in the incomplete list.
The variable checkdoc-symbol-words can be a list of words that
happen to also be symbols. This is not a problem for one-word
symbols, but if you use a hyphenated word that is also a symbol,
then you may need this.
The symbol checkdoc-force-docstrings-flag can be set to nil if
you have many undocumented functions you don't wish to document.
See the above section "Checking Parameters" for details about
parameter checking.
Defined variables (42)
checkdoc--argument-missing-flag | Non-nil means warn if function arguments are missing from docstring. |
checkdoc--dired-skip-lines-re | Regexp that when it matches tells ‘checkdoc-dired’ to skip a file. |
checkdoc--disambiguate-symbol-flag | Non-nil means ask to disambiguate Lisp symbol. |
checkdoc--help-buffer | Name of buffer used for Checkdoc Help. |
checkdoc--interactive-docstring-flag | Non-nil means warn if interactive function has no docstring. |
checkdoc-allow-quoting-nil-and-t | If non-nil, don’t warn when the symbols nil and t are quoted. |
checkdoc-arguments-in-order-flag | Non-nil means warn if arguments appear out of order. |
checkdoc-arguments-missing-flag | Non-nil means warn if function arguments are missing from docstring. |
checkdoc-autofix-flag | Non-nil means attempt auto-fixing of doc strings. |
checkdoc-bouncy-flag | Non-nil means to "bounce" to auto-fix locations. |
checkdoc-column-zero-backslash-before-paren | Non-nil means to warn if there is no "\" before "(" in column zero. |
checkdoc-comment-style-functions | Hook run after the standard comment style check is completed. |
checkdoc-commentary-header-string | String inserted as commentary marker in ‘checkdoc-file-comments-engine’. |
checkdoc-common-verbs-regexp | Regular expression derived from ‘checkdoc-common-verbs-regexp’. |
checkdoc-common-verbs-wrong-voice | Alist of common words in the wrong voice and what should be used instead. |
checkdoc-create-error-function | Function called when Checkdoc encounters an error. |
checkdoc-diagnostic-buffer | Name of warning message buffer. |
checkdoc-force-docstrings-flag | Non-nil means that all checkable definitions should have documentation. |
checkdoc-force-history-flag | Non-nil means that files should have a History section or ChangeLog file. |
checkdoc-generate-compile-warnings-flag | Non-nil means generate warnings in a buffer for browsing. |
checkdoc-ispell-lisp-words | List of words that are correct when spell-checking Lisp documentation. |
checkdoc-max-keyref-before-warn | Maximum number of \[command-to-keystroke] tokens allowed in a doc string. |
checkdoc-minor-mode | Non-nil if Checkdoc minor mode is enabled. |
checkdoc-minor-mode-hook | Hook run after entering or leaving ‘checkdoc-minor-mode’. |
checkdoc-minor-mode-map | Keymap used to override evaluation key-bindings for documentation checking. |
checkdoc-minor-mode-string | String to display in mode line when Checkdoc mode is enabled; nil for none. |
checkdoc-output-font-lock-keywords | Keywords used to highlight a checkdoc diagnostic buffer. |
checkdoc-output-mode-abbrev-table | Abbrev table for ‘checkdoc-output-mode’. |
checkdoc-output-mode-hook | Hook run after entering ‘checkdoc-output-mode’. |
checkdoc-output-mode-map | Keymap for ‘checkdoc-output-mode’. |
checkdoc-output-mode-syntax-table | Syntax table for ‘checkdoc-output-mode’. |
checkdoc-package-keywords-flag | Non-nil means warn if this file’s package keywords are not recognized. |
checkdoc-pending-errors | Non-nil when there are errors that have not been displayed yet. |
checkdoc-permit-comma-termination-flag | Non-nil means the first line of a docstring may end with a comma. |
checkdoc-proper-noun-list | List of words (not capitalized) which should be capitalized. |
checkdoc-proper-noun-regexp | Regular expression derived from ‘checkdoc-proper-noun-regexp’. |
checkdoc-spellcheck-documentation-flag | Non-nil means run Ispell on text based on value. |
checkdoc-style-functions | Hook run after the standard style check is completed. |
checkdoc-symbol-words | A list of symbol names (strings) which also happen to make good words. |
checkdoc-syntax-table | Syntax table used by checkdoc in document strings. |
checkdoc-verb-check-experimental-flag | Non-nil means to attempt to check the voice of the doc string. |
checkdoc-version | Release version of checkdoc you are currently running. |