[go: up one dir, main page]

Menu

[19eff1]: / docs / index.html  Maximize  Restore  History

Download this file

316 lines (244 with data), 23.3 kB

  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
311
312
313
314
315
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>ClammingPy doc</title>
<link rel="logo icon" href="./statics/clamming32x32.ico" />
<link rel="stylesheet" href="./Whakerexa-1.0/wexa_statics/css/wexa.css" type="text/css" />
<link rel="stylesheet" href="./Whakerexa-1.0/wexa_statics/css/layout.css" type="text/css" />
<link rel="stylesheet" href="./Whakerexa-1.0/wexa_statics/css/book.css" type="text/css" />
<link rel="stylesheet" href="./Whakerexa-1.0/wexa_statics/css/menu.css" type="text/css" />
<link rel="stylesheet" href="./Whakerexa-1.0/wexa_statics/css/code.css" type="text/css" />
<link rel="stylesheet" href="./statics/clamming.css" type="text/css" />
<script src="./Whakerexa-1.0/wexa_statics/js/wexa.js" type="module"></script>
<script src="./Whakerexa-1.0/wexa_statics/js/whakerpy/request.js" type="text/javascript"></script>
<script src="./Whakerexa-1.0/wexa_statics/js/book.js" type="application/javascript"></script>
<script type="module">
window.Wexa.OnLoadManager.addLoadFunction(() => {
let book = new Book("main-content");
book.fill_table(false);
});
</script>
</head>
<body class="light">
<header>
<a role="button" class="skip" href="#main-content" aria-label="Go to main content">
Go to main content
</a>
<nav>
<ul>
<li>
<button role="menuitem" class="print-off" onclick="AccessibilityManager.switch_contrast_scheme()" aria-label="Change contrast">
<img class="nav-item-img" src="./Whakerexa-1.0/wexa_statics/icons/contrast_switcher.jpg" alt="Contrast" id="img-contrast"/>
</button>
</li>
<li>
<button class="print-off" role="menuitem" onclick="AccessibilityManager.switch_color_scheme()" aria-label="Change theme color" >
<img class="nav-item-img" src="./Whakerexa-1.0/wexa_statics/icons/theme_switcher.png" alt="Theme" id="img-theme"/>
</button>
</li>
</ul>
</nav>
<h1>ClammingPy 2.0</h1>
<p><img class="small-logo" src="./statics/clamming.png" alt="Software logo"/></p>
<p><a class="external-link" href="https://sourceforge.net/projects/clamming/">https://sourceforge.net/projects/clamming/</a></p>
</header>
<nav id="nav-book" class="side-nav">
<h1>ClammingPy 2.0</h1>
<img class="small-logo center" src="./statics/clamming.png" alt=""/>
<p><a class="external-link" href="https://sourceforge.net/projects/clamming/">https://sourceforge.net/projects/clamming/</a></p>
<ul>
<li><a role="button" tabindex="0" aria-disabled="true"> &crarr; Prev. Module</a></li>
<li><a role="button" tabindex="0" aria-disabled="true"> &uarr; Prev. Class</a></li>
<li><a role="button" tabindex="0" href="index.html"> &#8962; Index</a></li>
<li><a role="button" tabindex="0" aria-disabled="true"> &darr; Next Class</a></li>
<li><a role="button" tabindex="0" aria-disabled="true"> &rdsh; Next Module</a></li>
</ul>
<h2>Table of Contents</h2>
<ul id="toc"></ul>
<hr>
<p><small>Automatically created</small></p><p><small>by <a class="external-link" href="https://clamming.sf.net">ClammingPy</a></small></p>
</nav>
<main id="main-content">
<section id="readme">
<h1>ClammingPy Description</h1>
<h2>Overview</h2>
<blockquote>
<p>ClammingPy is a Light Python-API Documentation in Markdown and accessible HTML</p>
</blockquote>
<h3>Typical use</h3>
<p>You have a Python API you documented with docstrings, and you want to share documentation in either Markdown or HTML.
ClammingPy is the documentation generator you may need: it is generating Markdown or HTML from the docstrings within the source code of any Python library.</p>
<blockquote>
<p>ClammingPy generates HTML-5 with a high level of WCAG 2.1 conformity.</p>
</blockquote>
<h3>Features</h3>
<p>Python modules are usually documented using docstrings. They typically use plain text markup formats such as reStructuredText (reST, the markup used for writing the official Python documentation) and/or Markdown.
<code>ClammingPy</code> is a Python, free, open-source, self-hosted library to export a Python class or module into a Markdown and/or HTML files, for documentation purpose. Contrariwise to other documentation tools, docstrings are analyzed with <strong>flexibility rather than completeness...</strong></p>
<blockquote>
<p>Both ReST and Epydoc field styles are supported. It means that either ':field:' or '@field:' can be used indifferently, with upper- or lower- cases.</p>
</blockquote>
<p>Two very useful reST non-standard field items can also be used in the docstrings: <code>:example:</code> and <code>:code:</code>.
Finally, some variants in field names are supported:</p>
<ul>
<li><code>:return:</code> or <code>:returns:</code> are both interpreted the same way;</li>
<li><code>:raise:</code> or <code>:raises:</code> or <code>:catch:</code> or <code>:except:</code> are all interpreted the same way.</li>
</ul>
<h3>Main advantages</h3>
<ul>
<li>easily customizable: it's a pure python library in Object-Oriented Programming</li>
<li>open-source: easily add new features and functionalities </li>
<li>scalable: no limit to support numerous modules</li>
<li>inclusive: the documentation is highly WCAG 2.1 compliant</li>
</ul>
<h2>Install ClammingPy</h2>
<p>Get it here: <a href="https://sourceforge.net/projects/clamming/">https://sourceforge.net/projects/clamming/</a>.</p>
<p>ClammingPy requires Whakerexa to be installed; it can be downloaded from: <a href="https://whakerexa.sourceforge.io">https://whakerexa.sourceforge.io</a>.</p>
<h3>From pypi</h3>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">ClammingPy</span>
</code></pre></div>
<h3>From the repo:</h3>
<p>Download the repository and unpack it. ClammingPy tool includes the following folders and files:</p>
<ol>
<li><code>clamming</code>: the source code of <code>ClammingPy</code> library</li>
<li><code>docs</code>: the documentation of clamming library in HTML, already including "wexa_statics".</li>
<li><code>tests</code>: unittest of <code>Clamming</code> library</li>
<li><code>sample</code>: a sample class <code>Vehicle</code> to illustrate <code>clamming</code> use</li>
<li><code>makedoc.py</code>: create the ClammingPy documentation, using <code>clamming</code> library</li>
<li><code>etc</code>: etcetera!</li>
</ol>
<h3>From the package:</h3>
<p>Install it in your python environment from the local wheel with:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">dist</span><span class="o">/&lt;</span><span class="n">clamming</span><span class="o">.</span><span class="n">whl</span><span class="o">&gt;</span>
</code></pre></div>
<h2>Quick start</h2>
<h3>Documenting a single class</h3>
<p>The <code>sample</code> folder contains a Python class example and the simplest solution to get access to the documentation either in Markdown or HTML. The <code>Vehicle</code> class is illustrating the supported format and its flexibility. Try it with:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">cd</span> <span class="n">sample</span>
<span class="o">&gt;</span> <span class="n">python</span> <span class="n">makedoc_vehicle</span><span class="o">.</span><span class="n">py</span> <span class="o">&gt;</span> <span class="n">vehicle</span><span class="o">.</span><span class="n">html</span>
<span class="o">&gt;</span> <span class="n">python</span> <span class="n">makedoc_vehicle</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">md</span> <span class="o">&gt;</span> <span class="n">vehicle</span><span class="o">.</span><span class="n">md</span>
</code></pre></div>
<p>or with the main program:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">c</span> <span class="n">Vehicle</span> <span class="o">-</span><span class="n">m</span> <span class="n">sample</span><span class="o">.</span><span class="n">vehicle</span>
<span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">c</span> <span class="n">Vehicle</span> <span class="o">-</span><span class="n">m</span> <span class="n">sample</span><span class="o">.</span><span class="n">vehicle</span> <span class="o">--</span><span class="n">md</span>
</code></pre></div>
<p>In the same way, the documentation of any Python class can be extracted with, for example:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">c</span> <span class="n">TestCase</span> <span class="o">-</span><span class="n">m</span> <span class="n">unittest</span> <span class="o">--</span><span class="n">md</span>
<span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">c</span> <span class="n">BaseHTTPRequestHandler</span> <span class="o">-</span><span class="n">m</span> <span class="n">http</span><span class="o">.</span><span class="n">server</span> <span class="o">--</span><span class="n">md</span>
</code></pre></div>
<p>When using the <code>ClammingPy</code> library directly, the documented files can be obtained with the following Python code:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">import</span><span class="w"> </span><span class="nn">clamming</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">import</span><span class="w"> </span><span class="nn">Vehicle</span> <span class="c1"># Or any other Python class to be documented</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">parser</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ClammingClassParser</span><span class="p">(</span><span class="n">Vehicle</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">clams</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ClamsClass</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nb">print</span><span class="p">(</span><span class="n">clams</span><span class="o">.</span><span class="n">html</span><span class="p">())</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nb">print</span><span class="p">(</span><span class="n">clams</span><span class="o">.</span><span class="n">markdown</span><span class="p">())</span>
</code></pre></div>
<h3>Documenting all classes of a module</h3>
<p>Below are two examples with the main program:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">m</span> <span class="n">clamming</span> <span class="o">&gt;</span> <span class="n">clamming</span><span class="o">.</span><span class="n">html</span>
<span class="o">&gt;</span> <span class="n">python</span> <span class="n">main</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">m</span> <span class="n">http</span><span class="o">.</span><span class="n">server</span> <span class="o">--</span><span class="n">md</span> <span class="o">|</span> <span class="n">grep</span> <span class="s2">&quot;### Class &quot;</span>
<span class="c1">### Class `HTTPServer`</span>
<span class="c1">### Class `ThreadingHTTPServer`</span>
<span class="c1">### Class `BaseHTTPRequestHandler`</span>
<span class="c1">### Class `SimpleHTTPRequestHandler`</span>
<span class="c1">### Class `CGIHTTPRequestHandler`</span>
</code></pre></div>
<p>The following Python code allows to generate the documentation of <code>clamming</code>
module in Mardown format or in HTML format as a standalone content:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">import</span><span class="w"> </span><span class="nn">clamming</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">clams_pack</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ClamsPack</span><span class="p">(</span><span class="n">clamming</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nb">print</span><span class="p">(</span><span class="n">clams_pack</span><span class="o">.</span><span class="n">markdown</span><span class="p">())</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nb">print</span><span class="p">(</span><span class="n">clams_pack</span><span class="o">.</span><span class="n">html</span><span class="p">())</span>
</code></pre></div>
<p>Here is a summary of the main steps to generate an HTML documentation, in a bunch of HTML files:</p>
<div class="highlight"><pre><span></span><code><span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="kn">import</span><span class="w"> </span><span class="nn">clamming</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># Options for HTML exportation</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">html_export</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ExportOptions</span><span class="p">()</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">html_export</span><span class="o">.</span><span class="n">software</span> <span class="o">=</span> <span class="s1">&#39;ClammingPy &#39;</span> <span class="o">+</span> <span class="n">clamming</span><span class="o">.</span><span class="n">__version__</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># Create an HTML page for each class of the module</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">clams_pack</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ClamsPack</span><span class="p">(</span><span class="n">clamming</span><span class="p">)</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">clams_pack</span><span class="o">.</span><span class="n">html_export_clams</span><span class="p">(</span><span class="s2">&quot;docs&quot;</span><span class="p">,</span> <span class="n">html_export</span><span class="p">)</span>
</code></pre></div>
<h3>Documenting all classes of a list of modules</h3>
<p>There is an all-in-one function to generate the HTML documentation of a list of packages. It requires to define the followings:</p>
<ol>
<li>The list of ClamsPack instances of the modules to be documented;</li>
<li>The HTMLDocExport allowing to fix the HTML options for files exportation.</li>
</ol>
<div class="highlight"><pre><span></span><code><span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="kn">import</span><span class="w"> </span><span class="nn">clamming</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># List of modules to be documented.</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">packages</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">packages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">clamming</span><span class="p">)</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># Options for HTML exportation</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">html_export</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ExportOptions</span><span class="p">()</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">html_export</span><span class="o">.</span><span class="n">wexa_statics</span> <span class="o">=</span> <span class="s1">&#39;../Whakerexa-1.0/wexa_statics&#39;</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">html_export</span><span class="o">.</span><span class="n">software</span> <span class="o">=</span> <span class="s1">&#39;ClammingPy &#39;</span> <span class="o">+</span> <span class="n">clamming</span><span class="o">.</span><span class="n">__version__</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># Export documentation to HTML files into the &quot;docs&quot; folder.</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">m</span> <span class="o">=</span> <span class="n">clamming</span><span class="o">.</span><span class="n">ClamsModules</span><span class="p">(</span><span class="n">packages</span><span class="p">)</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">m</span><span class="o">.</span><span class="n">html_export_packages</span><span class="p">(</span><span class="s2">&quot;docs&quot;</span><span class="p">,</span> <span class="n">html_export</span><span class="p">)</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="c1"># Export documentation to Markdown files into the &quot;docs&quot; folder.</span>
<span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="n">m</span><span class="o">.</span><span class="n">markdown_export_packages</span><span class="p">(</span><span class="s2">&quot;docs&quot;</span><span class="p">)</span>
</code></pre></div>
<p>See <code>makedoc.py</code> Python script for details.</p>
<blockquote>
<p>See the ClammingPy documentation in <code>docs</code> folder for extended usages.</p>
</blockquote>
<h2>Browse the documentation</h2>
<p>Starting from Whakerexa 1.0, browsing the HTML documentation of <code>ClammingPy</code>
requires running an HTTP server. This can easily be done with <strong>uWSGI</strong>
(for instance, using WSL under Windows):</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Install the required external libraries:</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">pycryptodome</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">uwsgi</span>
<span class="c1"># Launch the HTTP service:</span>
<span class="n">uwsgi</span> <span class="o">--</span><span class="n">http</span> <span class="p">:</span><span class="mi">9090</span> <span class="o">--</span><span class="n">wsgi</span><span class="o">-</span><span class="n">file</span> <span class="n">uwsgi</span><span class="o">.</span><span class="n">py</span>
</code></pre></div>
<p>An example <code>uwsgi.py</code> minimal file is available in the <code>docs</code> folder.</p>
<h2>How to cite ClamminPy</h2>
<p>By using ClammingPy, you are encouraged to mention it in your publications
or products, in accordance with the best practices of the AGPL license.</p>
<p>Use one of the following reference to cite ClammingPy:</p>
<blockquote>
<p>Brigitte Bigi. ClammingPy - Light Python-API Documentation in Markdown and HTML,
Version 2.0. 2025. <a href="https://hal.science/hal-04392103">https://hal.science/hal-04392103</a></p>
</blockquote>
<h2>Projects using ClammingPy</h2>
<ul>
<li>WhakerPy: <a href="https://whakerpy.sf.net">https://whakerpy.sf.net</a></li>
<li>WhintPy: <a href="https://whintpy.sourceforge.io">https://whintpy.sourceforge.io</a></li>
<li>AudiooPy: <a href="https://audioopy.sf.net">https://audioopy.sf.net</a></li>
<li>PyMancala: <a href="https://pymancala.sf.net">https://pymancala.sf.net</a></li>
<li>SPPAS: <a href="https://sppas.org/api/index.html">https://sppas.org/api/index.html</a></li>
<li><em>contact the author if you want to add a project here</em></li>
</ul>
<h2>Help / How to contribute</h2>
<p>If you plan to contribute to the code or to report a bug, please send an e-mail to the author.
Any and all constructive comments are welcome.</p>
<h2>License/Copyright</h2>
<p>See the accompanying LICENSE and AUTHORS files for the full list of contributors.</p>
<p>Copyright (C) 2023-2025 - <a href="https://sppas.org/bigi/">Brigitte Bigi</a> - <a href="&#109;&#x61;&#x69;&#108;&#x74;&#x6f;&#58;&#x63;&#x6f;&#x6e;&#x74;&#x61;&#x63;&#116;&#64;s&#112;&#x70;&#x61;&#115;&#x2e;&#x6f;&#x72;&#x67;">&#x63;&#x6f;&#x6e;&#x74;&#x61;&#x63;&#116;&#64;s&#112;&#x70;&#x61;&#115;&#x2e;&#x6f;&#x72;&#x67;</a>, CNRS,
Laboratoire Parole et Langage, Aix-en-Provence, France</p>
<p>This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.</p>
<p>You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.</p>
</section>
<h1>List of packages:</h1>
<h2>clamming</h2>
<p><a href='clamming.html'>Get documentation</a></p>
<h2>tests</h2>
<p><a href='tests.html'>Get documentation</a></p>
</main>
<footer>
<p class="copyright">Copyright (C) 2023-2025 Brigitte Bigi, CNRS, Laboratoire Parole et Langage, Aix-en-Provence, France</p>
</footer>
</body>
</html>