Class JavadocFormatter
- java.lang.Object
-
- com.google.googlejavaformat.java.javadoc.JavadocFormatter
-
public final class JavadocFormatter extends java.lang.ObjectEntry point for formatting Javadoc.This stateless class reads tokens from the stateful lexer and translates them to "requests" and "writes" to the stateful writer. It also munges tokens into "standardized" forms. Finally, it performs postprocessing to convert the written Javadoc to a one-liner if possible or to leave a single blank line if it's empty.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intMAX_LINE_LENGTHprivate static java.util.regex.PatternONE_CONTENT_LINE_PATTERNprivate static java.util.regex.PatternSIMPLE_TAG_PATTERNprivate static TokenSTANDARD_BR_TOKENprivate static TokenSTANDARD_P_TOKEN
-
Constructor Summary
Constructors Modifier Constructor Description privateJavadocFormatter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringformatJavadoc(java.lang.String input, int blockIndent)Formats the given Javadoc comment, which must start with ∕✱✱ and end with ✱∕.private static java.lang.StringmakeSingleLineIfPossible(int blockIndent, java.lang.String input)Returns the given string or a one-line version of it (e.g., "∕✱✱ Tests for foos.private static booleanoneLineJavadoc(java.lang.String line, int blockIndent)private static java.lang.Stringrender(java.util.List<Token> input, int blockIndent)private static Tokenstandardize(Token token, Token standardToken)private static TokenstandardizeBrToken(Token token)private static TokenstandardizePToken(Token token)
-
-
-
Field Detail
-
MAX_LINE_LENGTH
static final int MAX_LINE_LENGTH
- See Also:
- Constant Field Values
-
STANDARD_BR_TOKEN
private static final Token STANDARD_BR_TOKEN
-
STANDARD_P_TOKEN
private static final Token STANDARD_P_TOKEN
-
SIMPLE_TAG_PATTERN
private static final java.util.regex.Pattern SIMPLE_TAG_PATTERN
-
ONE_CONTENT_LINE_PATTERN
private static final java.util.regex.Pattern ONE_CONTENT_LINE_PATTERN
-
-
Method Detail
-
formatJavadoc
public static java.lang.String formatJavadoc(java.lang.String input, int blockIndent)Formats the given Javadoc comment, which must start with ∕✱✱ and end with ✱∕. The output will start and end with the same characters.
-
render
private static java.lang.String render(java.util.List<Token> input, int blockIndent)
-
makeSingleLineIfPossible
private static java.lang.String makeSingleLineIfPossible(int blockIndent, java.lang.String input)Returns the given string or a one-line version of it (e.g., "∕✱✱ Tests for foos. ✱∕") if it fits on one line.
-
oneLineJavadoc
private static boolean oneLineJavadoc(java.lang.String line, int blockIndent)
-
-