GJF adds <p> tag prior to the <div> tag
还没有人认领这个 Issue。
评估
调研方向
报告中没有指定源文件或测试。使用提供的 Test.java 示例和 google-java-format 1.24.0 命令复现该行为,然后跟踪面向块级标签的 Javadoc 格式化入口。完成标准是:格式化不再在
前添加,并保留对
- 和结束
- 标签的预期处理。
由索引模型根据 Issue 内容生成。
描述
Detected at: https://github.com/checkstyle/checkstyle/issues/15865, User's got his answer at: https://github.com/checkstyle/checkstyle/issues/15865#issuecomment-2462352189
GJF adds <p> prior to <div> tag, but the style guide says that block-level tags should not be preceded by <p> tag:
https://google.github.io/styleguide/javaguide.html#s7.1.2-javadoc-paragraphs
HTML tags for other block-level elements, such as <ul> or <table>, are not preceded with <p>.
Here's an example of it:
01: /**
02: * Plugin to standardize all directions to their appropriate abbreviation.
03: *
04: * <div>Some javadoc here....</div>
05: *
06: * <ul>
07: * <li>Item - 1 </li>
08: * <li>Item - 2 </li>
09: * <li>Item - 3 </li>
10: * </ul>
11: *
12: * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13: */
14: public class Test {
15: /** Some javadoc. */
16: public static void main(String[] args) {
17:
18: }
19: }
20:
$ java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml .\Test.java
Starting audit...
Audit done.
$ java -jar .\google-java-format-1.24.0-all-deps.jar .\Test.java > TestUpdated.java
01: /**
02: * Plugin to standardize all directions to their appropriate abbreviation.
03: *
04: * <p><div>Some javadoc here....</div>
05: *
06: * <ul>
07: * <li>Item - 1
08: * <li>Item - 2
09: * <li>Item - 3
10: * </ul>
11: *
12: * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13: */
14: public class Test {
15: /** Some javadoc. */
16: public static void main(String[] args) {}
17: }
18:
java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml .\TestUpdated.java
Starting audit...
[WARN] C:\checkstyle testing\.\TestUpdated.java:4:4: <p> tag should not precede HTML block-tag '<div>', <p> tag should be removed. [JavadocParagraph]
[WARN] C:\checkstyle testing\.\TestUpdated.java:14:1: The name of the outer type and the file do not match. [OuterTypeFilename]
Audit done.
Ignore the OuterTypeFilename violation.
The formatter added <p> tag preceding to <div> tag, Checkstyle was complaining about it. But this did not happened in case of <ul> tag, formatter didn't added preceding <p> tag to it.
Edit: After formatting, GJF also removes closing li tags ( </li> )
- 主要语言
- Java
- 星标
- 6.2k
- 派生
- 936
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/google-java-format 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
google/google-java-format#1094 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 15/100
google/google-java-format#1450 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 55/100
google/google-java-format#1439 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 62/100
google/google-java-format#1436 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 48/100
google/google-java-format#1428 · 3 条评论 ·
查看 google/google-java-format 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
elastic/gradle-plugins#157 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
cryptomator/hub#497 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
johanhaleby/occurrent#1120 ·