[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here are some tips and conventions for the writing of documentation strings. You can check many of these conventions by running the command M-x checkdoc-minor-mode.
The documentation string is not limited to one line; use as many lines as you need to explain the details of how to use the function or variable. Please use complete sentences in the additional lines.
dired-find-file
is:
In Dired, visit the file or directory named on this line. |
apropos
.
You can fill the text if that looks good. However, rather than blindly filling the entire documentation string, you can often make it much more readable by choosing certain line breaks with care. Use blank lines between topics if the documentation string is long.
nil
values are equivalent and indicate explicitly what
nil
and non-nil
mean.
eval
refers to its second argument as `FORM', because the
actual argument name is form
:
Evaluate FORM and return its value. |
Also write metasyntactic variables in capital letters, such as when you show the decomposition of a list or vector into subunits, some of which may vary. `KEY' and `VALUE' in the following example illustrate this practice:
The argument TABLE should be an alist whose elements have the form (KEY . VALUE). Here, KEY is ... |
The argument FOO can be either a number \(a buffer position) or a string (a file name). |
This prevents the open-parenthesis from being treated as the start of a defun (see section `Defuns' in The GNU Emacs Manual).
Help mode automatically creates a hyperlink when a documentation string uses a symbol name inside single quotes, if the symbol has either a function or a variable definition. You do not need to do anything special to make use of this feature. However, when a symbol has both a function definition and a variable definition, and you want to refer to just one of them, you can specify which one by writing one of the words `variable', `option', `function', or `command', immediately before the symbol name. (Case makes no difference in recognizing these indicator words.) For example, if you write
This function sets the variable `buffer-file-name'. |
then the hyperlink will refer only to the variable documentation of
buffer-file-name
, and not to its function documentation.
If a symbol has a function definition and/or a variable definition, but those are irrelevant to the use of the symbol that you are documenting, you can write the word `symbol' before the symbol name to prevent making any hyperlink. For example,
If the argument KIND-OF-RESULT is the symbol `list', this function returns a list of all the objects that satisfy the criterion. |
does not make a hyperlink to the documentation, irrelevant here, of the
function list
.
To make a hyperlink to Info documentation, write the name of the Info node in single quotes, preceded by `info node' or `Info node'. The Info file name defaults to `emacs'. For example,
See Info node `Font Lock' and Info node `(elisp)Font Lock Basics'. |
forward-char
.
(This is normally `C-f', but it may be some other character if the
user has moved key bindings.) See section 24.3 Substituting Key Bindings in Documentation.
It is not practical to use `\\[...]' very many times, because display of the documentation string will become slow. So use this to describe the most important commands in your major mode, and then use `\\{...}' to display the rest of the mode's keymap.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |