有没有办法在 Scaladoc 中包含数学公式? [英] Is there a way to include math formulae in Scaladoc?
问题描述
我想在数学 Scala 代码的 Scaladoc 文档中输入数学公式.在 Java 中,我发现了一个名为 LatexTaglet 的库,它可以通过在 Latex 中编写公式来为 Javadoc 做到这一点:http://latextaglet.sourceforge.net/
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, by writing formulae in Latex: http://latextaglet.sourceforge.net/
它似乎与 Maven 很好地集成(POM 的报告/插件部分).Scaladoc 是否有等效的库?如果没有,我如何将此库与 SBT 集成?
And it seems to integrate well with Maven (reporting/plugins section of a POM). Is there an equivalent library for Scaladoc? If not, how could I integrate this library with SBT?
我也考虑过使用 MathML (http://www.w3.org/Math/),但看起来太冗长了.有没有推荐的编辑器?MathML 是否与 Scaladoc 很好地集成?
I also considered using MathML (http://www.w3.org/Math/), but looks too verbose. Is there an editor you would recommend? Does MathML integrate well with Scaladoc?
感谢您的帮助!
推荐答案
简短的回答是:不.LaTeXTaglet 是由 JavaDoc Taglet API.Scaladoc 中没有等价物,因此没有干净的解决方案.
The short answer is: no. LaTeXTaglet is made possible by the JavaDoc Taglet API. There is no equivalent in Scaladoc, therefore no clean solution.
但是,我可以想到一个可能很容易做到的 hack:
However, I can think of a hack that might be easy enough to do:
有一个名为 MathJax 的库,它在 HTML 页面中查找 LaTeX 风格的数学公式并动态呈现它到位.以前用过,挺好看的;您所要做的就是包含脚本.所以你可以做两件事:
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:
- 编辑并重建 Scaladoc 源代码以包含 MathJax,或者...
- 编写一个小后处理器在运行后抓取 Scaladoc 的所有 HTML 输出,并将 MathJax 注入每个文件.
- Edit and rebuild the Scaladoc source to include MathJax, or...
- Write a little post-processor crawl all of Scaladoc's HTML output after it runs, and inject MathJax into each file.
这样,您可以直接在 Scala 注释中编写 LaTeX 公式,它们应该在浏览器中呈现.当然,如果你想要一个 non-hacky 解决方案,我建议你为 Scaladoc 创建一个类似于 taglet 的 API ;)
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 ;)
这篇关于有没有办法在 Scaladoc 中包含数学公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!