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.
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.
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 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.
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.
Minimum elements for a valid POM:
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:
[...] <issueManagement> <system>jira</system> <url>http://jira.someproject.org</url> </issueManagement> [...]
[...] <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> [...]
[...] <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> [...]
[...] <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> [...]
[...] <organization> <name>Noone Care Software Foundation</name> <url>http://noonecare.org/</url> </organization> [...]
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:
[...] <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <version>2.5.1</version> </plugin> </plugins> </reporting> [...]
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. * * @goal somegoal * @phase compile */ public class ExampleMojo extends AbstractWarMojo { public void execute() throws MojoExecutionException, MojoFailureException { [...]
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.
The site descriptor describes the navigation links and can be found in src/site/site.xml. Below is the suggested site descriptor template.
<?xml version="1.0" encoding="UTF-8"?> <project> <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>
The introduction is the front page of the plugin documentation. This is a good place to place any section and pages that needs to be emphasized. It is also suggested that the generated plugin parameter configuration be linked here. Below is the suggested src/site/apt/index.apt template
------ Introduction ------ Author ------ YYYY-MM-DD ------ Plugin Name Plugin introduction, description, and other relevant information. * Goals Overview General information about the goals. * {{{<goal>.html}prefix:goal}} short description for this plugin goal. * Usage General instructions on how to use the Plugin Name can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Plugin+Name}plugin's wiki page}}. In case you still have questions regarding the plugin's usage, please have a look at the {{{faq.html}FAQ}} and feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding of some usages of the Plugin Name, you can take a look into the following examples: * {{{./examples/example-one.html}Example Description One}} * {{{./examples/example-two.html}Example Description Two}}
plugin-info.html is generated by the Maven Plugin Plugin. Until the Maven Site Plugin is updated it would be better to pull it out to the main menu for greater visibility. This contains the goals and their descriptions with a link to the configuration parameters. The information is based on the comments and annotations of the plugin.
The usage page describes the the basic use cases for the plugin goals which includes sample POM configurations and explanation of how the goals work.
A well documented project always collates frequently asked questions which are usually located in src/site/fml/faq.fml. The example below provides a template for your FAQ:
<?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>
The advanced configurations and examples not covered in the usage page is located here. Advanced users who wants to maximize the use of a plugin can check the items here. Tips on how to use the plugin effectively is also a good thing to put here.
For examples of items under "Examples" check these plugin sites:
There are 2 recommended report plugins to enhance the plugin documentation, Javadoc and JXR.
Javadocs provide documentation that makes it easier for developers to know how to use a particular class. Instead of reading and understanding the actual source code, the developer can use the Javadocs instead to lookup the class attributes and methods.
To enable javadoc for your plugin add the following to your pom.xml
[...] <build> [...] </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.4</version> <configuration> <minmemory>128m</minmemory> <maxmemory>512</maxmemory> ... </configuration> </plugin> </plugins> [...] </reporting> [...]
Check the documentation about the plugin's javadoc:javadoc goal for the advanced configurations.
The Maven JXR Plugin generates a cross-reference of the project sources. The generated cross-references are also linked to the corresponding javadoc if javadoc is generated. The cross-references is great for those who wants to better understand the inner workings of the plugin.
To enable source code cross-references add the following to your pom.xml
[...] <build> [...] </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.1</version> </plugin> </plugins> </reporting> [...]
Check the JXR configuration page for the possible configuration parameters.