[html] Add documentation (#3885)
This commit is contained in:
@ -379,6 +379,9 @@ entries:
|
||||
- title: XML and XML dialects
|
||||
url: /pmd_languages_xml.html
|
||||
output: web, pdf
|
||||
- title: HTML
|
||||
url: /pmd_languages_html.html
|
||||
output: web, pdf
|
||||
- title: Developer Documentation
|
||||
output: web, pdf
|
||||
folderitems:
|
||||
|
18
docs/pages/pmd/languages/html.md
Normal file
18
docs/pages/pmd/languages/html.md
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
title: Processing HTML files
|
||||
permalink: pmd_languages_html.html
|
||||
last_updated: April 2022 (6.45.0)
|
||||
---
|
||||
|
||||
## The HTML language module
|
||||
|
||||
**Since:** 6.45.0
|
||||
|
||||
**Minimum Java Runtime:** Java 8
|
||||
|
||||
{% include warning.html content="This language module is experimental and may change any time." %}
|
||||
|
||||
The HTML language module uses [jsoup](https://jsoup.org/) for parsing.
|
||||
|
||||
XPath rules are supported, but the DOM is not a typical XML/XPath DOM. E.g.
|
||||
text nodes are normal nodes. This might change in the future.
|
@ -14,6 +14,36 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
### New and noteworthy
|
||||
|
||||
#### Support for HTML
|
||||
|
||||
This version of PMD ships a new language module to support analyzing of HTML.
|
||||
Support for HTML is experimental and might change without notice.
|
||||
|
||||
#### New rules
|
||||
|
||||
* The HTML rule {% rule html/bestpractices/AvoidInlineStyles %} finds elements which use a style attribute.
|
||||
In order to help maintaining a webpage it is considered good practice to separate content and styles. Instead
|
||||
of inline styles one should use CSS files and classes.
|
||||
|
||||
```xml
|
||||
<rule ref="category/html/bestpractices.xml/AvoidInlineStyles" />
|
||||
```
|
||||
|
||||
* The HTML rule {% rule html/bestpractices/UnnecessaryTypeAttribute %} finds "link" and "script" elements which
|
||||
still have a "type" attribute. This is not necessary anymore since modern browsers automatically use CSS and
|
||||
JavaScript.
|
||||
|
||||
```xml
|
||||
<rule ref="category/html/bestpractices.xml/UnnecessaryTypeAttribute" />
|
||||
```
|
||||
|
||||
* The HTML rule {% rule html/bestpractices/UseAltAttributeForImages %} finds "img" elements without an "alt"
|
||||
attribute. An alternate text should always be provided in order to help screen readers.
|
||||
|
||||
```xml
|
||||
<rule ref="category/html/bestpractices.xml/UseAltAttributeForImages" />
|
||||
```
|
||||
|
||||
#### Modified rules
|
||||
|
||||
* The Java rule {% rule java/bestpractices/UnusedPrivateField %} has a new property `ignoredFieldNames`.
|
||||
|
15
pmd-core/src/main/resources/rulesets/releases/6450.xml
Normal file
15
pmd-core/src/main/resources/rulesets/releases/6450.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="6450"
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
<description>
|
||||
This ruleset contains links to rules that are new in PMD v6.45.0
|
||||
</description>
|
||||
|
||||
<rule ref="category/html/bestpractices.xml/AvoidInlineStyles" />
|
||||
<rule ref="category/html/bestpractices.xml/UnnecessaryTypeAttribute" />
|
||||
<rule ref="category/html/bestpractices.xml/UseAltAttributeForImages" />
|
||||
|
||||
</ruleset>
|
Reference in New Issue
Block a user