projectdoc Toolbox

Integrate information from different sources into your documentation using Confluence and the projectdoc Toolbox.

Parent
Audience
Level of Experience
Expected Duration
20 min
Tags
Type
Contents

This is a short outline on how to bring living documentation to Confluence - the team collaboration platform - with the projectdoc Toolbox.

We will first define what living documentation is and then show how the tools in the projectdoc Toolbox support it. The journey will take us from the source code artifacts, where the information specified, to the Confluence page, where this information is displayed.

This approach can be used - for instance - to document error and response codes, create examples of usage patterns of APIs, or to expose project and product properties, such as build information or configuration properties.

Definition

What is living documentation?

Living documentation is a source of information about system functionality that’s as reliable as programming language code but much easier to access and understand.

Gojko Adzic. Specification by Example. 2011

In his book Living Documentation, Cyrille Martraire defines four principles documentation has to meet to be called 'living documentation'.

  • Reliable by making sure all documentation is accurate and in sync with the software being delivered, at any point in time.
  • Low-Effort by minimizing the amount of work to be done on documentation even in case of changes, deletions or additions. It only requires a minimal additional effort, and only once.
  • Collaborative: it promotes conversations and knowledge sharing between everyone involved.
  • Insightful: By drawing attention to each aspect of the work, it offers opportunities for feedback and encourages deeper thinking. It helps reflect over the on-going work and guides towards better decisions
Cyrille Martraire. Living Documentation, Core Principles of Living Documentation, p. 34. 2016

Process

This definition and principles in mind we outline a process based on Confluence and the projectdoc Toolbox where information is

  1. gathered from the source,
  2. refined, packed, and finally
  3. fed to the team collaboration platform.

The information may be

  • copied (imported) in case it is frozen (that is: a release with a version number has been created),
  • transcluded from remote information systems, or
  • referenced in remote information systems.

This way the documentation is

  • reliable - it is in-sync with the information in the source artifacts
  • created at low-cost - it is integrated automatically
  • collaborative - it is available in the team collaboration platform so that each stakeholder has access to (directly or indirectly)
  • insightful - every stakeholder provides feedback and is able to refine information by adding new views on the subjects

From the Source

smartics Exceptions

The farther documentation is away from the source code, the more likely it is that it is out-of-date and therefore plain wrong. It is beneficial to keep all information as close to the source as possible. This makes it easier for the development team to reflect changes to the source code directly to the documentation in the source file.

smartics Properties

The information may be available in plain configuration files, like the Maven POM file or deployment descriptors such as the web.xml.

Often the information is attached to the source code by the use of annotations (see Java Annotations). The annotations typically have impact on the runtime behavior. So changing an annotation directly takes effect in the execution of the software.

Information may be added as comments, especially as API documentation, such as Javadoc.

Finally information may also be gathered from types (such as interfaces) or members (fields and methods).

Here are some examples for tools and libraries that add information to the source code.

Javadoc Tool
Javadoc is a tool for generating API documentation in HTML format from doc comments in source code.
Java REST Annotations
A tutorial on writing REST services with Java using annotations.
Mojo Annotations
Overview over annotations to use for writing mojos of a plugin for Maven.
smartics Exceptions
Library for Java to define exceptions and exception codes. This project addresses services for exception handling commonly required for applications, be them standalone or distributed multi-tier enterprise applications.
smartics Properties
A library for Java to declare and define properties and to access them from an application in a convenient way.

Generate Reports

Information can be derived from the source code in various ways. An automatic process may simply grab all configuration files and make them available for other information systems. If the information is spread over multiple files, maybe in different formats, a parser may first generate the information in one or multiple normalized files.

Examples for tools to generate reports:

  1. Buildmetadata Maven Plugin - collects build time information
  2. Maven Javadoc Plugin - creates an API documentation
  3. Maven Surefire Plugin - creates test reports
  4. Maven Checkstyle Plugin - creates a report on static analysis results
  5. Maven PMD Plugin - also creates a report on static analysis results
  6. Exception Codes Maven Plugin - creates a report on exception and error codes
  7. Properties Maven Plugin - creates a report on configuration parameters and their actual values
  8. Maven Plugin Pluging - creates the Maven Plugin Descriptor
Red Hat Fork

There is a fork of the Buildmetadata Maven Plugin supported by a team at Red Hat.

The fork is also available as a GitHub project and their artifact is deployed to the public Maven Repository!

We are continuing with supporting our version, adding new features, and keeping close contact with the team at Red Hat. For more information please read Great News: Buildmetadata Maven Plugin forked!

Bundle Reports to Artifacts

Some information is automatically bundled with the generated artifact during the build process.

Projectmetadata Maven Plugin Configuration

