-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlgorithmDocumentation.html
310 lines (260 loc) · 20.6 KB
/
AlgorithmDocumentation.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Algorithm Documentation</title>
<link rel="stylesheet" href="_static/basic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '3.12.20180329.1038',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<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-59110517-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body role="document">
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.mantidproject.org"><img src="_static/Mantid_Logo_Transparent.png">
</a>
<span class="navbar-text navbar-version pull-left"><b>3.12</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="http://www.mantidproject.org">Home</a></li>
<li><a href="http://download.mantidproject.org">Download</a></li>
<li><a href="http://www.mantidproject.org/Documentation">Documentation</a></li>
<li><a href="http://www.mantidproject.org/Contact">Contact Us</a></li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12 content">
<div class="section" id="algorithm-documentation">
<span id="algorithmdocumentation"></span><h1>Algorithm Documentation<a class="headerlink" href="#algorithm-documentation" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#summary" id="id1">Summary</a></li>
<li><a class="reference internal" href="#how-to-document-an-algorithm" id="id2">How to Document an Algorithm</a><ul>
<li><a class="reference internal" href="#the-code-files" id="id3">The Code Files</a></li>
<li><a class="reference internal" href="#property-descriptions" id="id4">Property Descriptions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#workflow-algorithms" id="id5">Workflow algorithms</a></li>
<li><a class="reference internal" href="#algorithm-directives" id="id6">Algorithm Directives</a></li>
<li><a class="reference internal" href="#description" id="id7">Description</a><ul>
<li><a class="reference internal" href="#referencing-other-algorithms" id="id8">Referencing Other Algorithms</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="id9">Usage</a></li>
<li><a class="reference internal" href="#building-the-documentation" id="id10">Building the Documentation</a></li>
</ul>
</div>
<div class="section" id="summary">
<h2><a class="toc-backref" href="#id1">Summary</a><a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<p>This page deals with the specifics of how to document an algorithm. For a more general guide to the Mantid documentation system see <a class="reference external" href="DocumentationGuideForDevs.html">Documentation Guide For Devs</a>.</p>
</div>
<div class="section" id="how-to-document-an-algorithm">
<h2><a class="toc-backref" href="#id2">How to Document an Algorithm</a><a class="headerlink" href="#how-to-document-an-algorithm" title="Permalink to this headline">¶</a></h2>
<p>Algorithm documentation is stored in two places.</p>
<ul class="simple">
<li>The code (.cpp / .h / .py) files: For strings that are needed in the GUI for tooltips etc.</li>
<li>The .rst file: For all other documentation, including the algorithm description and <a class="reference external" href="AlgorithmUsageExamples.html">usage examples</a>.</li>
</ul>
<div class="section" id="the-code-files">
<h3><a class="toc-backref" href="#id3">The Code Files</a><a class="headerlink" href="#the-code-files" title="Permalink to this headline">¶</a></h3>
<p>The code files hold documentation in two important areas.</p>
<dl class="docutils">
<dt>The <code class="docutils literal"><span class="pre">summary</span></code> method</dt>
<dd>The summary method should return a string (in plain text) that describes in a short sentence the purpose of the algorithm. This is used to provide a summary in the algorithm dialog box and in the algorithm documentation web page.</dd>
</dl>
<p>In C++: (This example uses the .h file, you could of course implement it in the .cpp file)</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="c1">/// Algorithm's name for identification overriding a virtual method</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">name</span><span class="p">()</span> <span class="k">const</span> <span class="k">override</span> <span class="p">{</span> <span class="k">return</span> <span class="s">"Rebin"</span><span class="p">;}</span>
<span class="c1">///Summary of algorithms purpose</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">summary</span><span class="p">()</span> <span class="k">const</span> <span class="k">override</span> <span class="p">{</span><span class="k">return</span> <span class="s">"Rebins data with new X bin boundaries."</span><span class="p">;}</span>
</pre></div>
</div>
</div>
<div class="section" id="property-descriptions">
<h3><a class="toc-backref" href="#id4">Property Descriptions</a><a class="headerlink" href="#property-descriptions" title="Permalink to this headline">¶</a></h3>
<p>Each property declaration in the init method of the .cpp file should include a description. This is used as a tooltip, and in the ‘properties’ table on the algorithm’s documentation web page.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The tooltip may only show the description up to the first dot. Be sure that the first sentence in the description gives enough information to understand the purpose of the property.</p>
</div>
<p>For example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">declareProperty</span><span class="p">(</span>
<span class="k">new</span> <span class="n">WorkspaceProperty</span><span class="o"><></span><span class="p">(</span><span class="s">"InputWorkspace"</span><span class="p">,</span> <span class="s">""</span><span class="p">,</span> <span class="n">Direction</span><span class="o">::</span><span class="n">Input</span><span class="p">),</span>
<span class="s">"Workspace containing the input data"</span><span class="p">);</span>
<span class="n">declareProperty</span><span class="p">(</span>
<span class="k">new</span> <span class="n">WorkspaceProperty</span><span class="o"><></span><span class="p">(</span><span class="s">"OutputWorkspace"</span><span class="p">,</span><span class="s">""</span><span class="p">,</span><span class="n">Direction</span><span class="o">::</span><span class="n">Output</span><span class="p">),</span>
<span class="s">"The name to give the output workspace"</span><span class="p">);</span>
<span class="n">declareProperty</span><span class="p">(</span>
<span class="k">new</span> <span class="n">ArrayProperty</span><span class="o"><</span><span class="kt">double</span><span class="o">></span><span class="p">(</span><span class="s">"Params"</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">make_shared</span><span class="o"><</span><span class="n">RebinParamsValidator</span><span class="o">></span><span class="p">()),</span>
<span class="s">"A comma separated list of first bin boundary, width, last bin boundary. Optionally "</span>
<span class="s">"this can be followed by a comma and more widths and last boundary pairs. "</span>
<span class="s">"Optionally this can also be a single number, which is the bin width. "</span>
<span class="s">"In this case, the boundary of binning will be determined by minimum and maximum TOF "</span>
<span class="s">"values among all events, or previous binning boundary, in case of event Workspace, or "</span>
<span class="s">"non-event Workspace, respectively. Negative width values indicate logarithmic binning. "</span><span class="p">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="workflow-algorithms">
<h2><a class="toc-backref" href="#id5">Workflow algorithms</a><a class="headerlink" href="#workflow-algorithms" title="Permalink to this headline">¶</a></h2>
<p>There should be a flow chart for workflow algorithms. See <a class="reference external" href="FlowchartCreation.html">here</a> on how to make one.</p>
</div>
<div class="section" id="algorithm-directives">
<h2><a class="toc-backref" href="#id6">Algorithm Directives</a><a class="headerlink" href="#algorithm-directives" title="Permalink to this headline">¶</a></h2>
<p>We have defined several custom directives using the Sphinx extension framework. These are defined to generate the information from an algorithm that is not required to be hand written, i.e the properties table. Each .rst file that is documenting an algorithm should use these directives.</p>
<p>As the <strong>Description</strong> and <strong>Usage</strong> of an algorithm <em>cannot</em> be obtained automatically, it must be manually entered. The structure of an algorithm’s .rst is:</p>
<div class="highlight-rest"><div class="highlight"><pre><span></span><span class="p">..</span> <span class="ow">algorithm</span><span class="p">::</span>
<span class="p">..</span> <span class="ow">summary</span><span class="p">::</span>
<span class="p">..</span> <span class="ow">alias</span><span class="p">::</span>
<span class="p">..</span> <span class="ow">properties</span><span class="p">::</span>
<span class="gh">Description</span>
<span class="gh">-----------</span>
The description of your algorithm here.
<span class="gh">Usage</span>
<span class="gh">-----</span>
A custom usage example.
<span class="p">..</span> <span class="ow">categories</span><span class="p">::</span>
<span class="p">..</span> <span class="ow">sourcelink</span><span class="p">::</span>
</pre></div>
</div>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">..</span> <span class="pre">algorithm</span> <span class="pre">::</span></code></dt>
<dd>This directive has several pieces of functionality, which includes:</dd>
</dl>
<ul class="simple">
<li>A referable link is created for the algorithm. This allows other documentation pages create references to it (e.g. create links to it).</li>
<li>Insertion of the page title (which is the name of the algorithm, including the version).</li>
<li>Insertion of a screenshot of the algorithm’s dialog.</li>
<li>Insertion of the Table Of Contents.</li>
</ul>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">..</span> <span class="pre">summary::</span></code></dt>
<dd>The content of the summary method declared in your algorithm is output as HTML, for example, the following method is used in Rebin:</dd>
</dl>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="c1">/// Summary of algorithms purpose</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">summary</span><span class="p">()</span> <span class="k">const</span> <span class="k">override</span> <span class="p">{</span>
<span class="k">return</span> <span class="s">"Rebins data with new X bin boundaries. For EventWorkspaces, you can very quickly rebin in-place by keeping the same output name and PreserveEvents=true."</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">..</span> <span class="pre">alias::</span></code></dt>
<dd>This directive obtains aliases from the required <code class="docutils literal"><span class="pre">alias</span></code> method in the algorithm, for example, the following method is used in Rebin:</dd>
</dl>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="c1">/// Algorithm's aliases</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">alias</span><span class="p">()</span> <span class="k">const</span> <span class="k">override</span> <span class="p">{</span> <span class="k">return</span> <span class="s">"rebin"</span><span class="p">;</span> <span class="p">}</span>
</pre></div>
</div>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">..</span> <span class="pre">properties::</span></code></dt>
<dd>As mentioned above, it is <em>critical</em> that you include a description for the properties of your algorithm. This directive obtains all of the algorithm’s properties (set inside the algorithm’s <code class="docutils literal"><span class="pre">init</span></code> method) and outputs in a table format.</dd>
<dt><code class="docutils literal"><span class="pre">..</span> <span class="pre">categories::</span></code></dt>
<dd>By default, this directive obtains the categories that were set in the <code class="docutils literal"><span class="pre">categories</span></code> method the algorithm. For example, in Rebin the category method is in the header and contains:</dd>
</dl>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="c1">/// Algorithm's category for identification</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">category</span><span class="p">()</span> <span class="k">const</span> <span class="k">override</span> <span class="p">{</span><span class="k">return</span> <span class="s">"Transforms</span><span class="se">\\</span><span class="s">Rebin"</span><span class="p">;}</span>
</pre></div>
</div>
<p>When the HTML is generate a categories list is built that contains: Algorithms, Transforms and Rebin.</p>
<p>It is possible to add additional categories by passing the directive arguments, for example, the following would output the above categories, and also <cite>Example</cite>:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">..sourcelink</span> <span class="pre">::</span></code></dt>
<dd>This directive adds links to the algorithms source code.</dd>
</dl>
</div>
<div class="section" id="description">
<h2><a class="toc-backref" href="#id7">Description</a><a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p>This section must be manually entered. The description is an extension of the summary, and must contain a detailed overview of the algorithm’s functionality.</p>
<div class="section" id="referencing-other-algorithms">
<h3><a class="toc-backref" href="#id8">Referencing Other Algorithms</a><a class="headerlink" href="#referencing-other-algorithms" title="Permalink to this headline">¶</a></h3>
<p>Every algorithm and version has been marked with a tag that can be used to reference it from other documents. If you need to reference the latest version of an algorithm, e.g. DiffractionFocussing, then in Sphinx you type would type</p>
<div class="highlight-rest"><div class="highlight"><pre><span></span><span class="na">:ref:</span><span class="nv">`DiffractionFocussing <algm-DiffractionFocussing>`</span>
</pre></div>
</div>
<p>If you need to reference a particular version then you would type</p>
<div class="highlight-rest"><div class="highlight"><pre><span></span><span class="na">:ref:</span><span class="nv">`DiffractionFocussing version 2 <algm-DiffractionFocussing-v2>`</span>
</pre></div>
</div>
<p>where the first part outside the angle brackets defines the link text and the part inside the angle brackets references the tag name.</p>
</div>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#id9">Usage</a><a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>This section <em>must</em> be manually entered. The usage is a ‘code’ example of the algorithm in use. The <cite>testcode</cite> directive must be used to verify the usage code you entered works correctly. See <a class="reference external" href="AlgorithmUsageExamples">here</a> for more information on how to write usage examples.</p>
</div>
<div class="section" id="building-the-documentation">
<h2><a class="toc-backref" href="#id10">Building the Documentation</a><a class="headerlink" href="#building-the-documentation" title="Permalink to this headline">¶</a></h2>
<p>One can update the documentation for a particular algorithm after changes have been introduced into the corresponding documentation file. Assuming you are in the build directory and want to update the documentation for Rebin:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">bin</span><span class="o">/</span><span class="n">MantidPlot</span> <span class="o">-</span><span class="n">xq</span> <span class="n">docs</span><span class="o">/</span><span class="n">runsphinx_html</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">R</span> <span class="n">Rebin</span> <span class="c1"># builds HTML documentation</span>
<span class="nb">bin</span><span class="o">/</span><span class="n">MantidPlot</span> <span class="o">-</span><span class="n">xq</span> <span class="n">docs</span><span class="o">/</span><span class="n">runsphinx_qthelp</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">R</span> <span class="n">Rebin</span> <span class="c1"># builds Qt-help documentation</span>
</pre></div>
</div>
<p>or with vanilla python</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>python docs/runsphinx_html.py -m $PWD/bin -R Rebin
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<ul class="nav navbar-nav" style=" float: right;">
<li><a href="#">Back to top</a></li>
</ul>
<p>
</p>
</div>
</footer>
</body>
</html>