Class AIIndexTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.sentrysoftware.maven.skin.AIIndexTool

@DefaultKey("aiIndexTool") public class AIIndexTool extends org.apache.velocity.tools.generic.SafeConfig
aiIndexTool is a Velocity tool that creates AI-ready Markdown index files.

It converts HTML documentation pages to Markdown format with YAML frontmatter, making them suitable for AI consumption and processing.

  • Field Summary

    Fields inherited from class org.apache.velocity.tools.generic.SafeConfig

    LOCK_CONFIG_KEY, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance
  • Method Summary

    Modifier and Type
    Method
    Description
    convertToMarkdown(String outputDirectory, String docPath, org.jsoup.nodes.Element headElement, org.jsoup.nodes.Element bodyElement, Date publishDate, String projectUrl)
    Converts an HTML document to a Markdown file.
    void
    updateLlmsTxt(String llmsTxtPath, String docPath, String docTitle, String projectName, String projectDescription, String section)
    Updates or creates an llms.txt file by adding or updating a documentation entry.
    void
    updateLlmsTxt(String llmsTxtPath, String docPath, String docTitle, String projectName, String projectDescription, String section, String projectUrl)
    Updates or creates an llms.txt file by adding or updating a documentation entry.

    Methods inherited from class org.apache.velocity.tools.generic.SafeConfig

    configure, isConfigLocked, isSafeMode

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AIIndexTool

      public AIIndexTool()
      Creates a new instance
  • Method Details

    • convertToMarkdown

      public String convertToMarkdown(String outputDirectory, String docPath, org.jsoup.nodes.Element headElement, org.jsoup.nodes.Element bodyElement, Date publishDate, String projectUrl)
      Converts an HTML document to a Markdown file.

      The Markdown file will contain:

      • YAML frontmatter with meta tags extracted from HTML header
      • The body content converted from HTML to Markdown
      Parameters:
      outputDirectory - Actual root directory of the site on the file system
      docPath - Logical path to the document relative to outputDirectory (e.g., "subdir/feature.html"), the .md file will be created at the same location with .html.md extension (per llmstxt.org convention)
      headElement - The HTML head element (containing meta tags)
      bodyElement - The HTML body element
      publishDate - The publication date for the document (used for date_published and date_modified frontmatter fields)
      projectUrl - The base URL of the project site (used to build canonical_url)
      Returns:
      An HTML link element for the alternate Markdown version, e.g. <link rel="alternate" type="text/markdown" href="/docs/page.html.md">, or an empty string if conversion fails
    • updateLlmsTxt

      public void updateLlmsTxt(String llmsTxtPath, String docPath, String docTitle, String projectName, String projectDescription, String section)
      Updates or creates an llms.txt file by adding or updating a documentation entry.

      The llms.txt file follows a specific Markdown format with sections containing links to documentation pages. This method is typically called for each generated HTML file during site generation.

      This is a convenience method that uses relative paths for links. Use updateLlmsTxt(String, String, String, String, String, String, String) to specify a project URL for absolute links.

      Parameters:
      llmsTxtPath - Path to the llms.txt file
      docPath - Path relative to the root of the site (e.g., "subdir/page.html")
      docTitle - Title of the document
      projectName - Name of the project (used in the H1 header)
      projectDescription - Description of the project (used in the blockquote)
      section - Name of the section where this entry should be placed; if null or empty, the entry is placed in the "Other" section
    • updateLlmsTxt

      public void updateLlmsTxt(String llmsTxtPath, String docPath, String docTitle, String projectName, String projectDescription, String section, String projectUrl)
      Updates or creates an llms.txt file by adding or updating a documentation entry.

      The llms.txt file follows a specific Markdown format with sections containing links to documentation pages. This method is typically called for each generated HTML file during site generation.

      Parameters:
      llmsTxtPath - Path to the llms.txt file
      docPath - Path relative to the root of the site (e.g., "subdir/page.html")
      docTitle - Title of the document
      projectName - Name of the project (used in the H1 header)
      projectDescription - Description of the project (used in the blockquote)
      section - Name of the section where this entry should be placed; if null or empty, the entry is placed in the "Other" section
      projectUrl - The base URL of the project site (used to build absolute URLs for the links); if null or empty, relative paths are used