GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • PMD Source Code Analyzer Project
  • Nav
  • Download
  • GitHub
  • Edit on GitHub

This view

  • Original page
  • New address

GeezerVison is showing docs.pmd-code.org — Writing documentation | PMD Source Code Analyzer

 
  • PMD 7.23.0
  • Release date: 27-March-2026
  • About
    • Home
    • Release notes
    • Release notes (PMD 7)
    • Getting help
    • Release policies
    • Support lifecycle
    • Security
  • User Documentation
    • Migration Guide for PMD 7
    • Installation and basic CLI usage
    • Making rulesets
    • Configuring rules
    • Best practices
    • Suppressing warnings
    • Incremental analysis
    • PMD CLI reference
    • PMD Report formats
    • 3rd party rulesets
    • Signed Releases
    • CPD reference
      • Copy-paste detection
      • CPD Report formats
    • Extending PMD
      • Introduction to writing rules
      • Your first rule
      • XPath rules
      • Java rules
      • Rule designer reference
      • Defining rule properties
      • Rule guidelines
      • Testing your rules
      • Creating (XML) dump of the AST
    • Tools / Integrations
      • Maven PMD Plugin
      • Gradle
      • Ant
      • PMD Java API
      • bld PMD Extension
      • CI integrations
      • IDE Plugins
      • Other Tools / Integrations
  • Rule Reference
    • Apex Rules
      • Index
      • Best Practices
      • Code Style
      • Design
      • Documentation
      • Error Prone
      • Performance
      • Security
    • HTML Rules
      • Index
      • Best Practices
    • Java Rules
      • Index
      • Best Practices
      • Code Style
      • Design
      • Documentation
      • Error Prone
      • Multithreading
      • Performance
      • Security
    • Java Server Pages Rules
      • Index
      • Best Practices
      • Code Style
      • Design
      • Error Prone
      • Security
    • JavaScript Rules
      • Index
      • Best Practices
      • Code Style
      • Error Prone
      • Performance
    • Kotlin Rules
      • Index
      • Best Practices
      • Error Prone
    • Maven POM Rules
      • Index
      • Error Prone
    • Modelica Rules
      • Index
      • Best Practices
    • PLSQL Rules
      • Index
      • Best Practices
      • Code Style
      • Design
      • Error Prone
    • Salesforce Visualforce Rules
      • Index
      • Security
    • Scala Rules
      • Index
    • Swift Rules
      • Index
      • Best Practices
      • Error Prone
    • Velocity Template Language (VTL) Rules
      • Index
      • Best Practices
      • Design
      • Error Prone
    • WSDL Rules
      • Index
    • XML Rules
      • Index
      • Best Practices
      • Error Prone
    • XSL Rules
      • Index
      • Code Style
      • Performance
  • Language-Specific Documentation
    • Overview
    • Language configuration
    • Apex
    • C/C++
    • C#
    • CSS
    • Coco
    • Dart
    • Fortran
    • Gherkin
    • Go
    • HTML
    • Java
    • JavaScript / TypeScript
    • JSP
    • Julia
    • Kotlin
    • Lua
    • Matlab
    • Modelica
    • Objective-C
    • Perl
    • PHP
    • PLSQL
    • Python
    • Ruby
    • Rust
    • Scala
    • Swift
    • T-SQL
    • Visualforce
    • Velocity Template Language (VTL)
    • XML and XML dialects
  • Developer Documentation
    • Contributing
      • Contributing
      • Developer resources
      • Newcomers' Guide
      • Writing documentation
    • Building PMD
      • General Info
      • Building PMD from source
      • Building PMD with IntelliJ IDEA
      • Building PMD with Eclipse IDE
      • Building PMD with VS Code IDE
      • Building PMD with Netbeans IDE
    • Roadmap
    • GitHub Actions Workflows
    • How PMD works
    • Logging
    • Pmdtester
    • Rule Deprecation Policy
    • Major contributions
      • Rule Guidelines
      • Adding a new dialect
      • Adding a new language (JavaCC)
      • Adding a new language (ANTLR)
      • Adding a new CPD language
    • Experimental features
      • List of experimental Features
  • Project documentation
    • Trivia about PMD
      • PMD in the press
      • Products & books related to PMD
      • Similar projects
      • What does 'PMD' mean?
    • Logo
    • FAQ
    • License
    • Credits
    • Old release notes
    • Decisions
    • Project management
      • Infrastructure
      • Release process
      • Merging pull requests
      • Main Landing page

Writing documentation

Table of Contents

PMD’s documentation uses Jekyll with the I’d rather be writing Jekyll Theme.

Here are some quick tips.

Format

The pages are in general in Github Flavored Markdown.

Structure

The documentation sources can be found in two places based on how they are generated:

  • the ones that are manually written (like the one you are reading);
  • and the ones that are generated automatically from the category files. All the rule documentation pages are generated that way.

Handwritten documentation

All handwritten documentation is stored in the subfolders under docs/pages. The folder structure resembles the sidebar structure. Since all pages use a simple permalink, in the rendered html pages, all pages are flattened in one directory. This makes it easy to view the documentation also offline.

Rule documentation

