-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExtensionsAPI.html
137 lines (114 loc) · 6.61 KB
/
ExtensionsAPI.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Concordion - Extensions API</title>
<link media="all" rel="stylesheet" type="text/css" href="css/default.css"/>
<link media="print" rel="stylesheet" type="text/css" href="css/print.css"/>
<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
<style>
#specFixtureSystem {
padding: 20px 20px 20px 64px;
}
.exampleTable table {
border-collapse: collapse;
empty-cells: show;
margin: 8px 0px 8px 0px;
}
.exampleTable th, .exampleTable td {
border: 1px solid #966;
padding: 3px;
background-color: #ffe4e4;
}
</style>
</head>
<body id="extensions">
<div class="page">
<div class="header">
<div id="google_translate_element" class="language-translation"></div>
<div class="logo"><a href="index.html"> <img src="image/front-page-banner.png" alt="Specification by Example" /> </a></div>
</div><!-- header -->
<div class="menuBar">
<ul class="menu">
<li><a href="/">Home</a></li>
<li><a href="Example.html">Example</a></li>
<li><a href="Tutorial.html">Tutorial</a></li>
<li><a href="Technique.html">Hints and Tips</a></li>
<li class="selectedTab"><a href="ExtensionsAPI.html">Extensions API</a></li>
<li><a href="Extensions.html">Extensions</a></li>
<li><a href="Download.html">Download</a></li>
<li><a href="Questions.html">FAQ</a></li>
</ul>
</div><!-- menuBar -->
<div class="content">
<h1>Extensions API</h1>
<p class="subtext">
The Extensions API allows you to add functionality to Concordion, for example implementing new commands, listening to events, or modifying the Concordion output.</p>
<p>For full details, see the <a href="dist/1.5.1/spec/concordion/extension/Extension.html">specifications</a>, the
classes in <a class="externalLink" href="https://github.com/concordion/concordion/tree/master/src/main/java/org/concordion/api/extension">org.concordion.api.extension</a>
and the <a class="externalLink" href="https://github.com/concordion/concordion/tree/master/src/test/resources/spec/concordion/extension">fixtures that demonstrate it</a>.
</p>
<p>
See also the source code of the extensions listed on the <a href="Extensions.html">extensions</a> page</a>.
</p>
<h2><a name="add"/>Adding extensions to Concordion</h2>
<p>Extensions are added to Concordion by:</p>
<ul>
<li>Annotating the fixture class with <code>@org.concordion.api.extension.Extensions</code>. This annotation is parameterised with a list of extension, and/or extension factory, classes to be installed.
For example:</p>
<pre class="java">@RunWith(ConcordionRunner.class)
@Extensions({LoggingTooltipExtension.class, TimestampFormatterExtension.class})
public class MyTest {
...</pre>
</li>
<li><b>Or</b> annotating public fields in the fixture class with <code>@org.concordion.api.extension.Extension</code>. This allows the extensions to be configured per class instance. For example:</p>
<pre class="java">...
@Extension
public ConcordionExtension extension = new ScreenshotExtension().setScreenshotTaker(camera);
...</pre>
</li>
<li><b>Or</b> by setting the system property <code>"concordion.extensions"</code> to a comma separated list of extension, and/or extension factory, classes. For example:
<pre class="console">java -Dconcordion.extensions="org.concordion.ext.LoggingTooltipExtension,com.acme.Extra"</pre>
</li>
</ul>
<p>For further details see the <a href="dist/1.5.1/spec/concordion/extension/ExtensionConfiguration.html">extension configuration</a> specification.</p>
<h2><a name="build"/>Building your own extension</h2>
<p>Extensions must implement the <a href="https://github.com/concordion/concordion/blob/master/src/main/java/org/concordion/api/extension/ConcordionExtension.java">ConcordionExtension</a> interface,
which allows extensions to hook into the Concordion build phase through the <a href="https://github.com/concordion/concordion/blob/master/src/main/java/org/concordion/api/extension/ConcordionExtender.java">ConcordionExtender</a> interface.</p>
<h3><a name="cssExample"/>Example: Adding custom CSS</h3>
<p>Amongst other features, the <code>ConcordionExtender</code> interface provide a means for adding CSS, JavaScript or arbitrary resources to the Concordion output folder.</p>
<p>The following example extension copies <code>/my_concordion.css</code> from the classpath to the root folder of the Concordion output, and links to it from the Concordion output HTML.</p>
<pre class="java">
package com.acme;
public class MyCssExtension implements ConcordionExtension {
@Override
public void addTo(ConcordionExtender concordionExtender) {
concordionExtender.withLinkedCSS("/my_concordion.css",
new Resource("/my_concordion.css"));
}
}
</pre>
<p>Note: if you have already declared a link to the CSS file in your HTML, you should use <code>concordionExtender.withResource()</code> rather than <code>concordionExtender.withLinkedCSS()</code> to avoid a duplicate declaration.</code></p>
<p>If you'd prefer to embed the CSS in the HTML, use <code>concordionExtender.withEmbeddedCSS()</code>. Similar methods exist for including JavaScript in the output, or you can use <code>withResource()</code> to copy images or other resources to the output.</p>
</div> <!-- content -->
</div> <!-- page -->
<div class="copyright">
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
</div> <!-- copyright -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-58172036-1', 'auto');
ga('send', 'pageview');
</script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, gaTrack: true, gaId: 'UA-58172036-1'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</body>
</html>