Class ChecksXmlMacro
java.lang.Object
org.apache.maven.doxia.macro.AbstractMacro
com.puppycrawl.tools.checkstyle.site.ChecksXmlMacro
- 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="checks")
public class ChecksXmlMacro
extends org.apache.maven.doxia.macro.AbstractMacro
A macro that inserts the first sentence (summary) of a Check module's Javadoc,
cleaned of HTML tags and links for safe inclusion in xdoc XML.
This class is used during site generation to dynamically populate
checks.xml content using module-level documentation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternPattern to remove HTML anchor tags (...).private static final PatternPattern for collapsing multiple whitespace characters into one.private static final PatternPattern to remove structural HTML tags like div, p, span, em, strong.Fields inherited from interface org.apache.maven.doxia.macro.Macro
EOL, ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(org.apache.maven.doxia.sink.Sink sink, org.apache.maven.doxia.macro.MacroRequest request) private static StringextractFirstSentence(String description) Extracts the first sentence (until the first period followed by whitespace or end).private static StringCleans up unwanted HTML tags, leaving readable text only.private static StringWraps text at approximatelywrapLimitcharacters without breaking words.Methods inherited from class org.apache.maven.doxia.macro.AbstractMacro
enableLogging, getAttributesFromMap, getLog, required
-
Field Details
-
STRUCTURAL_TAG_PATTERN
Pattern to remove structural HTML tags like div, p, span, em, strong. -
ANCHOR_TAG_PATTERN
Pattern to remove HTML anchor tags (...). -
SPACE_PATTERN
Pattern for collapsing multiple whitespace characters into one.
-
-
Constructor Details
-
ChecksXmlMacro
public ChecksXmlMacro()
-
-
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
-
extractFirstSentence
Extracts the first sentence (until the first period followed by whitespace or end).- Parameters:
description- the full module description text- Returns:
- first sentence of description
-
wrapText
Wraps text at approximatelywrapLimitcharacters without breaking words. Ensures total line length (including indentation and XML tags) ≤ 100 chars.- Parameters:
text- the text to wrapwrapLimit- maximum number of characters per line before wrapping- Returns:
- wrapped text
-
sanitize
Cleans up unwanted HTML tags, leaving readable text only. Preserves inline formatting tags like<code>.- Parameters:
html- the HTML text to clean- Returns:
- sanitized text without unwanted tags
-