Ahh.. documentation for tags. What a great example of how
semantic abstracts out behaviors.
semantic-documentation-for-tag is a overloaded function created with
`define-overload'. It has a default behavior which either returns the
:documentation attribute, or just grabs any comment preceding the
give tag, and returns the body of that comment.
For any language with a special way of storing the documentation for a
given tag, you can write a new implementation just for that language.
If you want to grab some text from HTML, you could do that. If you
have an Emacs Lisp function you can query Emacs for the doc.
If you would like this feature to work with python you can either
teach the parser to put in :documentation attributes (which can make
TAG files really huge,) or you can write a bit of lisp to find the doc
inside the tag.
See bovine/semantic-el.el for how to override this function to make it
work right for some other language. eg:
emacs-lisp-mode (tag &optional nosnarf)
"Return the documentation string for TAG.
Optional argument NOSNARF is ignored."
(let ((d (semantic-tag-docstring tag)))
(when (not d)
(cond ((semantic-tag-buffer tag)
;; Doc isn't in the tag itself. Lets pull it out of the
(let ((semantic-elisp-store-documentation-in-tag t))
Adding this to python would be a great new feature.
Also, your function is similar to semantic-ia-show-doc. If you end up
with an improvement it would be spiff to replace the short tool I
>>> joakim@... seems to think that:
>I'm having some trouble making (semantic-documentation-for-tag) return
>I have code llike this:
>(defun jv-finddoc-main (point)
> "Display the code-level documentation for the symbol at POINT."
> (interactive "d");"P"
> (with-output-to-temp-buffer "*TAG DOCUMENTATION*"
> (let* ((ctxt (semantic-analyze-current-context point))
> (cursym (semantic-ctxt-current-symbol))
> (thing (semantic-ctxt-current-thing ))
> (pf (reverse (oref ctxt prefix)))
> (tag (car pf))
> (symbol-buffer-mode major-mode)
> ;; If PF, the prefix is non-nil, then the last element is either
> ;; a string (incomplete type), or a semantic TAG. If it is a TAG
> ;; then we should be able to find DOC for it.
> (set-buffer "*TAG DOCUMENTATION*") ;;figure out stuff about the buffer where the symbol lives, before this call
> (cond ((stringp tag)
> (princ "Incomplete symbol name."))
> ((semantic-tag-p tag)
> (let ((doc
> (condition-case err
> (semantic-documentation-for-tag tag) ;; look at tag for docs, or before tag for comments
> ;;feels dodgy, seems it looks at point instead of tag
> ;; maybe not. saves excursion, and jumps to tag
> (error (format "oops semantic-documentation-for-tag crashed %s " err)))
>The provlem is (semantic-documentation-for-tag tag) rarely returns
>anything useful except maybe a comment preceeding the tag.
>If I do M-x (semantic-documentation-for-tag) on a lisp function I
>might get the proper documentation for that function sometimes, but
>not for a python definition like:
> return r
>In the end what I want to achieve is:
>- show snarfed documentation if there is one for symbol at point
>- do language specific documentation lookup for at least python, java
Eric Ludlam: zappo@..., eric@...
Home: http://www.ludlam.net Siege: http://www.siege-engine.com
Emacs: http://cedet.sourceforge.net GNU: http://www.gnu.org