intellij-idea - IntelliJ : wrap javadoc text but not markup

标签 intellij-idea formatting

我正在尝试格式化以下 Javadoc,但我不知道如何。

示例输入:

/**
 * Headline.
 * <p>
 * Lorem ipsum dolor sit amet,
 * consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
 * <p>
 * A list:
 * <ul>
 * <li>The description above should be wrapped at the right margin, and broken lines should be joined.</li>
 * <li>A line starting or ending in a tag should not be joined.</li>
 * </ul>
 *
 * @author Mark Jeronimus
 */

当我按下“格式”时,我想看到这个:

/**
 * Headline.
 * <p>
 * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
 * ut labore et dolore magna aliqua.
 * <p>
 * A list:
 * <ul>
 * <li>The description above should be wrapped at the right margin, and broken lines should
 * be joined.</li>
 * <li>A line starting or ending in a tag should not be joined.</li>
 * </ul>
 *
 * @author Mark Jeronimus
 */

Eclipse 和 NetBeans 很容易做到这一点。 IntelliJ,如果我将它配置为换行(我需要)它还会加入标签,除了 <p> . (设置 -> 编辑器 -> 代码样式 -> Java -> JavaDoc -> 其他 -> 在右边距处换行)。它看起来像这样:

/**
 * Headline.
 * <p>
 * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
 * ut labore et dolore magna aliqua.
 * <p>
 * A list: <ul> <li>The description above should be wrapped at the right margin, and broken
 * lines should be joined.</li> <li>A line starting or ending in a tag should not be joined.
 * </li> </ul>
 *
 * @author Mark Jeronimus
 */

我尝试更改其他设置,希望其中一些相互干扰,但无济于事。

我不想要的是使用 Eclipse Formatter 插件。我觉得 IntelliJ 本身应该能够处理这种基本行为,或者任何人应该如何以正常方式格式化他们的 Javadoc?

最佳答案

  1. 打开首选项
  2. 选择编辑器> 代码样式> Java
  3. 打开 JavaDoc 选项卡
  4. 设置以下选项

    Blank lines
     ✓ After description This is a javadoc standard, other blank lines are optional
    Other
     ✓ Wrap at right margin
     ✓ Enable leading asterisks
     ✓ Generate "<p>" on empty lines
     ✓ Keep empty lines
     ✗ Preserve line feeds

  5. 点击确定

  6. 然后只需使用代码> 重新格式化代码

当然,您可以根据自己的...偏好调整偏好。此设置将重新对齐文本以适合页边距,但您必须在格式化之前将

    标签放在新行上。

关于intellij-idea - IntelliJ : wrap javadoc text but not markup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36268493/

相关文章:

intellij-idea - IntelliJ IDEA 中的这个错误是什么?

intellij-idea - Intellij 意外引用行为

javascript - 数字格式化函数 : What algorithm is used for rounding values ending in 5?

python-3.x - Python打印具有给定位数的 float

java - java中main调用其他方法

java - 如何将@Deprecated 添加到每个类和每个类的每个构造函数/方法?

intellij-idea - Gradle IDEA配置

java - 如何为导入语句创建自定义 IntelliJ 警告/错误?

date - os.time() Lua 生成的错误处理表

c# - ToString ("N2") 和 ToString ("0.00") 之间的区别