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.private static final StringPath component for checks directory.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 StringHTML file extension.private static final PathRoot path for Java check files.private static final intMaximum line width considering 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 StringXML file extension.Fields inherited from interface org.apache.maven.doxia.macro.Macro
EOL, ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddCheckInfo(Map<String, AllCheckSummaries.CheckInfo> infos, String simpleName, String href, String summary) Adds a newAllCheckSummaries.CheckInforecord to the provided map.private 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 voidappendRows(Map<String, AllCheckSummaries.CheckInfo> infos, StringBuilder normalRows, StringBuilder holderRows) Iterates over collected check info entries and appends corresponding rows.private static StringbuildFilteredHolderSectionHtml(StringBuilder holderRows, String packageTitle) Builds the HTML for the filtered Holder Checks section.private static StringbuildHolderSectionHtml(StringBuilder holderRows) Builds the HTML for the Holder Checks 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 StringcreateSummary(String description) Produces a concise, sanitized summary from the full Javadoc description.private static StringdeterminePackageName(Path path, String moduleName) Determines the package name for a check, applying remapping rules.private static StringdetermineSimpleName(String moduleName) Determines the simple name of a check module.voidexecute(org.apache.maven.doxia.sink.Sink sink, org.apache.maven.doxia.macro.MacroRequest request) private static StringextractCategory(Path path) Extracts category name from the given Java source path.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 voidfinalizeRows(StringBuilder normalRows, StringBuilder holderRows) Removes leading newlines from the generated table row builders.private static StringgetDescriptionIfPresent(DetailNode javadoc) Returns the module description if present and non-empty.private static StringgetModuleDescriptionSafe(DetailNode javadoc) Retrieves Javadoc description node safely.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 StringperformWrapping(String text) Performs wrapping of summary text.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 StringSanitizes HTML and extracts first sentence.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
-
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. -
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. -
CODE_SPACE_PATTERN
Pattern to match trailing spaces before closing code tags. -
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. -
MAX_LINE_WIDTH
Maximum line width considering indentation.- See Also:
-
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:
-
-
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
-
determineSimpleName
Determines the simple name of a check module.- Parameters:
moduleName- the full module name- Returns:
- the simple name
-
determinePackageName
Determines the package name for a check, applying remapping rules.- Parameters:
path- the check class filemoduleName- the module name- Returns:
- the package name
-
getDescriptionIfPresent
Returns the module description if present and non-empty.- Parameters:
javadoc- the parsed Javadoc node- Returns:
- the description text, or
nullif not present
-
createSummary
Produces a concise, sanitized summary from the full Javadoc description.- Parameters:
description- full Javadoc text- Returns:
- sanitized first sentence of the description
-
extractCategory
Extracts category name from the given Java source path.- Parameters:
path- source path of the class- Returns:
- category name string
-
addCheckInfo
private static void addCheckInfo(Map<String, AllCheckSummaries.CheckInfo> infos, String simpleName, String href, String summary) Adds a newAllCheckSummaries.CheckInforecord to the provided map.- Parameters:
infos- map to updatesimpleName- simple class namehref- documentation hrefsummary- short summary of the check
-
getModuleDescriptionSafe
Retrieves Javadoc description node safely.- Parameters:
javadoc- DetailNode root- Returns:
- module description or null
-
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
-
appendRows
private static void appendRows(Map<String, AllCheckSummaries.CheckInfo> infos, StringBuilder normalRows, StringBuilder holderRows) Iterates over collected check info entries and appends corresponding rows.- Parameters:
infos- map of check info entriesnormalRows- builder for normal check rowsholderRows- builder for holder check rows
-
finalizeRows
Removes leading newlines from the generated table row builders.- Parameters:
normalRows- 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
-
buildHolderSectionHtml
Builds the HTML for the Holder Checks section.- Parameters:
holderRows- the holder rows content- Returns:
- the complete HTML section as a string
-
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
-
buildFilteredHolderSectionHtml
Builds the HTML for the filtered Holder Checks section.- Parameters:
holderRows- the holder rows contentpackageTitle- the display name of the package- Returns:
- the complete HTML section as a string
-
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
-
sanitizeAndFirstSentence
Sanitizes HTML and extracts first sentence. Preserves anchor tags while removing other HTML formatting.- 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.- Parameters:
text- the text to wrap- Returns:
- the wrapped text
-
performWrapping
Performs wrapping of summary text.- Parameters:
text- the text to wrap- Returns:
- the wrapped text
-