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.
  • 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
    • processCheckFiles

      private static void processCheckFiles(Map<String,AllCheckSummaries.CheckInfo> infos, Map<String,String> xmlHrefMap) throws org.apache.maven.doxia.macro.MacroExecutionException
      Scans Java sources and populates info map with modules having Javadoc.
      Parameters:
      infos - map of collected module info
      xmlHrefMap - map of XML-to-HTML hrefs
      Throws:
      org.apache.maven.doxia.macro.MacroExecutionException - if file walk fails
    • isCheckOrHolderFile

      private static boolean isCheckOrHolderFile(Path path)
      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 file
      infos - map of results
      xmlHrefMap - map of XML hrefs
      Throws:
      IllegalArgumentException - if macro execution fails
    • getDescriptionIfPresent

      @Nullable private static String getDescriptionIfPresent(DetailNode javadoc)
      Returns the module description if present and non-empty.
      Parameters:
      javadoc - the parsed Javadoc node
      Returns:
      the description text, or null if not present
    • createSummary

      private static String createSummary(String description)
      Produces a concise, sanitized summary from the full Javadoc description.
      Parameters:
      description - full Javadoc text
      Returns:
      sanitized first sentence of the description
    • extractCategory

      private static String extractCategory(Path path)
      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 new AllCheckSummaries.CheckInfo record to the provided map.
      Parameters:
      infos - map to update
      simpleName - simple class name
      href - documentation href
      summary - short summary of the check
      isHolder - true if the check is a holder module
    • getModuleDescriptionSafe

      @Nullable private static String getModuleDescriptionSafe(DetailNode javadoc)
      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 info
      normalRows - builder for normal check rows
      holderRows - 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 entries
      normalRows - builder for normal check rows
      holderRows - builder for holder check rows
    • finalizeRows

      private static void finalizeRows(StringBuilder normalRows, StringBuilder holderRows)
      Removes leading newlines from the generated table row builders.
      Parameters:
      normalRows - builder for normal check rows
      holderRows - 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

      private static void removeLeadingNewline(StringBuilder builder)
      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 sink
      holderRows - the holder rows content
    • buildHolderSectionHtml

      private static String buildHolderSectionHtml(StringBuilder holderRows)
      Builds the HTML for the Holder Checks section.
      Parameters:
      holderRows - the holder rows content
      Returns:
      the complete HTML section as a string
    • buildXmlHtmlMap

      private static Map<String,String> buildXmlHtmlMap()
      Builds map of XML file names to HTML documentation paths.
      Returns:
      map of lowercase check names to hrefs
    • isValidXmlFile

      private static boolean isValidXmlFile(Path path)
      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

      private static void addXmlHtmlMapping(Path path, Map<String,String> map)
      Adds XML-to-HTML mapping entry to map.
      Parameters:
      path - the XML file path
      map - the mapping to update
    • resolveHref

      private static String resolveHref(Map<String,String> xmlMap, String category, String simpleName)
      Resolves the href for a given check module.
      Parameters:
      xmlMap - map of XML file names to HTML paths
      category - the category of the check
      simpleName - simple name of the check
      Returns:
      the resolved href for the check
    • extractCategoryFromJavaPath

      private static String extractCategoryFromJavaPath(Path javaPath)
      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

      private static String sanitizeAndFirstSentence(String html)
      Sanitizes HTML and extracts first sentence.
      Parameters:
      html - the HTML string to process
      Returns:
      the sanitized first sentence
    • extractFirstSentence

      private static String extractFirstSentence(String text)
      Extracts first sentence from plain text.
      Parameters:
      text - the text to process
      Returns:
      the first sentence extracted from the text
    • wrapSummary

      private static String wrapSummary(String text)
      Wraps long summaries to avoid exceeding line width.
      Parameters:
      text - the text to wrap
      Returns:
      the wrapped text
    • performWrapping

      private static String performWrapping(String text)
      Performs wrapping of summary text.
      Parameters:
      text - the text to wrap
      Returns:
      the wrapped text