-
Project home (this page)
Tip
|
Do you want to improve this page? Please git-edit it on GitHub. |
Htmlchecker scans the .html
files present in a given directory and verify that certain rules are violated or not.
A report with all warnings and errors can be obtained as HTML or as XML file.
Following rules ensures that local files referenced as attribute of some html tags are present. Missing files correspond to an error.
-
git-LOCAL_A_TAG_RULE (
href
attribute in the<a>
tag) -
git-LOCAL_IMG_TAG_RULE (
src
attribute in the<img>
tag) -
git-LOCAL_LINK_TAG_RULE (
href
attribute in the<link>
tag) -
git-LOCAL_SCRIPT_TAG_RULE (
src
attribute in the<script>
tag)
The html report looks like this:
See an example for the git-site-example project: example-report.html.
The xml report looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<issues>
<issue
name="LOCAL_A_TAG_RULE"
severity="Error"
message="File 'page2.html' (relative to 'index.html') ......"
category="Local"
summary="Local file should be present"
explanation="All local files referenced by the `href` attribute ......"
location="....../site-example/src/main/resources/site/index.html"
lineNumber="15"
/>
<!-- ..... -->
</issues>
See an example for the git-site-example project: example-report.xml.
Since version 1.2.0, a compiled version of the project is available on maven central.
For the core library:
<dependency>
<groupId>{maven-group-id}</groupId>
<artifactId>htmlchecker-core</artifactId>
<version>{last-stable-version}</version>
</dependency>
An other interesting approach is to run the cli jar using Jbang to take care of the classpath:
jbang run {maven-group-id}:htmlchecker-cli:{last-stable-version} --help
A maven plugin and a gradle plugin are available as well.
In the plugins
section of your build
section, you can add something like this:
link:../../site-example/pom.xml[role=include]
Possible configuration parameters for the maven plugin:
- sourceDirectory
-
Directory to scan (default value is
${project.basedir}
). - outputType
-
Type of report that should be created, possible values:
-
html
(default) -
xml
-
- outputFile
-
Name of the file, where the report will be created (default value is
${project.build.directory}/report.html
). - srcPathPrefix
-
Local or remote path to the source directory, if not set (default) a relative path to the local file will be computed. For the
site-example
project in this repository, the remote path to view the files on GitHub is:https://github.com/jmini/htmlchecker/blob/master/site-example/src/main/resources/site/
. - enableOnlyRules
-
Only check for these rules. Ignored if not set (default).
- disableRules
-
Disable the list of rules. Ignored if not set (default).
- enableRules
-
Enable the list of rules. Ignored if not set (default).
- enableCategories
-
Run all rules of certain categories. Ignored if not set (default).
- noWarnings
-
Only check for errors; ignore warnings. Possible values:
-
false
(default) -
true
-
- allWarnings
-
Check all warnings, including those off by default. Possible values:
-
false
(default) -
true
-
- waringsAreErrors
-
Treat all warnings as errors. Possible values:
-
false
(default) -
true
-
After having unzipped the archive, you can run htmlchecker.cmd
or htmlchecker.sh
depending on your operating system.
htmlchecker --html myreport.html site-example/src/main/resources/site/
Here is the complete list of options:
link:../../htmlchecker-cli/src/test/resources/htmlchecker-help.txt[role=include]
With version 1.2.0
and newer a new export format is available: jenkins-xml
The generated XML file can be parsed by Jenkins using the Warnings Next Generation Plugin (tested with version 5.3.0
).
In your build configuration, in the "Post-build Actions" section, add a "Record compiler warnings and static analysis results" item:
Configure the item with following values:
-
Tool:
Warnings Plugin Native Format
-
Report File Pattern:
target/htmlchecker-report.xml
(example value, must match with the output file created when you run the tool) -
Custom ID:
htmlchecker
(optional) -
Custom Name:
HTML Checker
(optional)
Here the same configuration as Jenkins pipeline script:
recordIssues(tools: [issues(id: 'htmlchecker', name: 'HTML Checker', pattern: 'target/htmlchecker-report.xml')])
The project is hosted on GitHub: {git-repository}
This project is using gradle.
Command to build the sources locally:
./gradlew build
Command to deploy to your local maven repository:
./gradlew publishToMavenLocal
Command to build the documentation page:
./gradlew asciidoctor
The output of this command is an HTML page located at <git repo root>/build/docs/html5/index.html
.
signing.gnupg.keyName
and signing.gnupg.passphrase
are expected to be set in your local gradle.properties
file to be able to sign.
sonatypeUser
and sonatypePassword
are expected to be set in order to be able to publish to a distant repository.
Command to build and publish the result to maven central:
./gradlew publishToSonatype
Command to upload the documentation page on GitHub pages:
./gradlew gitPublishPush
Command to perform a release:
./gradlew release -Prelease.useAutomaticVersion=true
Some tasks requires pushing into the distant git repository (release task or updating the gh-pages
branch).
If they are failing with errors like this:
org.eclipse.jgit.api.errors.TransportException: ... Permission denied (publickey).
Then ssh-agent
can be used.
eval `ssh-agent -s` ssh-add ~/.ssh/id_rsa
(source for this approach)