Fixing "Open help" in the Script Editor: find documentation and source code for java classes

Hi all,
I’ve just pushed a pull request to the Script Editor repository, adding a new menu item named “Tools - Source or javadoc for class or package…”.
For some years, the “Open help” menu item was broken, ever since the mavenization of Fiji. Recently, @ctrueden kindly provided a fix, but it has the limitation of requiring a fully qualified class name. That is, instead of e.g. ImagePlus or UnsignedByteType, it would only open the javadoc in the web browser if ij.ImagePlus or net.imglib2.type.numeric.integer.UnsignedByteType was selected.
This limitation is severe, because in a script one only infrequently if ever encounters the fully qualified class name (class name with the package prefix), and typing it in, if known at all, can be cumbersome, as the second example above illustrates.
So the new menu item lets you select any part of a fully qualified class name and get a list of options in a GUI that opens, with buttons for the source code in github and for the javadoc as well.
Under the hood, it searches into the actual jar files of Fiji and parses its pom.xml files to find the appropriate information, mainly URLs.
The beauty of it is that you can e.g. select parts of a class name and get a list of matching class names. And that includes the package: select parts of a package name and you’ll get the full list of classes whose fully qualified class name contain that substring.
The code is, in some ways, fragile, as it depends on the pom.xml files and their content, and also on the continued existence of https://javadoc.scijava.org. At the same time, if these resources were to change, we’ll adapt the code. And as much as possible I’ve built checks and fallbacks to be able to get a working link to some info on the class.
Have a look at the pull request: https://github.com/scijava/script-editor/pull/46

Would appreciate comments @imagejan @haesleinhuepf @ctrueden

1 Like

The thought of course occurred to me that the ability to pattern-match class names on partial text could be used towards class-name expansion in all scripting languages.