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.
-
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 StringPath component for checks directory.private static final StringHTML file extension.private static final PathRoot path for Java check files.private static final PatternMatches HTML anchor tags and captures their inner text.private static final intMaximum line width considering indentation.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 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, boolean isHolder) 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 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 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.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 booleanisCheckOrHolderFile(Path path) Checks if a path is a Check or Holder Java file.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) Processes a single check class file and extracts metadata.private static voidprocessCheckFiles(Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, String> xmlHrefMap) 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
-
LINK_PATTERN
Matches HTML anchor tags and captures their inner text. Used to strip <a> elements while keeping their display text. -
TAG_PATTERN
Matches common HTML tags such as paragraph, div, span, strong, and em. Used to remove formatting tags from the Javadoc HTML content. -
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. -
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:
-
-
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) Scans Java sources and populates info map with modules having Javadoc.- Parameters:
infos- map of collected module infoxmlHrefMap- map of XML-to-HTML hrefs- 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
-
processCheckFile
private static void processCheckFile(Path path, Map<String, AllCheckSummaries.CheckInfo> infos, Map<String, String> xmlHrefMap) Processes a single check class file and extracts metadata.- Parameters:
path- the check class fileinfos- map of resultsxmlHrefMap- map of XML hrefs- Throws:
IllegalArgumentException- if macro execution fails
-
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, boolean isHolder) Adds a newAllCheckSummaries.CheckInforecord to the provided map.- Parameters:
infos- map to updatesimpleName- simple class namehref- documentation hrefsummary- short summary of the checkisHolder- true if the check is a holder module
-
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
-
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
Resolves the href for a given check module.- Parameters:
xmlMap- map of XML file names to HTML pathscategory- the category of the checksimpleName- simple name of the check- 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.- 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
-