Function: semantic-doc-snarf-comment-for-tag

semantic-doc-snarf-comment-for-tag is a byte-compiled function defined in doc.el.gz.

Signature

(semantic-doc-snarf-comment-for-tag NOSNARF)

Documentation

Snarf up the comment at POINT for semantic-documentation-for-tag.

Attempt to strip out comment syntactic sugar. Argument NOSNARF means don't modify the found text. If NOSNARF is lex, then return the lex token.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/doc.el.gz
(defun semantic-doc-snarf-comment-for-tag (nosnarf)
  "Snarf up the comment at POINT for `semantic-documentation-for-tag'.
Attempt to strip out comment syntactic sugar.
Argument NOSNARF means don't modify the found text.
If NOSNARF is `lex', then return the lex token."
  (let* ((semantic-lex-analyzer #'semantic-comment-lexer))
    (if (memq nosnarf '(lex flex)) ;; keep `flex' for compatibility
	(car (semantic-lex (point) (1+ (point))))
      (let ((ct (semantic-lex-token-text
		 (car (semantic-lex (point) (1+ (point)))))))
	(if nosnarf
	    nil
	  ;; ok, try to clean the text up.
	  ;; Comment start thingy
	  (while (string-match (concat "^\\s-*\\(?:" comment-start-skip "\\)")
                               ct)
	    (setq ct (concat (substring ct 0 (match-beginning 0))
			     (substring ct (match-end 0)))))
	  ;; Arbitrary punctuation at the beginning of each line.
	  (while (string-match "^\\s-*\\s.+\\s-*" ct)
	    (setq ct (concat (substring ct 0 (match-beginning 0))
			     (substring ct (match-end 0)))))
	  ;; End of a block comment.
	  (if (and (boundp 'block-comment-end)
		   block-comment-end
		   (string-match block-comment-end ct))
	      (setq ct (concat (substring ct 0 (match-beginning 0))
			       (substring ct (match-end 0)))))
	  ;; In case it's a real string, STRIPIT.
	  (while (string-match "\\s-*\\s\"+\\s-*" ct)
	    (setq ct (concat (substring ct 0 (match-beginning 0))
			     (substring ct (match-end 0)))))
	  ;; Remove comment delimiter at the end of the string.
	  (when (and comment-end (not (string= comment-end ""))
		     (string-match (concat (regexp-quote comment-end) "$") ct))
	    (setq ct (substring ct 0 (match-beginning 0)))))
	;; Now return the text.
	ct))))