comparison lisp/emacs-lisp/checkdoc.el @ 21181:2b9774c50f91

Updated to 0.4.3: Removed string check in basic doc search code. Made the check for embeded key codes more robust from erronious checks.
author Eric M. Ludlam <zappo@gnu.org>
date Sat, 14 Mar 1998 12:59:13 +0000
parents f3f9df46d008
children 86fcccceba7b
comparison
equal deleted inserted replaced
21180:921bd225796e 21181:2b9774c50f91
1 ;;; checkdoc --- Check documentation strings for style requirements 1 ;;; checkdoc --- Check documentation strings for style requirements
2 2
3 ;;; Copyright (C) 1997, 1998 Free Software Foundation 3 ;;; Copyright (C) 1997, 1998 Free Software Foundation
4 ;; 4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> 5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Version: 0.4.2 6 ;; Version: 0.4.3
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
167 ;; `checkdoc-spellcheck-documentation-flag' off by default. 167 ;; `checkdoc-spellcheck-documentation-flag' off by default.
168 ;; 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. 169 ;; 0.4.2 Added some more comments in the commentary.
170 ;; You can now `quote' symbols that look like keystrokes 170 ;; You can now `quote' symbols that look like keystrokes
171 ;; When spell checking, meta variables can end in `th' or `s'. 171 ;; When spell checking, meta variables can end in `th' or `s'.
172 ;; 0.4.3 Fixed bug where multi-function checking skips defuns that
173 ;; have comments before the doc-string.
174 ;; Fixed bug where keystrokes were identified from a variable name
175 ;; like ASSOC-P.
172 176
173 ;;; TO DO: 177 ;;; TO DO:
174 ;; Hook into the byte compiler on a defun/defver level to generate 178 ;; Hook into the byte compiler on a defun/defver level to generate
175 ;; warnings in the byte-compiler's warning/error buffer. 179 ;; warnings in the byte-compiler's warning/error buffer.
176 ;; Better ways to override more typical `eval' functions. Advice 180 ;; Better ways to override more typical `eval' functions. Advice
180 ;; Code sweep checks for "forbidden functions", proper use of hooks, 184 ;; Code sweep checks for "forbidden functions", proper use of hooks,
181 ;; proper keybindings, and other items from the manual that are 185 ;; proper keybindings, and other items from the manual that are
182 ;; not specifically docstring related. Would this even be useful? 186 ;; not specifically docstring related. Would this even be useful?
183 187
184 ;;; Code: 188 ;;; Code:
185 (defvar checkdoc-version "0.4.2" 189 (defvar checkdoc-version "0.4.3"
186 "Release version of checkdoc you are currently running.") 190 "Release version of checkdoc you are currently running.")
187 191
188 ;; From custom web page for compatibility between versions of custom: 192 ;; From custom web page for compatibility between versions of custom:
189 (eval-and-compile 193 (eval-and-compile
190 (condition-case () 194 (condition-case ()
607 (save-excursion 611 (save-excursion
608 ;; If we are taking notes, encompass the whole buffer, otherwise 612 ;; If we are taking notes, encompass the whole buffer, otherwise
609 ;; the user is navigating down through the buffer. 613 ;; the user is navigating down through the buffer.
610 (if take-notes (checkdoc-start-section "checkdoc")) 614 (if take-notes (checkdoc-start-section "checkdoc"))
611 (while (and (not wrong) (checkdoc-next-docstring)) 615 (while (and (not wrong) (checkdoc-next-docstring))
612 (if (not (checkdoc-char= (following-char) ?\")) 616 ;; OK, lets look at the doc-string.
613 ;; No doc-string... 617 (setq msg (checkdoc-this-string-valid))
614 nil 618 (if msg
615 ;; OK, lets look at the doc-string. 619 ;; Oops
616 (setq msg (checkdoc-this-string-valid)) 620 (if take-notes
617 (if msg 621 (progn
618 ;; Oops 622 (checkdoc-error (point) msg)
619 (if take-notes 623 (setq errors t))
620 (progn 624 (setq wrong (point))))))
621 (checkdoc-error (point) msg)
622 (setq errors t))
623 (setq wrong (point)))))))
624 (if wrong 625 (if wrong
625 (progn 626 (progn
626 (goto-char wrong) 627 (goto-char wrong)
627 (error msg))) 628 (error msg)))
628 (if (and take-notes errors) 629 (if (and take-notes errors)
1118 replace original))))) 1119 replace original)))))
1119 ;; * Don't write key sequences directly in documentation strings. 1120 ;; * Don't write key sequences directly in documentation strings.
1120 ;; Instead, use the `\\[...]' construct to stand for them. 1121 ;; Instead, use the `\\[...]' construct to stand for them.
1121 (save-excursion 1122 (save-excursion
1122 (let ((f nil) (m nil) (start (point)) 1123 (let ((f nil) (m nil) (start (point))
1123 (re "[^`]\\([CMA]-[a-zA-Z]\\|\\(\\([CMA]-\\)?\ 1124 (re "[^`A-Za-z0-9_]\\([CMA]-[a-zA-Z]\\|\\(\\([CMA]-\\)?\
1124 mouse-[0-3]\\)\\)\\>")) 1125 mouse-[0-3]\\)\\)\\>"))
1125 ;; Find the first key sequence not in a sample 1126 ;; Find the first key sequence not in a sample
1126 (while (and (not f) (setq m (re-search-forward re e t))) 1127 (while (and (not f) (setq m (re-search-forward re e t)))
1127 (setq f (not (checkdoc-in-sample-code-p start e)))) 1128 (setq f (not (checkdoc-in-sample-code-p start e))))
1128 (if m 1129 (if m