The categories for a language %lang% are located in pmd-%lang%/src/main/resources/category/%lang% . So for Java the categories can be found under pmd-java/src/main/resources/category/java. The XML category files in this directory are transformed during build into markdown pages describing the rules they contain. These pages are placed under docs/ like the handwritten documentation, and are then rendered with Jekyll like the rest of them. The rule documentation generator is the separate submodule pmd-doc.

Modifying the documentation of a rule should thus not be done on the markdown page, but directly on the XML rule tag corresponding to the rule, in the relevant category file.

The XML documentation of rules can contain GitHub flavoured markdown. Just wrap the markdown inside CDATA section in the xml. CDATA sections preserve all formatting inside the delimiters, and allow to write code samples without escaping special xml characters. For example:

<rule ...>
 <description>
 <![CDATA[
   Full description, can contain markup

   And paragraphs
 ]]>
 </description>
 ...
</rule>

Custom Liquid Tags

We have some additional custom liquid tags that help in writing the documentation.

Here’s a short overview:

Liquid Rendered as
{% rule "java/codestyle/LinguisticNaming" %} LinguisticNaming
{% jdoc core::lang.rule.Rule %} Rule
{% jdoc !q!core::lang.rule.Rule %} net.sourceforge.pmd.lang.rule.Rule
{% jdoc core::lang.rule.Rule#setName(java.lang.String) %} setName
{% jdoc !c!core::lang.rule.Rule#setName(java.lang.String) %} Rule#setName
{% jdoc !a!core::lang.rule.Rule#setName(java.lang.String) %} setName(String)
{% jdoc !ac!core::lang.rule.Rule#setName(java.lang.String) %} Rule#setName(String)
{% jdoc core::properties.PropertyDescriptor %} PropertyDescriptor
{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc jast::ASTTypeDeclaration %} ASTTypeDeclaration
{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc_package :jast %} net.sourceforge.pmd.lang.java.ast
{% jdoc_nspace :PrD core::properties.PropertyDescriptor %}{% jdoc !ac!:PrD#uiOrder() %} PropertyDescriptor#uiOrder()
{% jdoc_old core::Rule %} Rule

For the javadoc tags, the standard PMD maven modules are already defined as namespaces, e.g. core, java, apex, ….

For the implementation of these tags, see the _plugins folder.

Building

There are two ways, to execute jekyll:

  1. Using bundler. This will install all the needed ruby packages locally and execute jekyll:

    # this is required only once, to download and install the dependencies
    bundle install
    # this builds the documentation under _site
    bundle exec jekyll build
    # this runs a local webserver as http://localhost:4005
    bundle exec jekyll serve
    
  2. Using docker. This will create a local docker image, into which all needed ruby packages and jekyll is installed.

    # this is required only once to create a local docker image named "pmd-doc"
    docker build --no-cache -t pmd-doc .
    # this builds the documentation under _site
    docker run --rm=true -v "$PWD:/src" pmd-doc build -H 0.0.0.0
    # this runs a local webserver as http://localhost:4005
    docker run --rm=true -v "$PWD:/src" -p 4005:4005 pmd-doc serve -H 0.0.0.0
    

The built site is stored locally in the (git ignored) directory _site. You can point your browser to _site/index.html to see the pmd documentation.

Alternatively, you can start the local webserver, that will serve the documentation. Just go to http://localhost:4005. If a page is modified, the documentation will automatically be rendered again and all you need to do, is refreshing the page in your browser.

See also the script pmd-jekyll.sh. It starts the jekyll server in the background and doesn’t block the current shell.

The sidebar

The sidebar is stored as a YAML document under _data/sidebars/pmd_sidebar.yml.

Make sure to add an entry there, whenever you create a new page.

The frontmatter

Each page in jekyll begins with a YAML section at the beginning. This section is separated by 3 dashes (---). Example:

---
title: Writing Documentation
last_updated: January 2025 (7.10.0)
permalink: pmd_devdocs_writing_documentation.html
---

Some Text

# Some header

There are a couple of possible fields. Most important and always required are title and permalink.

By default, a page toc (table of contents) is automatically generated. You can prevent this with “toc: false”.

You can add keywords, that will be used for the on-site search: “keywords: documentation, jekyll, markdown”

It’s useful to maintain a last_updated field. This will be added at the bottom of the page.

A summary can also be provided. It will be added in a box before the content.

For a more exhaustive list, see Pages - Frontmatter.

Alerts and Callouts

See Alerts.

For example, a info-box can be created like this:

{% include note.html content="This is a note." %}

It renders as:

Note: This is a note.

Other available types are:

  • note.html
  • tip.html
  • warning.html
  • important.html

A callout is created like this:

{% include callout.html content="This is a callout of type default.<br/><br/>There are the following types available: danger, default, primary, success, info, and warning." type="default" %}

It renders as:

This is a callout of type default.

There are the following types available: danger, default, primary, success, info, and warning.

Code samples with syntax highlighting

This is as easy as:

``` java
public class Foo {
    public void bar() { System.out.println("x"); }
}
```

This looks as follows:

public class Foo {
    public void bar() { System.out.println("x"); }
}

Checking for dead links

mvn verify -pl pmd-doc. This only checks links within the site. HTTP links can be checked by specifying -Dpmd.doc.checkExternalLinks=true on the command line.

Tags: devdocs
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.