From 2de733678c78ee138dc6d38ca27f6104e544166f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Mon, 16 Mar 2026 13:41:36 -0700 Subject: [PATCH] Add a test demonstrating the current broken formatting for markdown javadoc. The most obvious problem is that wrapped lines start with `//` instead of `///`. PiperOrigin-RevId: 884614790 --- .../java/JavadocFormattingTest.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java index 39d43c2f9..d49bd30b0 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java @@ -1488,4 +1488,46 @@ public void missingSummaryFragment() { }; doFormatTest(input, expected); } + + @Test + public void simpleMarkdown() { + String[] input = { + "package com.example;", + "", + "/// # Heading", + "///", + "/// A very long line of text, long enough that it will need to be wrapped to fit within the" + + " maximum line length.", + "class Test {", + " /// Another very long line of text, also long enough that it will need to be wrapped to" + + " fit within the maximum line length.", + " /// @param a generic type", + " T method() {", + " return null;", + " }", + "}", + }; + // TODO(emcmanus): Fix the formatter so it doesn't produce this nonsense: + // - wrapped lines should start with /// not // + // - blank line before @param + String[] expected = { + "package com.example;", + "", + "/// # Heading", + "///", + "/// A very long line of text, long enough that it will need to be wrapped to fit within the" + + " maximum", + "// line length.", + "class Test {", + " /// Another very long line of text, also long enough that it will need to be wrapped to" + + " fit within", + " // the maximum line length.", + " /// @param a generic type", + " T method() {", + " return null;", + " }", + "}", + }; + doFormatTest(input, expected); + } }