1. xemacs
  2. semantic

Source

semantic / document.el

Diff from to

File document.el

  • Ignore whitespace
 ;;; document.el --- Use the bovinator to aid in generating documentation.
 
-;;; Copyright (C) 2000, 2001 Eric M. Ludlam
+;;; Copyright (C) 2000, 2001, 2002 Eric M. Ludlam
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: doc
 ;; can not insert foriegn tokens.
 
 (require 'sformat)
+;; This contains most variable settings for auto-comment generation.
 (require 'document-vars)
 
 ;;; Code:
   :group 'document
   :type 'string)
 
-(defvar document-comment-start nil
-  "Comment start string.")
-
-(defvar document-comment-line-prefix nil
-  "Comment prefix string.  Used at the beginning of each line.")
-
-(defvar document-comment-end nil
-  "Comment end string.")
-
 (defvar document-runflags nil
   "Flags collected while updating a comment.
 This is used to create a history element.")
 
-;; This contains most variable settings for auto-comment generation.
-(require 'document-vars)
-
 ;;; Status tracking
 ;;
 (defvar document-current-output-file nil
 	(document-insert-function-comment-new nonterm))
       (message "Done..."))
      (t
-      (error "Type %s is not yet managed by document `document-inline'" tt)))))
+      (error "Type %S is not yet managed by document `document-inline'" tt)))))
 
 (defun document-update-comment (nonterm)
   "Update an existing comment for NONTERM."
 	(if p (insert (format (cdr p) (cdr (car document-runflags))))))
       (setq document-runflags (cdr document-runflags)))))
 
+(defun document-argument-name (arg)
+  "Return a string representing the argument ARGs name.
+Arguments can be semantic tokens, or strings."
+  (cond ((semantic-token-p arg)
+	 (semantic-token-name arg))
+	((stringp arg)
+	 arg)
+	(t (format "%s" arg))))
+
 (defun document-update-paramlist (nonterm comment)
   "Update NONTERM's comment found in the flex token COMMENT."
   (let ((endpos 0) st en (il nil)
 	;; are the same.
 	(let ((tl l) (stop nil))
 	  (while (and tl (not stop))
-	    (if (not (assoc (semantic-token-name (car tl)) il))
+	    (if (not (assoc (document-argument-name (car tl)) il))
 		(setq stop t))
 	    (setq tl (cdr tl)))
 	  (if (not stop)
 		(cs1 nil)
 		(num 0))
 	    (while ntl
-	      (if (not (assoc (semantic-token-name (car ntl)) il))
+	      (if (not (assoc (document-argument-name (car ntl)) il))
 		  (progn
 		    (setq num (1+ num))
 		    (setq cs1 (concat cs1 (if cs1 ", ")
-				      (semantic-token-name (car ntl))))))
+				      (document-argument-name (car ntl))))))
 	      (setq ntl (cdr ntl)))
 	    (if cs1
 		(if (= num 1)
       (setq string (document-texify-elisp-docstring string)))
   ;; Else, other languages are simpler.  Also, might as well
   ;; run the elisp version through also.
-  (let ((case-fold-search nil))
+  (let ((case-fold-search nil)
+	(start 0))
     (while (string-match
 	    "\\(^\\|[^{]\\)\\<\\([A-Z0-9_-]+\\)\\>\\($\\|[^}]\\)"
-	    string)
+	    string start)
       (setq string (concat (substring string 0 (match-beginning 2))
 			   "@var{"
 			   (match-string 2 string)
 			   "}"
-			   (substring string (match-end 2)))))
+			   (substring string (match-end 2)))
+	    start (match-end 2)))
     )
   string)