sponsor Vim development Vim logo Vim Book Ad

javaDoc.vim : Look up javadoc Help file from Vim [Unix Only]

 script karma  Rating 7/3, Downloaded by 1226  Comments, bugs, improvements  Vim wiki

created by
vim power
 
script type
utility
 
description
Hi All,
This script looks up javaDoc HTML help files for J2SE and J2EE api classes.
First of all I am not sure if there is already a utility to do this or not, so here is my version.

About the script.
First the script runs only on Unix boxes, Windows users are more that welcome to port it .
Make sure that the following unix commands are present in directories mentioned in your $PATH variable.
dirname,grep,xlswin,awk
It also uses a shell script provided along with this package.
It is heavily commented and can be easily modified.

What it does and what it doesn't
It opens javaDoc HTML file in an external browser from VIM.
It can open the HTML in either Netscape (Netscape 4.x, 6,7.x, Mozilla , Firebird ) or
a text browser such as lynx or links. Personally I prefer to open help in netscape when I am using gvim and in a text browser when I am using vim.
Currently It only supports looking up classes and not methods , or members.

How it works.
It opens javaDoc HTML file in an external browser from VIM.
It can open the HTML in either Netscape (Netscape 4.x, 6,7.x, Mozilla , Firebird ) or
a text browser such as lynx or links.
Personally I prefer to open help in netscape when I am using gvim
and in a text browser when I am using vim.
Currently It only supports looking up classes and not methods , or members.

How it works.
You have two ways to lookup help
1)
To use the mapping <Leader>jh, the cursor has to be placed on the class name
whose help file is to be looked up. i.e.
if your source is "Connection conn = null;"
The cursor will have to be on the word Connection.
The script can't do a reverse mapping of variable name to class name and look-up help. i.e.
you can't use the variable conn to look up help for connection.

2)Use the :Javadoc command and supply the Class name as an argument.
i.e. :Javadoc Connection
 
install details
Extract the provided .tar.gz file .
Put the javadoc.vim in your plugin directory of $VIMRUNTIME or ~/.vim.
Put the javadoc.txt in your doc directory of $VIMRUNTIME or ~/.vim.
Run
:helptags ~/.vim/doc or :helptags $VIMRUNTIME/doc
Place the included shell script in a convenient location .
Make sure to give execute permissions to the shell script.

Settings                            *javadoc-settings*
Now for stuff in your .vimrc file.
The script uses a trick to support several javaDoc locations,
e.g. J2SE, J2EE, and any generated javadoc of your Code also.
First define a global variable g_no_of_ID_Files to
number of unique locations of your javaDocs.
e.g. If you have J2SE and J2EE Api javadocs i.e. 2 javadocs,

let g:no_of_ID_Files=2

The define the actual locations of these API's
The file I use to look-up class name is "allclasses-frame.html",
So specify locations to the allclasses-frame.html for each javadoc.
If you have javaDoc of thirdparty APIs or you own Code, make sure that the allclasses-frames.html is present in it.

e.g.
let g:javadoc_ID_File_1="/user/abcd/docs/javadoc/JDK/java/api/allclasses-frame.html"
let g:javadoc_ID_File_2="/user/abcd/docs/javadoc//J2EE/java/api/allclasses-frame.html"

Note the first variable g:no_of_ID_Files determines how many g:_javadoc_ID_File_<cnt> should be defined.

Next specify the location of the included shell script
let g:srchJdoc_loc="/user/abcd/softwares/usr/bin/srchJdoc.sh"

Next specify the commands for a GUI browser and a text browser,
Note:- I use Netscape as my GUI browser and links as my text browser and
the executables for both are in my $PATH. You may want to specify the full-path
depending on your situation.

let g:javadoc_netscape_cmd="netscape"
let g:javadoc_textbrowser_cmd="links"

By default the Helpfile is opended using the text browser defined in g:javadoc_textbrowser_cmd.
If you want to open it using the GUI browser add the following too.

let g:jhelp_use_gui_browser=1

Note:-Usually I prefer text browser, when I am using VIM from a terminal and GUI browser
when I am using GVIM in X. For that you can put the above line in ~/.gvimrc. This way
everytime u use vim, a text browser will be used and whenever you use gvim, GUI browser will be used.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
javadoc.tar.gz v2 2003-10-28 6.0 vim power This is the second release. This contains lots of changes.
Made compatible as per the write-plugin document, provided help file.
Note:- The name of the plugin has been changed from javaDoc.vim to all lowercase
javadoc.vim, So be sure to remove the earlier version.
javaDoc.tar.gz 1 2003-10-22 6.0 vim power Initial upload
ip used for rating: 3.141.24.134

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github