I have code where it's common to have many equations in JavaDoc comments. I'm currently using MathML to display these equations, as it's the only way I've been able to get equations that can display in Eclipse's hover tooltips.
I don't actually care about created HTML. I just need Eclipse's hover to display equations correctly.
Unfortunately, MathML is insanely verbose. One line of simple LaTeX becomes 50 lines of MathML! It's cluttering up my source and the JavaDoc comments are unreadable in the source code (you have to hover over the method to read the comment).
Does anyone know a way to use LaTeX equations in Eclipse that will show up in this hover text?
EDIT: Something like this would be preferable, but this doesn't work in Eclipse's hovers. Presumably there's no way to inject JavaScript in those.
Suggestion 1: Use MathJax
I use MathJax to write LaTeX equations in JavaDoc. You may see the result here: http://finmath.net/java/finmath-lib/apidocs/net/finmath/montecarlo/interestrate/LIBORMarketModel.html
However, MathJax relies on JavaScript and the Eclipse Hover does not support JavaScript. But then I must say that the MathJax LaTeX can be read even without renderer, so for me it is OK to have LaTeX code in the hover text. You will see it if you enable JavaScript in the hover text - but that is a different question.
To enable MathJax you just need to include a header in your docket config like
<header>
<![CDATA[
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
]]>
</header>
Suggestion 2: Use CLSI on your local machine
If you need this only for yourself you could run a CLSI (common-latex-service-interface). Then, maybe it is possible to just have an image tag with the latex code in its URL which returns an image). I have not elaborated on this... (personally I would prefer option 1, because it will also generate the LaTeX in the JavaDoc.
You can try LaTeXlet
Take a look at: http://users.informatik.uni-halle.de/~grau/LaTeXlet/
LaTeXlet is a taglet that allows to use LaTeX within Javadoc comments.
Here are an Example:
http://users.informatik.uni-halle.de/~grau/LaTeXlet/doc/latexlet/BlockLaTeXlet.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With