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-flagNon-nil means warn if function arguments are missing from docstring.
checkdoc--dired-skip-lines-reRegexp that when it matches tells ‘checkdoc-dired’ to skip a file.
checkdoc--disambiguate-symbol-flagNon-nil means ask to disambiguate Lisp symbol.
checkdoc--help-bufferName of buffer used for Checkdoc Help.
checkdoc--interactive-docstring-flagNon-nil means warn if interactive function has no docstring.
checkdoc-allow-quoting-nil-and-tIf non-nil, don’t warn when the symbols nil and t are quoted.
checkdoc-arguments-in-order-flagNon-nil means warn if arguments appear out of order.
checkdoc-arguments-missing-flagNon-nil means warn if function arguments are missing from docstring.
checkdoc-autofix-flagNon-nil means attempt auto-fixing of doc strings.
checkdoc-bouncy-flagNon-nil means to "bounce" to auto-fix locations.
checkdoc-column-zero-backslash-before-parenNon-nil means to warn if there is no "\" before "(" in column zero.
checkdoc-comment-style-functionsHook run after the standard comment style check is completed.
checkdoc-commentary-header-stringString inserted as commentary marker in ‘checkdoc-file-comments-engine’.
checkdoc-common-verbs-regexpRegular expression derived from ‘checkdoc-common-verbs-regexp’.
checkdoc-common-verbs-wrong-voiceAlist of common words in the wrong voice and what should be used instead.
checkdoc-create-error-functionFunction called when Checkdoc encounters an error.
checkdoc-diagnostic-bufferName of warning message buffer.
checkdoc-force-docstrings-flagNon-nil means that all checkable definitions should have documentation.
checkdoc-force-history-flagNon-nil means that files should have a History section or ChangeLog file.
checkdoc-generate-compile-warnings-flagNon-nil means generate warnings in a buffer for browsing.
checkdoc-ispell-lisp-wordsList of words that are correct when spell-checking Lisp documentation.
checkdoc-max-keyref-before-warnMaximum number of \[command-to-keystroke] tokens allowed in a doc string.
checkdoc-minor-modeNon-nil if Checkdoc minor mode is enabled.
checkdoc-minor-mode-hookHook run after entering or leaving ‘checkdoc-minor-mode’.
checkdoc-minor-mode-mapKeymap used to override evaluation key-bindings for documentation checking.
checkdoc-minor-mode-stringString to display in mode line when Checkdoc mode is enabled; nil for none.
checkdoc-output-font-lock-keywordsKeywords used to highlight a checkdoc diagnostic buffer.
checkdoc-output-mode-abbrev-tableAbbrev table for ‘checkdoc-output-mode’.
checkdoc-output-mode-hookHook run after entering ‘checkdoc-output-mode’.
checkdoc-output-mode-mapKeymap for ‘checkdoc-output-mode’.
checkdoc-output-mode-syntax-tableSyntax table for ‘checkdoc-output-mode’.
checkdoc-package-keywords-flagNon-nil means warn if this file’s package keywords are not recognized.
checkdoc-pending-errorsNon-nil when there are errors that have not been displayed yet.
checkdoc-permit-comma-termination-flagNon-nil means the first line of a docstring may end with a comma.
checkdoc-proper-noun-listList of words (not capitalized) which should be capitalized.
checkdoc-proper-noun-regexpRegular expression derived from ‘checkdoc-proper-noun-regexp’.
checkdoc-spellcheck-documentation-flagNon-nil means run Ispell on text based on value.
checkdoc-style-functionsHook run after the standard style check is completed.
checkdoc-symbol-wordsA list of symbol names (strings) which also happen to make good words.
checkdoc-syntax-tableSyntax table used by checkdoc in document strings.
checkdoc-verb-check-experimental-flagNon-nil means to attempt to check the voice of the doc string.
checkdoc-versionRelease version of checkdoc you are currently running.

Defined functions (78)

checkdoc()
checkdoc--create-error(TEXT START END &optional UNFIXABLE)
checkdoc--create-error--cmacro(CL-WHOLE-ARG TEXT START END &optional UNFIXABLE)
checkdoc--create-error-for-checkdoc(TEXT START END &optional UNFIXABLE)
checkdoc--error-bad-format-p()
checkdoc--fix-y-or-n-p()
checkdoc--next-docstring()
checkdoc-autofix-ask-replace(START END QUESTION REPLACEWITH &optional COMPLEX)
checkdoc-buffer-label()
checkdoc-comments(&optional TAKE-NOTES)
checkdoc-continue(&optional TAKE-NOTES)
checkdoc-create-common-verbs-regexp()
checkdoc-create-error(TEXT START END &optional UNFIXABLE)
checkdoc-current-buffer(&optional TAKE-NOTES)
checkdoc-defun(&optional NO-ERROR)
checkdoc-defun-info()
checkdoc-dired(FILES)
checkdoc-display-status-buffer(CHECK)
checkdoc-error(POINT MSG)
checkdoc-error-end(checkdoc-error-end X)
checkdoc-error-end--inliner(INLINE--FORM X)
checkdoc-error-p(X)
checkdoc-error-p--inliner(INLINE--FORM X)
checkdoc-error-start(checkdoc-error-start X)
checkdoc-error-start--inliner(INLINE--FORM X)
checkdoc-error-text(checkdoc-error-text X)
checkdoc-error-text--inliner(INLINE--FORM X)
checkdoc-error-unfixable(checkdoc-error-unfixable X)
checkdoc-error-unfixable--inliner(INLINE--FORM X)
checkdoc-eval-current-buffer()
checkdoc-eval-defun()
checkdoc-file(FILE)
checkdoc-file-comments-engine()
checkdoc-get-keywords()
checkdoc-in-abbreviation-p(BEGIN)
checkdoc-in-example-string-p(START LIMIT)
checkdoc-in-sample-code-p(START LIMIT)
checkdoc-interactive(&optional START-HERE SHOWSTATUS)
checkdoc-interactive-ispell-loop(START-HERE)
checkdoc-interactive-loop(START-HERE SHOWSTATUS FINDFUNC)
checkdoc-ispell()
checkdoc-ispell-comments()
checkdoc-ispell-continue()
checkdoc-ispell-current-buffer()
checkdoc-ispell-defun()
checkdoc-ispell-docstring-engine(END &optional TAKE-NOTES)
checkdoc-ispell-init()
checkdoc-ispell-interactive()
checkdoc-ispell-message-interactive()
checkdoc-ispell-message-text()
checkdoc-ispell-start()
checkdoc-list-of-strings-p(OBJ)
checkdoc-message-interactive(&optional START-HERE SHOWSTATUS)
checkdoc-message-interactive-ispell-loop(START-HERE)
checkdoc-message-text(&optional TAKE-NOTES)
checkdoc-message-text-engine(&optional TYPE)
checkdoc-message-text-next-string(END)
checkdoc-message-text-search(&optional BEG END)
checkdoc-minor-mode(&optional ARG)
checkdoc-next-docstring()
checkdoc-next-error(ENABLE-FIX)
checkdoc-next-message-error(ENABLE-FIX)
checkdoc-output-mode()
checkdoc-outside-major-sexp()
checkdoc-package-keywords()
checkdoc-proper-noun-region-engine(BEGIN END)
checkdoc-recursive-edit(MSG)
checkdoc-rogue-space-check-engine(&optional START END INTERACT)
checkdoc-rogue-spaces(&optional TAKE-NOTES INTERACT)
checkdoc-run-hooks(HOOK &rest ARGS)
checkdoc-sentencespace-region-engine(BEGIN END)
checkdoc-show-diagnostics()
checkdoc-start(&optional TAKE-NOTES)
checkdoc-start-section(CHECK-TYPE)
checkdoc-this-string-valid(&optional TAKE-NOTES)
checkdoc-this-string-valid-engine(FP &optional TAKE-NOTES)
checkdoc-y-or-n-p(QUESTION)
copy-checkdoc-error(ARG)

Defined faces (0)