如何在Javadoc内联标签(例如{@code}标签)中转义花括号 [英] How do you escape curly braces in javadoc inline tags, such as the {@code} tag

查看:1105
本文介绍了如何在Javadoc内联标签(例如{@code}标签)中转义花括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/**
 * Gets the meatball icon for a nincompoop.
 * 
 * <p>
 * Example: {@code <custom:meatball color="<%= Meatball.RED %> nincompoop="${person}" />}
 * 
 * @author King Cong
 * 
 */

"$ {person}"部分使用花括号将文档注释打乱.

The "${person}" part breaks the doc comment because it uses curly braces.

推荐答案

答案不算是解决方法,但如果将{@code ...}替换为旧版本<code>...</code>,它将使花括号呈现您的期望./p>

Not so much an answer as a workaround, but if you replace {@code ...} with the old version <code>...</code> it will render curly braces how you expect.

<code>{person} == ${person}</code>

不幸的是,这会破坏尖括号,因此对于原始问题,您需要避免这些问题:

Unfortunately, this breaks angle brackets, so to the original question you need to escape these:

<code>&lt;custom:meatball color="&lt;%= Meatball.RED %&gt; nincompoop="${person}" /&gt;</code>

您甚至可以通过使用便利的TextFX-> convert-> Encode HTML(&<>)来让Notepad ++为您做到这一点来作弊.

You can even cheat here by getting Notepad++ to do that for you, with the handy TextFX -> convert -> Encode HTML (&<>").

这至少具有这样的好处,即所有东西都可以在生成的Javadoc和Eclipse的Javadoc视图中很好地呈现,这似乎无法理解&#125;和朋友.

This does at least have the benefit that everything renders nicely both in the generated Javadoc and in Eclipse in the Javadoc view, which doesn't appear to understand &#125; and friends.

这篇关于如何在Javadoc内联标签(例如{@code}标签)中转义花括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