Eclipse:如何让代码格式化程序在 javadoc 标签后插入制表符

发布于 2024-12-18 23:35:55 字数 509 浏览 2 评论 0原文

我想要:

    /**
 * @param from  a point belonging to the map
 * @param to    a point belonging to the map
 * @return      a list of weighted edges on the shortest path from
 *                  {@code from} to {@code to}
 */

但是日食给了我:

/**
 * @param from a point belonging to the map
 * @param to a point belonging to the map
 * @return a list of weighted edges on the shortest path from {@code from}
 *         to {@code to}
 */

有没有办法改变这个?

I'd like to have:

    /**
 * @param from  a point belonging to the map
 * @param to    a point belonging to the map
 * @return      a list of weighted edges on the shortest path from
 *                  {@code from} to {@code to}
 */

But eclipse gives me:

/**
 * @param from a point belonging to the map
 * @param to a point belonging to the map
 * @return a list of weighted edges on the shortest path from {@code from}
 *         to {@code to}
 */

Is there a way to change this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不必在意 2024-12-25 23:35:55

添加

   
    /**
    * @param from
    *            a point belonging to the map
    * @param to
    *            a point belonging to the map
    * @return a list of weighted edges on the shortest path from<br>
    *         {@code from} to {@code to}
    */

Eclipse 将为每个
包含一个换行符。此外,当您使用 Eclipse 生成 JavaDocs 时,它还包含强制换行符。

具有固定格式的另一种方法是

 标签。

/**
* Some Comments
* 
* <pre>
* Hello
* World
* </pre>
* 
* @param toTest
* @return ...
*/

 的一个问题是在开始 
 之前强制换行收盘后

标签,这意味着它不能与@return,@param,...一起使用

注意:


仅可与 JavaDoc-Comments /** 一起使用。在普通的块注释 /* 中,这两个被 eclipse 忽略。

Add <br>

   
    /**
    * @param from
    *            a point belonging to the map
    * @param to
    *            a point belonging to the map
    * @return a list of weighted edges on the shortest path from<br>
    *         {@code from} to {@code to}
    */

Eclipse will include a line-break for each <br>. In Addition, when you generate your JavaDocs with Eclipse it also includes a forced line-break.

Another way to have a fix format is the <pre> </pre> tag.

/**
* Some Comments
* 
* <pre>
* Hello
* World
* </pre>
* 
* @param toTest
* @return ...
*/

One Problem with <pre> is that you have a forced line-break before the opening <pre> and after the closing </pre> tag, wich means it cannot be used with @return, @param,...

Note: <pre> and <br> are only usable with JavaDoc-Comments /**. In a normal block-comment /* these two are ignored by eclipse.

遗弃M 2024-12-25 23:35:55

当然,在 Eclipse 中,转到 Windows、首选项、Java>Code Style>Formatter,然后单击编辑。然后查找您要修改的注释并添加选项卡。

也就是说,您确定要这样做吗?请考虑指南,更不用说现在或将来,某些解析器可能无法找到您的 javadoc,并且某些程序员可能会对您感到非常恼火;)

编辑:哦:/恐怕您是对的;我正在考虑 Java>CodeStyle>CodeTemplates,它会在创建方法/类时放置您想要的任何内容。然而,自动格式化程序不会遵守这一点:(

Sure, in eclipse, go to Windows, preferences, Java>Code Style>Formatter, and click on edit. Then look for the comments you want to modify and add a tab.

That said, are you sure you want to do this? Please consider the guidelines, not to mention that now or in the future, some parsers might fail to find your javadoc, and some programmers might be very annoyed with you ;)

Edit: Oh :/ I'm afraid you're right; I was thinking of Java>CodeStyle>CodeTemplates, which will put whatever you want when a method/class is created. This, however, will not be respected by the autoformatter :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文