简体   繁体   English

Maven JavaDoc Plugin 输出不正确的参数 alignment

[英]Maven JavaDoc Plugin outputs incorrect parameter alignment

We're using the Maven JavaDoc Plugin to generate javadocs for our projects.我们正在使用 Maven JavaDoc 插件为我们的项目生成 javadocs。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.2.0</version>
    <executions>
        <execution>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

When generating the JavaDoc for some methods, the alignment is completely off.在为某些方法生成 JavaDoc 时,alignment 完全关闭。 For example this例如这个

@GetMapping(value = "/api/manyToOnes/{tablePlural}/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, String> getManyToOnes(@PathVariable String tablePlural, @PathVariable Integer id)

produces this (spaces preserved, please don't edit them out):产生这个(保留空间,请不要编辑它们):

@GetMapping(value="/api/manyToOnes/{tablePlural}/{id}",
            produces="application/json")
public Map<String,String> getManyToOnes(@PathVariable
                                                                                                                                         String tablePlural,
                                                                                                                                         @PathVariable
                                                                                                                                         Integer id)

As you can see, it's just really annoying to read and I would prefer if it lined up, or at least if there wasn't a huge gap in the middle.正如你所看到的,阅读起来真的很烦人,我更喜欢它排成一行,或者至少如果中间没有很大的差距。

I can't work out exactly what it's struggling with, but it seems to be related to the annotations.我无法弄清楚它到底在挣扎什么,但它似乎与注释有关。 Other methods which do not use annotations are fine.其他不使用注释的方法很好。

I checked the config to see if there was anything related to alignment but I didn't see anything.我检查了配置以查看是否有任何与 alignment 相关的内容,但我没有看到任何内容。

I am already using the latest version, would downgrading to a previous version help?我已经在使用最新版本,降级到以前的版本有帮助吗? I'm reluctant to manually iterate through them, especially when there's no guarantee it ever worked.我不愿意手动遍历它们,尤其是当不能保证它曾经有效时。

I checked the issue tracker , there doesn't seem to be anything matching what I'm seeing.我检查了问题跟踪器,似乎没有任何与我所看到的相匹配的东西。 If no one can help here then I'll raise a bug there.如果没有人可以在这里提供帮助,那么我会在那里提出一个错误。 I don't recall seeing this in any other project's JavaDocs, so I'm inclined to think it's my problem rather than theirs.我不记得在任何其他项目的 JavaDocs 中看到过这一点,所以我倾向于认为这是我的问题,而不是他们的问题。

Upon investigating this, I learned that it is not the plugin which generates the HTML at all, but rather it delegates this to a tool provided by the JDK, jdk/bin/javadoc.exe经过调查,我了解到它根本不是生成 HTML 的插件,而是将其委托给 JDK 提供的工具jdk/bin/javadoc.exe

After learning this, I tried building with JDK 9 rather than 8 and the output was much better.在了解了这一点后,我尝试使用 JDK 9 而不是 8 进行构建,并且 output 更好。

@GetMapping(value="/api/manyToOnes/{tablePlural}/{id}",
            produces="application/json")
public Map<String,String> getManyToOnes​(@PathVariable
                                        String tablePlural,
                                        @PathVariable
                                        Integer id)

I looked at Oracle's bug tracker for fixVersion = 9 which led me to the bug: JDK-8062647我查看了Oracle 的 bug tracker for fixVersion = 9这导致了我的 bug: JDK-8062647

FWIW I learned that the output is different from both of these in Java 12, so it seems it's going through changes quite often. FWIW 我了解到 output 与 Java 12 中的这两个不同,所以它似乎经常经历变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM