Light Python-API Documentation in Markdown and HTML
Project description
ClammingPy - Light Python-API Documentation in Markdown and HTML
Overview
ClammingPy
is an open-source library useful to export a Python class
into
a Markdown or HTML file, for documentation purpose. ClammingPy
mainly
supports reStructured format, however, docstrings are analyzed with
flexibility rather than completeness...
Both ReST and Epydoc field styles are supported. It means that either :field: or @field: can be used indifferently, with upper- or lower- cases.
Two very useful non-standard "field list" items are added: :example:
and :code:
. Finally, some variants in field names are supported:
:return:
or:returns:
are both interpreted the same way;:raise:
or:raises:
or:catch:
or:except:
are all interpreted the same way.
Notice that we expect to generate HTML-5 with a high level of WCAG 2.1 conformity.
Install ClammingPy
ClammingPy requires Whakerexa to be installed; it can be downloaded from: https://whakerexa.sf.net. Unpack it into the ClammingPy package.
From the repo:
Download the repository and unpack it. ClammingPy tool includes the following folders and files:
clamming
: the source code ofClammingPy
librarydocs
: the documentation of clamming library in HTML, already including "wexa_statics".tests
: unittest ofClamming
librarysample
: a sample classVehicle
to illustrateclamming
usemakedoc.py
: create the ClammingPy documentation, usingclamming
libraryetc
: etcetera!
From the package:
Install it in your python environment from the local wheel with:
> python -m pip install dist/<clamming.whl>
License
This is the implementation of the ClammingPy
library, under the terms of the GNU General Public License version 3.
Usage
Documenting a single class
The sample
folder contains a Python class example and the simplest solution to get access to the documentation either in Markdown or HTML. The Vehicle
class is illustrating the supported format and its flexibility. Try it with:
> cd sample
> python makedoc_vehicle.py > vehicle.html
> python makedoc_vehicle.py --md > vehicle.md
or with the main program:
> python main.py -c Vehicle -m sample.vehicle
> python main.py -c Vehicle -m sample.vehicle --md
In the same way, the documentation of any Python class can be extracted with, for example:
> python main.py -c TestCase -m unittest --md
> python main.py -c BaseHTTPRequestHandler -m http.server --md
When using the ClammingPy
library directly, the documented files can be obtained with the following Python code:
>>> import clamming
>>> import Vehicle # Or any other Python class to be documented
>>> parser = clamming.ClammingClassParser(Vehicle)
>>> clams = clamming.ClamsClass(parser)
>>> print(clams.html())
>>> print(clams.markdown())
Documenting all classes of a package
Below are two examples with the main program:
> python main.py -m clamming > clamming.html
> python main.py -m http.server --md | grep "### Class "
### Class `HTTPServer`
### Class `ThreadingHTTPServer`
### Class `BaseHTTPRequestHandler`
### Class `SimpleHTTPRequestHandler`
### Class `CGIHTTPRequestHandler`
The following Python code allows to generate the documentation of clamming
module in Mardown format or in HTML format as a standalone content:
>>> import clamming
>>> clams_pack = clamming.ClamsPack(clamming)
>>> print(clams_pack.markdown())
>>> print(clams_pack.html())
Here is a summary of the main steps to generate an HTML documentation, in a bunch of HTML files:
>>> import clamming
>>> # Options for HTML exportation
>>> html_export = clamming.HTMLDocExport()
>>> html_export.software = 'ClammingPy ' + clamming.__version__
>>> # Create an HTML page for each class of the module
>>> clams_pack = clamming.ClamsPack(clamming)
>>> clams_pack.html_export_clams("docs", html_export)
Documenting all classes of a list of packages
There is an all-in-one function to generate the HTML documentation of a list of packages. It requires to define the followings:
- The list of ClamsPack instances of the modules to be documented;
- The HTMLDocExport allowing to fix the HTML options for files exportation.
>>> import clamming
>>> # List of modules to be documented.
>>> packages = list()
>>> packages.append(clamming.ClamsPack(clamming))
>>> # Options for HTML exportation
>>> html_export = clamming.HTMLDocExport()
>>> html_export.wexa_statics = '../Whakerexa-0.2/wexa_statics'
>>> html_export.software = 'ClammingPy ' + clamming.__version__
>>> # Export documentation to HTML files into the "docs" folder.
>>> clamming.ClamsPack.html_export_packages(packages, "docs", html_export)
>>> # Export documentation to Markdown files into the "docs" folder.
>>> clamming.ClamsPack.markdown_export_packages(packages, "docs", html_export)
See makedoc.py
Python script for details.
See the ClammingPy documentation in
docs
folder for extended usages.
Projects using ClammingPy
- WhakerPy: https://whakerpy.sf.net
- AudiooPy: https://audioopy.sf.net
- PyMancala: https://pymancala.sf.net
- SPPAS: https://sppas.org
- contact the author if you want to add a project here
Author/Copyright
Copyright (C) 2023-2024 - Brigitte Bigi - contact@sppas.org, Laboratoire Parole et Langage, Aix-en-Provence, France.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file ClammingPy-1.7-py3-none-any.whl
.
File metadata
- Download URL: ClammingPy-1.7-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2601c2be2af46272aedc5cdaad7ffdcf3ba0586e27e3558a2e83f39922bbe25 |
|
MD5 | a5e5d7021554a74206a4a3e21bc7afad |
|
BLAKE2b-256 | 5075452274cc50deab106e3bca730de7bd694ea19bd72334b109ae2b4f4f7369 |