Guide to the Plugin Documentation Standard – Maven (original) (raw)

Introduction

Where did the standard come from?

The plugin documentation standard was created to address the frequent complain of lack of documentation, specifically on the Maven plugins. The standard was based on the suggestions made on the Maven dev mailing list with some refinements. It is a community consensus of what basic documentation a Maven plugin should have.

Why do we need a documentation standard?

The standard is not a set of rules but a guide to help plugin developers document their plugins better, for the benefit of the users of the plugin. The standard also reminds the plugin developers of the important details that needs to be documented, to help speed up the adoption of the plugin.

Generated Documentation

It is recommended that you let Maven generate the basic information for the plugin to make sure that that the basic information is always accurate and synchronized with the plugin implementation.

Documentation is generated by running

mvn site

It will generate a plugin site based on the information in the POM, src/site and other reporting plugins configured in the POM. The most important reporting plugin is the Maven Plugin Report Plugin which will generate the documentation for each plugin goal based on the Mojo annotations. But in order for the generated site to be usable, the required information should be available to the Maven Site Plugin.

POM Elements

Maven extracts the information from the POM to generate the pages under Project Information. The first step in having a good documentation is to have an accurate and visible basic project information, Maven can provide this for the plugin as long as the information in the POM is complete, descriptive and accurate.

Required Elements

Minimum elements for a valid POM:

Optional Elements

These might be optional elements in a valid POM but they are important basic project information required by the users to effectively use the plugin:

<project>  
  [...]  
  <issueManagement>  
    <system>github</system>  
    <url>http://gitub.com/apache/foo/issues</url>  
  </issueManagement>  
  [...]  
</project>  
<project>  
  [...]  
  <mailingLists>  
    <mailingList>  
      <name>Project users</name>  
      <post>announce@noonecares.com</post>  
      <subscribe>users-subscribe@noonecares.com</subscribe>  
      <unsubscribe>users-unsubscribe@noonecares.com</unsubscribe>  
      <archive>http://noonecares.archive.org</archive>  
    </mailingList>  
    <mailingList>  
      [...]  
    </mailingList>  
  </mailingLists>  
  [...]  
</project>  
<project>  
  [...]  
  <licenses>  
    <license>  
      <name>Apache License, Version 2.0</name>  
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>  
      <distribution>repo</distribution>  
    </license>  
  </licenses>  
  [...]  
</project>  
<project>  
  [...]  
  <scm>  
    <connection>scm:svn:http://noonecares.com/some/plugin/project/trunk</connection>  
    <developerConnection>scm:svn:https://noonecares.com/some/plugin/project/trunk</developerConnection>  
    <url>http://noonecares.com/viewvc/some/project/trunk/</url>  
  </scm>  
  [...]  
</project>  
<project>  
  [...]  
  <organization>  
    <name>Noone Care Software Foundation</name>  
    <url>http://noonecare.org/</url>  
  </organization>  
  [...]  
</project>  

Plugin Configuration Parameters

The Maven Plugin Plugin is responsible for generating the Plugin Info site and needs to be added to the <reporting> section unless it is already inherited from a parent POM:

<project>
  [...]
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-report-plugin</artifactId>
        <version>3.15.1</version>
      </plugin>
    </plugins>
  </reporting>
  [...]  
</project>

The comments, annotations and plugin parameter names are extracted from the plugin source and rendered in the Plugin Info page. In order for the generated site to be useful here are some guidelines you can follow when documenting your plugin.

    [...]  
    /**  
     * Put something informative here that a regular user can understand.  
     */  
    @Parameter  
    private boolean someparameter;  
    [...]  
[...]  
/**  
 * Everything here will show up on the top of the generated plugin info page.  
 */  
@Mojo(name = "somegoal", defaultPhase = LifecyclePhase.COMPILE)  
public class ExampleMojo  
    extends AbstractWarMojo  
{  
    public void execute()  
        throws MojoExecutionException, MojoFailureException  
    {  
[...]  

Site Organization

Visibility of the information is also crucial, having uniform navigation links will greatly improve the visibility of the documentations. The index page can also help emphasize important sections and pages of the plugin documentation.

Site Descriptor

The site descriptor describes the navigation links and the layout of the page. It can be found in src/site/site.xml.

You must define a skin, if you are using a site descriptor. There is no default skin applied automatically.

Below is the suggested site descriptor template (with maven-fluido-skin).

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <skin>
    <groupId>org.apache.maven.skins</groupId>
    <artifactId>maven-fluido-skin</artifactId>
    <version>2.1.0</version>
  </skin>

  <body>
    <menu name="Overview">
      <item name="Introduction" href="index.html"/>
      <item name="Goals" href="plugin-info.html"/>
      <item name="Usage" href="usage.html"/>
      <item name="FAQ" href="faq.html"/>
    </menu>
   
    <menu name="Examples">
      <item name="description1" href="examples/example-one.html"/>
      <item name="description2" href="examples/example-two.html"/>
    </menu>
  </body>
</project>

Introduction

Author

YYYY-MM-DD

Plugin Name
Plugin introduction, description, and other relevant information.

<?xml version="1.0" encoding="UTF-8"?>  
<faqs id="FAQ" title="Frequently Asked Questions">  
  <part id="General">  
    <faq id="question">  
      <question>Question?</question>  
      <answer>  
        <p>  
          Answer  
        </p>  
      </answer>  
    </faq>  
  </part>  
</faqs>  

There are 2 recommended report plugins to enhance the plugin documentation, Javadoc and JXR.

<project>  
  [...]  
  <build>  
    [...]  
  </build>  
  <reporting>  
    <plugins>  
      <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-javadoc-plugin</artifactId>  
        <version>3.11.2</version>  
        <configuration>  
          <minmemory>128m</minmemory>  
          <maxmemory>512</maxmemory>  
          ...  
        </configuration>  
      </plugin>  
    </plugins>  
    [...]  
  </reporting>  
  [...]  
</project>  

Check the documentation about the plugin's javadoc:javadoc goal for the advanced configurations.

<project>  
  [...]  
  <build>  
    [...]  
  </build>  
  <reporting>  
    <plugins>  
      <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-jxr-plugin</artifactId>  
        <version>3.3.1</version>  
      </plugin>  
    </plugins>  
  </reporting>  
  [...]  
</project>  

Check the JXR configuration page for the possible configuration parameters.