sphinxcontrib-matlabdomain¶
sphinxcontrib-matlabdomain is Sphinx extension to generate API documentation for MATLAB, it also provides autodoc facilities, that lets you generate documentation automatically from MATLAB source files. It works similar to the Python Domain.
Getting started¶
If you are completely new to Sphinx, follow this Tutorial.
Install sphinxcontrib-matlabdomain with
pip install sphinxcontrib-matlabdomain
In order for the Sphinx MATLAB domain to auto-document MATLAB source code, set
the config value of matlab_src_dir
to the absolute root path. Currently
only one MATLAB path can be specified, but all subfolders in that tree will be
searched.
For convenience the primary domain
can be set to mat
.
Assuming that the directory structure of the project is ike this:
docs/
conf.py
index.rst
make.bat
Makefile
src
<matlab source files>
The docs/conf.py
would look like this:
import os
# other statements
extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.matlab']
this_dir = os.path.dirname(os.path.abspath(__file__))
matlab_src_dir = os.path.abspath(os.path.join(this_dir, '..'))
primary_domain = 'mat'
Example¶
- src.times_two(x)¶
times_two Multiply a number by two
- Parameters
x – The input value
- Returns
The input value multiplied by two
- src.times_two_napoleon(x)¶
times_two Multiply a number by two
- Parameters
x – The input value
- Returns
The input value multiplied by two
Using auto-directives¶
Creating a Sphinx project
Modifying
conf.py
to include sphinxcontrib-matlabdomain and autodoc.Add
matlab_src_dir
with root of MATLAB sourcesList directives and options
Using auto-directives
Using napoleon - different style docstrings, that are almost like MATLAB
Examples
Function
Function in package
Class with inheritance and properties
Class folder (have to use autofunction)
Known limitations