Is there a way to include math formulae in Scaladoc?

后端 未结 4 1046
南方客
南方客 2021-01-01 23:03

I would like to enter math formulae in Scaladoc documentation of mathematical Scala code. In Java, I found a library called LatexTaglet that can do exactly this for Javadoc,

4条回答
  •  清酒与你
    2021-01-02 00:00

    The short answer is: no. LaTeXTaglet is made possible by the JavaDoc Taglet API. There is no equivalent in Scaladoc, therefore no clean solution.

    However, I can think of a hack that might be easy enough to do:

    There's a library called MathJax, which looks for LaTeX-style math formulae in an HTML page and dynamically renders it in place. I've used it before, it's pretty nice; all you have to do is include the script. So you could do two things:

    1. Edit and rebuild the Scaladoc source to include MathJax, or...
    2. Write a little post-processor crawl all of Scaladoc's HTML output after it runs, and inject MathJax into each file.

    That way, you could just write LaTeX formulae directly in your Scala comments and they should be rendered in the browser. Of course if you wanted a non-hacky solution, I'd suggest you create a taglet-like API for Scaladoc ;)

提交回复
热议问题