Skip to content

concordion/concordion-api-documentation-extension

Repository files navigation

Build Status codecov Apache License 2.0 Download

Executable Documentation with Concordion

Tired of writing documentation for your library? This Concordion plugin can help!

  • Never again miss API changes in your documentation!
  • Include real code output in your documentation! No more "copy and paste from some old version"!
  • Embed code (Groovy) as part of the specification that gets executed in the tests!
  • Syntax highlighting by highlight.js
  • xhtml and Markdown!

HOWTO

To enable extensions use the annotation @Extensions(ExecutableSpecExtension.class).  

Maven

 <dependency>
  <groupId>org.concordion</groupId>
  <artifactId>concordion-api-documentation-extension</artifactId>
  <version>0.0.4</version>
  <type>pom</type>
</dependency>

Gradle

compile 'org.concordion:concordion-api-documentation-extension:0.0.4'

Examples

Screenshot

Browse the tests for examples. Here are the appetizers!

Scripts do not need to return values

```groovy
import ExecutableSpecExtension

System.out.println("Namespace: " + ExecutableSpecExtension.NAMESPACE);
System.out.println("OUT 1");
System.err.println("ERR 1");
System.out.println("OUT 2");
System.err.println("ERR 2");
```
@RunWith(ConcordionRunner.class)
@Extensions(ExecutableSpecExtension)
class ExecutableSpecReturnsValuesMarkdownTest {
  // no code needed for this
}

Scripts with native format can return values

```groovy result:#returnValue

return 7*7

```

This script returns [49]( - "?=#returnValue") (this check is verified as part of the specification)!

Compile Errors fail the test

```groovy
xxxCompiler error;
System.out.println("We should never get here!");
```

Skip compilation/execution

```groovy run:no
xxxCompiler error;
System.out.println("We should never get here!");
```

Other languages (without execution)

``` shell
total 0
drwxr-xr-x@ 3 root  wheel  102 Nov 25  2016 ..
drwxr-xr-x@ 5 jens  staff  170 Aug 10 15:35 .
drwx------@ 9 jens  staff  306 Aug 10 16:42 demo
```

Thanks

The base skeleton (e.g. build system) has been copied from https://github.com/concordion/concordion-input-style-extension-demo