Class AllCheckSummaries
java.lang.Object
org.apache.maven.doxia.macro.AbstractMacro
com.puppycrawl.tools.checkstyle.site.AllCheckSummaries
- All Implemented Interfaces:
org.apache.maven.doxia.logging.LogEnabled,org.apache.maven.doxia.macro.Macro
@Component(role=org.apache.maven.doxia.macro.Macro.class,
hint="allCheckSummaries")
public class AllCheckSummaries
extends org.apache.maven.doxia.macro.AbstractMacro
Macro to generate table rows for all Checkstyle modules.
Includes every Check.java file that has a Javadoc.
Uses href path structure based on src/site/xdoc/checks.
Usage:
<macro name="allCheckSummaries"/>
Supports optional "package" parameter to filter checks by package. When package parameter is provided, only checks from that package are included. Usage:
<macro name="allCheckSummaries"> <param name="package" value="annotation"/> </macro>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classData holder for each Check module entry. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternMatches '&' characters that are not part of a valid HTML entity.private static final StringHTML anchor separator.private static final StringPackage name for annotation checks.static final intInitial capacity for StringBuilder in wrapSummary method.private static final StringPath component for checks directory.private static final StringClosing anchor tag.private static final PatternPattern to match trailing spaces before closing code tags.private static final StringHTML div closing tag.private static final StringHTML div wrapper opening tag.private static final StringRegex replacement for first capture group.private static final PatternPattern to match href attributes in anchor tags.private static final StringHTML file extension.private static final intIndentation width for INDENT_LEVEL_14 (14 spaces).private static final PathRoot path for Java check files.private static final intMaximum content width excluding indentation.private static final intMaximum line width for complete line including indentation.private static final StringPackage name for miscellaneous checks.private static final StringHTML section closing tag.private static final PathRoot path for site check XML files.private static final PatternMatches one or more whitespace characters.private static final StringPath component for source directory.private static final StringHTML table closing tag.private static final StringHTML table opening tag.private static final PatternMatches common HTML tags such as paragraph, div, span, strong, and em.private static final StringTD closing tag.private static final StringTD opening tag.private static final StringWhitespace regex pattern string.private static final StringXML file extension.Fields inherited from interface org.apache.maven.doxia.macro.Macro
EOL, ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddXmlHtmlMapping(Path path, Map<String, String> map) Adds XML-to-HTML mapping entry to map.private static voidappendFilteredHolderSection(org.apache.maven.doxia.sink.Sink sink, StringBuilder holderRows, String packageName) Appends the filtered Holder Checks section for package views.private static voidappendHolderSection(org.apache.maven.doxia.sink.Sink sink, StringBuilder holderRows) Appends the Holder Checks HTML section.private static StringBuilds a single table row for a check module.private static voidbuildTableRows(Map<String, AllCheckSummaries.CheckInfo> infos, StringBuilder normalRows, StringBuilder holderRows) Builds HTML rows for both normal and holder check modules.Builds map of XML file names to HTML documentation paths.private static intcalculateBreakPoint(String clean, int cleanIndex, int idealBreak) Calculates the appropriate break point for text wrapping.private static String[]determineModuleInfo(Path path, String moduleName) Determines the simple name and package name for a check module.voidexecute(org.apache.maven.doxia.sink.Sink sink, org.apache.maven.doxia.macro.MacroRequest request) private static StringextractCategoryFromJavaPath(Path javaPath) Extracts category path from a Java file path.private static StringextractFirstSentence(String text) Extracts first sentence from plain text.private static intfindSafeBreakPoint(String text, int start, int idealBreak) Finds a safe break point at a space character.private static StringgetDescriptionIfPresent(DetailNode javadoc) Returns the module description if present and non-empty.private static StringgetPackageDisplayName(String packageName) Get display name for package (capitalize first letter).private static booleanisCheckOrHolderFile(Path path) Checks if a path is a Check or Holder Java file.private static booleanChecks if a module is a holder type.private static booleanisValidXmlFile(Path path) Checks if a path is a valid XML file for processing.private static voidprocessCheckFile(Path path, Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, String> xmlHrefMap, String packageFilter) Processes a single check class file and extracts metadata.private static voidprocessCheckFiles(Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, String> xmlHrefMap, String packageFilter) Scans Java sources and populates info map with modules having Javadoc.private static voidremoveLeadingNewline(StringBuilder builder) Removes leading newline characters from a StringBuilder.private static StringResolves the href for a given check module.private static StringsanitizeAnchorUrls(String html) Sanitizes URLs within anchor tags by removing whitespace from href attributes.private static StringSanitizes HTML and extracts first sentence.private static booleanshouldBreakAfterAnchorContent(int anchorStart, int anchorOpenEnd, int idealBreak, String clean) Determines if break should occur after anchor content.private static booleanshouldBreakAfterAnchorOpen(int anchorStart, int anchorOpenEnd, int idealBreak) Determines if break should occur after anchor opening tag.private static StringwrapSummary(String text) Wraps long summaries to avoid exceeding line width.Methods inherited from class org.apache.maven.doxia.macro.AbstractMacro
enableLogging, getAttributesFromMap, getLog, required
-
Field Details
-
CAPACITY
Initial capacity for StringBuilder in wrapSummary method.- See Also:
-
TAG_PATTERN
Matches common HTML tags such as paragraph, div, span, strong, and em. Used to remove formatting tags from the Javadoc HTML content. Note: anchor tags are preserved. -
WHITESPACE_REGEX
Whitespace regex pattern string.- See Also:
-
SPACE_PATTERN
Matches one or more whitespace characters. Used to normalize spacing in sanitized text. -
AMP_PATTERN
Matches '&' characters that are not part of a valid HTML entity. -
HREF_PATTERN
Pattern to match href attributes in anchor tags. Captures the URL within the href attribute, including any newlines. DOTALL flag allows . to match newlines, making the pattern work across line breaks. -
SRC
Path component for source directory.- See Also:
-
CHECKS
Path component for checks directory.- See Also:
-
JAVA_CHECKS_ROOT
Root path for Java check files. -
SITE_CHECKS_ROOT
Root path for site check XML files. -
XML_EXTENSION
XML file extension.- See Also:
-
HTML_EXTENSION
HTML file extension.- See Also:
-
TD_TAG
TD opening tag.- See Also:
-
TD_CLOSE_TAG
TD closing tag.- See Also:
-
MISC_PACKAGE
Package name for miscellaneous checks.- See Also:
-
ANNOTATION_PACKAGE
Package name for annotation checks.- See Also:
-
TABLE_CLOSE_TAG
HTML table closing tag.- See Also:
-
DIV_CLOSE_TAG
HTML div closing tag.- See Also:
-
SECTION_CLOSE_TAG
HTML section closing tag.- See Also:
-
DIV_WRAPPER_TAG
HTML div wrapper opening tag.- See Also:
-
TABLE_OPEN_TAG
HTML table opening tag.- See Also:
-
ANCHOR_SEPARATOR
HTML anchor separator.- See Also:
-
FIRST_CAPTURE_GROUP
Regex replacement for first capture group.- See Also:
-
MAX_LINE_WIDTH_TOTAL
Maximum line width for complete line including indentation.- See Also:
-
INDENT_WIDTH
Indentation width for INDENT_LEVEL_14 (14 spaces).- See Also:
-
MAX_CONTENT_WIDTH
Maximum content width excluding indentation.- See Also:
-
CLOSING_ANCHOR_TAG
Closing anchor tag.- See Also:
-
CODE_SPACE_PATTERN
Pattern to match trailing spaces before closing code tags.
-
-
Constructor Details
-
AllCheckSummaries
public AllCheckSummaries()
-
-
Method Details
-
execute
public void execute(org.apache.maven.doxia.sink.Sink sink, org.apache.maven.doxia.macro.MacroRequest request) throws org.apache.maven.doxia.macro.MacroExecutionException - Throws:
org.apache.maven.doxia.macro.MacroExecutionException
-
processCheckFiles
private static void processCheckFiles(Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, throws org.apache.maven.doxia.macro.MacroExecutionExceptionString> xmlHrefMap, String packageFilter) Scans Java sources and populates info map with modules having Javadoc.- Parameters:
infos- map of collected module infoxmlHrefMap- map of XML-to-HTML hrefspackageFilter- optional package to filter by, null for all- Throws:
org.apache.maven.doxia.macro.MacroExecutionException- if file walk fails
-
isCheckOrHolderFile
Checks if a path is a Check or Holder Java file.- Parameters:
path- the path to check- Returns:
- true if the path is a Check or Holder file, false otherwise
-
isHolder
Checks if a module is a holder type.- Parameters:
moduleName- the module name- Returns:
- true if the module is a holder, false otherwise
-
processCheckFile
private static void processCheckFile(Path path, Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, String> xmlHrefMap, String packageFilter) Processes a single check class file and extracts metadata.- Parameters:
path- the check class fileinfos- map of resultsxmlHrefMap- map of XML hrefspackageFilter- optional package to filter by, null for all- Throws:
IllegalArgumentException- if macro execution fails
-
determineModuleInfo
Determines the simple name and package name for a check module.- Parameters:
path- the check class filemoduleName- the full module name- Returns:
- array with [simpleName, packageName]
-
getDescriptionIfPresent
Returns the module description if present and non-empty.- Parameters:
javadoc- the parsed Javadoc node- Returns:
- the description text, or
nullif not present
-
buildTableRows
private static void buildTableRows(Map<String, AllCheckSummaries.CheckInfo> infos, StringBuilder normalRows, StringBuilder holderRows) Builds HTML rows for both normal and holder check modules.- Parameters:
infos- map of collected module infonormalRows- builder for normal check rowsholderRows- builder for holder check rows
-
buildTableRow
Builds a single table row for a check module.- Parameters:
info- check module information- Returns:
- the HTML table row as a string
-
removeLeadingNewline
Removes leading newline characters from a StringBuilder.- Parameters:
builder- the StringBuilder to process
-
appendHolderSection
private static void appendHolderSection(org.apache.maven.doxia.sink.Sink sink, StringBuilder holderRows) Appends the Holder Checks HTML section.- Parameters:
sink- the output sinkholderRows- the holder rows content
-
appendFilteredHolderSection
private static void appendFilteredHolderSection(org.apache.maven.doxia.sink.Sink sink, StringBuilder holderRows, String packageName) Appends the filtered Holder Checks section for package views.- Parameters:
sink- the output sinkholderRows- the holder rows contentpackageName- the package name
-
getPackageDisplayName
Get display name for package (capitalize first letter).- Parameters:
packageName- the package name- Returns:
- the capitalized package name
-
buildXmlHtmlMap
Builds map of XML file names to HTML documentation paths.- Returns:
- map of lowercase check names to hrefs
-
isValidXmlFile
Checks if a path is a valid XML file for processing.- Parameters:
path- the path to check- Returns:
- true if the path is a valid XML file, false otherwise
-
addXmlHtmlMapping
Adds XML-to-HTML mapping entry to map.- Parameters:
path- the XML file pathmap- the mapping to update
-
resolveHref
private static String resolveHref(Map<String, String> xmlMap, String category, String simpleName, @Nullable String packageFilter) Resolves the href for a given check module. When packageFilter is null, returns full path: checks/category/filename.html#CheckName When packageFilter is set, returns relative path: filename.html#CheckName- Parameters:
xmlMap- map of XML file names to HTML pathscategory- the category of the checksimpleName- simple name of the checkpackageFilter- optional package filter, null for all checks- Returns:
- the resolved href for the check
-
extractCategoryFromJavaPath
Extracts category path from a Java file path.- Parameters:
javaPath- the Java source file path- Returns:
- the category path extracted from the Java path
-
sanitizeAnchorUrls
Sanitizes URLs within anchor tags by removing whitespace from href attributes.- Parameters:
html- the HTML string containing anchor tags- Returns:
- the HTML with sanitized URLs
-
sanitizeAndFirstSentence
Sanitizes HTML and extracts first sentence. Preserves anchor tags while removing other HTML formatting. Also cleans whitespace from URLs in href attributes.- Parameters:
html- the HTML string to process- Returns:
- the sanitized first sentence
-
extractFirstSentence
Extracts first sentence from plain text.- Parameters:
text- the text to process- Returns:
- the first sentence extracted from the text
-
wrapSummary
Wraps long summaries to avoid exceeding line width. Preserves URLs in anchor tags by breaking after the opening tag's closing bracket.- Parameters:
text- the text to wrap- Returns:
- the wrapped text
-
calculateBreakPoint
Calculates the appropriate break point for text wrapping. Handles anchor tags specially to avoid breaking URLs.- Parameters:
clean- the cleaned text to processcleanIndex- current position in textidealBreak- ideal break position- Returns:
- the actual break position
-
shouldBreakAfterAnchorOpen
private static boolean shouldBreakAfterAnchorOpen(int anchorStart, int anchorOpenEnd, int idealBreak) Determines if break should occur after anchor opening tag.- Parameters:
anchorStart- start position of anchor taganchorOpenEnd- end position of anchor opening tagidealBreak- ideal break position- Returns:
- true if should break after anchor opening
-
shouldBreakAfterAnchorContent
private static boolean shouldBreakAfterAnchorContent(int anchorStart, int anchorOpenEnd, int idealBreak, String clean) Determines if break should occur after anchor content.- Parameters:
anchorStart- start position of anchor taganchorOpenEnd- end position of anchor opening tagidealBreak- ideal break positionclean- the text being processed- Returns:
- true if should break after anchor content
-
findSafeBreakPoint
Finds a safe break point at a space character.- Parameters:
text- the text to searchstart- the start indexidealBreak- the ideal break position- Returns:
- the actual break position
-