Tired of keeping your source code comments or code snippets in sync with your documentation? Introducing the Snippet Plugin 2.0, which allows you to include text snippets from external URLs such as Subversion or ViewCVS in your Confluence pages. The plugin supports the ability to define lists of accepted url prefixes to protect against abuse.

For example, in the plugin configuration, you can map the following prefix to URL:

myapp/   -->  http://www.mycompany.com/svn/myapp/

Then, by including the macro in your Confluence page like so:


You can easily import the snippet from a file, README.html, within your Subversion source code repository:

<!--START SNIPPET: description --!>
This application provides. . . .
<!--END SNIPPET: description --!>

Snippet URL’s aren’t limited to plain or HTML text. You can retrieve snippets from Javadoc comments in Java code, and the macro will know how to strip unnecessary characters. Also, you can refer to Java classes directly and the macro will know how to convert the Java class to a URL. For example, with the appropriate URL prefix defined, the macro will map this Java class to a URL:

com.mycompany.myapp.MyClass  --> http://www.mycompany.com/svn/myapp/trunk/src/java/com/mycompany/myapp/MyClass.java

See the Snippet Plugin document for more information.

This new version of the Snippet plugin provides:

  • Configurable URL prefixes
  • Snippet errors collected and managed per-space and globally
  • Plugin configuration page
  • Support for processing Java and Javadoc classes and snippets, respectively

Useful resources:

Fresh ideas, announcements, and inspiration for your team, delivered weekly.

Subscribe now