For information that is not automatically attached, the Projectmetadata Maven Plugin allows to create an artifact with any information attached. This artifact is then added to the artifact server for reference. The inclusion of report artifacts is based on descriptors. The plugin provides a number of standard descriptors and allows to define custom descriptors to attach additional formats.

Make available

The following techniques make the report information available on the team collaboration platform.

Import Artifacts

Create Space for Maven Plugin

Import static information to a space by referencing a POM file or its GAV coordinates.

  1. Create a space to document Maven plugins using projectdoc for Maven Developers
  2. Create a space to document a Java library using projectdoc for Java Developers
  3. Use the Version Doctype of the Core Doctypes to add new versions to an existing space

Java Space with Versions

Experimental

 

The import is based on the Maven Extension which is currently experimental.

We already use it to document our own products. Be aware that we currently only cover some basic use cases.

Transclude and Reference

Make reports available on remote information systems, like

  1. Javadoc API reports - using the Javadoc Maven Plugin to generate the report as part of a Maven Site
  2. Diagrams on an image repository - exporting diagrams with the smartics Enterprise Architect Maven Plugin
  3. Artifacts on an artifact repository - by the use of the Maven Deploy Plugin

Use in your Documents

Now let's access the provided information.

Imported Information

Static imported information can be easily accessed using the Display Space Property Macro and Display Document Property Macro (or it's cousins).

Real-Life Project

 

The smartics Enforcer Rules for Maven is based on the Java space template and has imported a number of versions via its Maven POM file.

Excerpt of Properties imported from a Maven POM

The screen shot shows an excerpt of the properties from the project's POM.

Refer to Space Properties and Using Space Properties for more information on space properties and to Document Properties for more information on document properties.

Remote Information

Information on remote systems can be easily transcluded or referred to using macros of the Information Systems Extension.

  1. Reference Javadoc API reports with the Javadoc Link Macro
  2. Transclude diagrams on an Enterprise Architect repository using the Enterprise Architect Image Link Macro
  3. Reference Artifacts on an artifact repository with the Nexus Link Macro
  4. Reference or transclude remote resources with the System Image Link Macro, System Transclusion Macro, or System Link Macro
 

References can be easily made with plain Confluence links. The advantage of the macros is that they use space properties to construct the URL to a remote resource. If resources on a server move to another address, the base URL can be easily updated in one place. All links based on this URL are automatically updated.

Java Elements in Javadoc

 

To reference the a class, specify the name of the class like this:

com.example.something.MyClass

The following example references a method aMethod():

com.example.something.MyClass.aMethod()

Here an example referencing a method aMethod(String, Class<?>) with generics:

com.example.something.MyClass.aMethod(java.lang.String, java.lang.Class)

Note to specify the parameters fully qualified and that generic type parameters or wildcards are not part of the reference.

Export - optionally

Not all stakeholders may have access to the team collaboration platform. In this case wiki pages can be exported to Word or PDF using the Scroll Office Add-on by K15t.

The exported page is then treated as a record that does not demand to be updated. But it can easily be transferred to remote parties.

Summary

In our short tour we have introduced tools to put information to source files and build tools to aggregate and export this information.

With the use of Confluence as the information hub and the projectdoc Toolbox this information can be easily accessed by the team to write documentation in an agile way!

Writing documentation based on living documentation is actually quite easy and a lot of fun!

Give it a try!

Resources

More information on this topic.

Articles & Books

A list of articles and books on living documentation and related topics.

Living Documentation – Tools at Hand
Article on our blog (May 2015).
Specification by Example
Gojko Adzic presents case studies (of over 50 projects) of how successful Lean and Agile teams design, develop, test and deliver software efficiently.
Living Documentation
The book by Cyrille Martraire explains the theory of living documentation and describes a number of techniques, with illustrations and concrete examples.
Agile Documenation
Agile documentation is not another buzzword. There is actually a set of rules to follow which will lead to meaningful documentation. Writing helpful documentation is not easy, but it gets a lot easier with the agile mindset - and with the projectdoc Toolbox.

smartics Plugins for Maven

Plugins for Maven to create or bundle artifacts based on source code information.

Projectmetadata Maven Plugin
Collects and packages metadata about the project and attaches the artifact containing this metadata to the build.
Buildmetadata Maven Plugin
Generates build metadata and provides it as Maven build properties. The properties are written to a properties file that can be included in the generated artifact. The information can also be added to the manifest file.
Enterprise Architect Maven Plugin
Integrates the Enterprise Architect (Sparx Systems) into a Maven build process. This allows to export diagrams to be used for documentation in other tools, such as projectdoc.

smartics Libraries for Java

Libraries for Java to export information from the source.

smartics Exceptions
Library for Java to define exceptions and exception codes. This project addresses services for exception handling commonly required for applications, be them standalone or distributed multi-tier enterprise applications.
smartics Properties
A library for Java to declare and define properties and to access them from an application in a convenient way.