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

    Fields
    Modifier and Type
    Field
    Description
    private static final Pattern
    Pattern to remove HTML anchor tags (...).
    private static final Pattern
    Pattern for collapsing multiple whitespace characters into one.
    private static final Pattern
    Pattern 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(org.apache.maven.doxia.sink.Sink sink, org.apache.maven.doxia.macro.MacroRequest request)
     
    private static String
    Extracts the first sentence (until the first period followed by whitespace or end).
    private static String
    Cleans up unwanted HTML tags, leaving readable text only.
    private static String
    wrapText(String text, int wrapLimit)
    Wraps text at approximately wrapLimit characters without breaking words.

    Methods inherited from class org.apache.maven.doxia.macro.AbstractMacro

    enableLogging, getAttributesFromMap, getLog, required

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • 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

      private static String extractFirstSentence(String description)
      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

      private static String wrapText(String text, int wrapLimit)
      Wraps text at approximately wrapLimit characters without breaking words. Ensures total line length (including indentation and XML tags) ≤ 100 chars.
      Parameters:
      text - the text to wrap
      wrapLimit - maximum number of characters per line before wrapping
      Returns:
      wrapped text
    • sanitize

      private static String sanitize(String html)
      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