Class HtmlReviewer
- All Implemented Interfaces:
Reviewer
Reviewer implementation for HTML and XML files with the
.html, .htm, or .xml extension. It identifies
guidance comments and turns matching files into localized review prompts.
The reviewer reads the complete file as UTF-8 text and looks for the configured guidance tag inside an HTML/XML comment. When guidance is found, it creates a localized prompt containing the file name, its path relative to the project directory, and the complete file content.
Guidance is expected to appear in an HTML/XML comment block, for example
<!-- @guidance ... -->. Files without such a comment are not
reviewable by this implementation. The source is decoded as UTF-8 and is
passed to the prompt template without altering its content.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ResourceBundleThe resource bundle used to obtain localized prompt templates for HTML and XML files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns the file extensions supported by this reviewer.Reviews the given file and returns a formatted prompt fragment when the file contains the configured guidance tag in an HTML/XML comment.
-
Field Details
-
promptBundle
The resource bundle used to obtain localized prompt templates for HTML and XML files.The
html_fileresource is expected to accept the file name, project-relative path, and complete file content, in that order. The bundle is resolved using the default locale when this reviewer is initialized.This field is initialized when an
HtmlReviewerinstance is created and remains unchanged for the lifetime of that instance.
-
-
Constructor Details
-
HtmlReviewer
public HtmlReviewer()
-
-
Method Details
-
getSupportedFileExtensions
Returns the file extensions supported by this reviewer. The returned extensions do not include a leading period.- Specified by:
getSupportedFileExtensionsin interfaceReviewer- Returns:
- an array containing
"html","htm", and"xml"
-
perform
Reviews the given file and returns a formatted prompt fragment when the file contains the configured guidance tag in an HTML/XML comment. The complete file is read as UTF-8 so that the prompt preserves its source content exactly. The first matching guidance comment determines whether the file is reviewable; the extracted comment text is used only for that determination because the prompt contains the complete source file.- Specified by:
performin interfaceReviewer- Parameters:
projectDir- the project root directory used to compute a project-relative path for contextguidancesFile- the HTML/XML file to analyze- Returns:
- a formatted prompt fragment, or
nullwhen the file does not contain guidance - Throws:
IOException- if an error occurs while reading the file
-