Mercurial > emacs
comparison lisp/emacs-lisp/checkdoc.el @ 20603:24dda0afd915
Added some more comments in the commentary.
You can now `quote' symbols that look like keystrokes
When spell checking, meta variables can end in `th' or `s'.
author | Eric M. Ludlam <zappo@gnu.org> |
---|---|
date | Thu, 08 Jan 1998 23:35:34 +0000 |
parents | 05408326bad6 |
children | f3f9df46d008 |
comparison
equal
deleted
inserted
replaced
20602:e8566ea47491 | 20603:24dda0afd915 |
---|---|
1 ;;; checkdoc --- Check documentation strings for style requirements | 1 ;;; checkdoc --- Check documentation strings for style requirements |
2 | 2 |
3 ;;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;;; Copyright (C) 1997, 1998 Free Software Foundation |
4 ;; | 4 ;; |
5 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu> | 5 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
6 ;; Version: 0.4.1 | 6 ;; Version: 0.4.2 |
7 ;; Keywords: docs, maint, lisp | 7 ;; Keywords: docs, maint, lisp |
8 ;; | 8 ;; |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 ;; |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
12 ;; it under the terms of the GNU General Public License as published by | 12 ;; it under the terms of the GNU General Public License as published by |
13 ;; the Free Software Foundation; either version 2, or (at your option) | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
14 ;; any later version. | 14 ;; any later version. |
15 | 15 ;; |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | 16 ;; GNU Emacs is distributed in the hope that it will be useful, |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 ;; GNU General Public License for more details. | 19 ;; GNU General Public License for more details. |
20 | 20 ;; |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02111-1307, USA. |
25 | 25 |
71 ;; your documentation. | 71 ;; your documentation. |
72 ;; There is a list of lisp-specific words which checkdoc will | 72 ;; There is a list of lisp-specific words which checkdoc will |
73 ;; install into ispell on the fly, but only if ispell is not already | 73 ;; install into ispell on the fly, but only if ispell is not already |
74 ;; running. Use `ispell-kill-ispell' to make checkdoc restart it with | 74 ;; running. Use `ispell-kill-ispell' to make checkdoc restart it with |
75 ;; these words enabled. | 75 ;; these words enabled. |
76 ;; | |
77 ;; Checking parameters | |
78 ;; | |
79 ;; You might not always want a function to have it's parameters listed | |
80 ;; in order. When this is the case, put the following comment just in | |
81 ;; front of the documentation string: "; checkdoc-order: nil" This | |
82 ;; overrides the value of `checkdoc-arguments-in-order-flag'. | |
83 ;; | |
84 ;; If you specifically wish to avoid mentioning a parameter of a | |
85 ;; function in the doc string (such as a hidden parameter, or a | |
86 ;; parameter which is very obvious like events), you can have checkdoc | |
87 ;; skip looking for it by putting the following comment just in front | |
88 ;; of the documentation string: "; checkdoc-params: (args go here)" | |
76 ;; | 89 ;; |
77 ;; Adding your own checks: | 90 ;; Adding your own checks: |
78 ;; | 91 ;; |
79 ;; You can experiment with adding your own checks by setting the | 92 ;; You can experiment with adding your own checks by setting the |
80 ;; hooks `checkdoc-style-hooks' and `checkdoc-comment-style-hooks'. | 93 ;; hooks `checkdoc-style-hooks' and `checkdoc-comment-style-hooks'. |
151 ;; C-m in warning buffer also goes to error. | 164 ;; C-m in warning buffer also goes to error. |
152 ;; Shrink error buffer to size of text. | 165 ;; Shrink error buffer to size of text. |
153 ;; Added `checkdoc-tripple-semi-comment-check-flag'. | 166 ;; Added `checkdoc-tripple-semi-comment-check-flag'. |
154 ;; `checkdoc-spellcheck-documentation-flag' off by default. | 167 ;; `checkdoc-spellcheck-documentation-flag' off by default. |
155 ;; Re-sorted check order so white space is removed before adding a . | 168 ;; Re-sorted check order so white space is removed before adding a . |
169 ;; 0.4.2 Added some more comments in the commentary. | |
170 ;; You can now `quote' symbols that look like keystrokes | |
171 ;; When spell checking, meta variables can end in `th' or `s'. | |
156 | 172 |
157 ;;; TO DO: | 173 ;;; TO DO: |
158 ;; Hook into the byte compiler on a defun/defver level to generate | 174 ;; Hook into the byte compiler on a defun/defver level to generate |
159 ;; warnings in the byte-compiler's warning/error buffer. | 175 ;; warnings in the byte-compiler's warning/error buffer. |
160 ;; Better ways to override more typical `eval' functions. Advice | 176 ;; Better ways to override more typical `eval' functions. Advice |
164 ;; Code sweep checks for "forbidden functions", proper use of hooks, | 180 ;; Code sweep checks for "forbidden functions", proper use of hooks, |
165 ;; proper keybindings, and other items from the manual that are | 181 ;; proper keybindings, and other items from the manual that are |
166 ;; not specifically docstring related. Would this even be useful? | 182 ;; not specifically docstring related. Would this even be useful? |
167 | 183 |
168 ;;; Code: | 184 ;;; Code: |
169 (defvar checkdoc-version "0.4.1" | 185 (defvar checkdoc-version "0.4.2" |
170 "Release version of checkdoc you are currently running.") | 186 "Release version of checkdoc you are currently running.") |
171 | 187 |
172 ;; From custom web page for compatibility between versions of custom: | 188 ;; From custom web page for compatibility between versions of custom: |
173 (eval-and-compile | 189 (eval-and-compile |
174 (condition-case () | 190 (condition-case () |
179 ;; We have the old custom-library, hack around it! | 195 ;; We have the old custom-library, hack around it! |
180 (defmacro defgroup (&rest args) | 196 (defmacro defgroup (&rest args) |
181 nil) | 197 nil) |
182 (defmacro custom-add-option (&rest args) | 198 (defmacro custom-add-option (&rest args) |
183 nil) | 199 nil) |
184 (defmacro defcustom (var value doc &rest args) | 200 (defmacro defcustom (var value doc &rest args) |
185 (` (defvar (, var) (, value) (, doc)))))) | 201 (` (defvar (, var) (, value) (, doc)))))) |
186 | 202 |
187 (defcustom checkdoc-autofix-flag 'semiautomatic | 203 (defcustom checkdoc-autofix-flag 'semiautomatic |
188 "*Non-nil means attempt auto-fixing of doc-strings. | 204 "*Non-nil means attempt auto-fixing of doc-strings. |
189 If this value is the symbol 'query, then the user is queried before | 205 If this value is the symbol 'query, then the user is queried before |
276 "Hooks called after the standard comment style check is completed. | 292 "Hooks called after the standard comment style check is completed. |
277 Must return nil if no errors are found, or a string describing the | 293 Must return nil if no errors are found, or a string describing the |
278 problem discovered. This is useful for adding additional checks.") | 294 problem discovered. This is useful for adding additional checks.") |
279 | 295 |
280 (defvar checkdoc-diagnostic-buffer "*Style Warnings*" | 296 (defvar checkdoc-diagnostic-buffer "*Style Warnings*" |
281 "Name of the buffer where checkdoc stores warning messages.") | 297 "Name of warning message buffer.") |
282 | 298 |
283 (defvar checkdoc-defun-regexp | 299 (defvar checkdoc-defun-regexp |
284 "^(def\\(un\\|var\\|custom\\|macro\\|const\\|subst\\|advice\\)\ | 300 "^(def\\(un\\|var\\|custom\\|macro\\|const\\|subst\\|advice\\)\ |
285 \\s-+\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]+" | 301 \\s-+\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]+" |
286 "Regular expression used to identify a defun. | 302 "Regular expression used to identify a defun. |
1102 replace original))))) | 1118 replace original))))) |
1103 ;; * Don't write key sequences directly in documentation strings. | 1119 ;; * Don't write key sequences directly in documentation strings. |
1104 ;; Instead, use the `\\[...]' construct to stand for them. | 1120 ;; Instead, use the `\\[...]' construct to stand for them. |
1105 (save-excursion | 1121 (save-excursion |
1106 (let ((f nil) (m nil) (start (point)) | 1122 (let ((f nil) (m nil) (start (point)) |
1107 (re "\\<\\([CMA]-[a-zA-Z]\\|\\(\\([CMA]-\\)?\ | 1123 (re "[^`]\\([CMA]-[a-zA-Z]\\|\\(\\([CMA]-\\)?\ |
1108 mouse-[0-3]\\)\\)\\>")) | 1124 mouse-[0-3]\\)\\)\\>")) |
1109 ;; Find the first key sequence not in a sample | 1125 ;; Find the first key sequence not in a sample |
1110 (while (and (not f) (setq m (re-search-forward re e t))) | 1126 (while (and (not f) (setq m (re-search-forward re e t))) |
1111 (setq f (not (checkdoc-in-sample-code-p start e)))) | 1127 (setq f (not (checkdoc-in-sample-code-p start e)))) |
1112 (if m | 1128 (if m |
1420 (if (and sym (or (boundp sym) (fboundp sym))) | 1436 (if (and sym (or (boundp sym) (fboundp sym))) |
1421 ;; This is probably repetative in most cases, but not always. | 1437 ;; This is probably repetative in most cases, but not always. |
1422 nil | 1438 nil |
1423 ;; Find out how we spell-check this word. | 1439 ;; Find out how we spell-check this word. |
1424 (if (or | 1440 (if (or |
1425 (not (string-match "[a-z]" word)) ;all caps meta variable | 1441 ;; All caps w/ option th, or s tacked on the end |
1442 ;; for pluralization or nuberthness. | |
1443 (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word) | |
1426 (looking-at "}") ; a keymap expression | 1444 (looking-at "}") ; a keymap expression |
1427 ) | 1445 ) |
1428 nil | 1446 nil |
1429 (save-excursion | 1447 (save-excursion |
1430 (if (not (eq checkdoc-autofix-flag 'never)) | 1448 (if (not (eq checkdoc-autofix-flag 'never)) |