Sphinx "matlabdomain" extension
Project description
This package contains the MATLAB Sphinx domain and autodoc extensions.
Installation
Use Pip, Setuptools Easy Install or Python Distributions Utilities (Distutils).
Pip:
~$ pip install -U sphinxcontrib-matlabdomain
Easy Install:
~$ easy_install -U sphinxcontrib-matlabdomain
Distutils:
~/downloads$ curl https://pypi.python.org/packages/source/s/sphinxcontrib-matlabdomain/sphinxcontrib-matlabdomain-0.X.tar.gz ~/downloads$ tar -xf sphinxcontrib-matlabdomain-0.X.tar.gz ~/downloads$ cd sphinxcontrib_matlabdomain-0.X ~/downloads/sphinxcontrib_matlabdomain-0.X$ python setup.py install
Requirements
This package is an extension to Sphinx.
Usage
In general usage is the same as for documenting Python code.
Configuration
In your Sphinx conf.py file add sphinxcontrib.matlab to the list of extensions. To use auto-documentation features, also add sphinx.ext.autodoc to the list of extensions.
In order for the Sphinx MATLAB domain to auto-document MATLAB source code, set the config value of matlab_src_dir to the absolute path instead of adding them to sys.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.
Roles and Directives
Please see Sphinx Domains and sphinx.ext.autodoc for documentation on the use of roles and directives. MATLAB code can be documented using the following roles and directives:
Directive |
MATLAB object |
---|---|
.. module:: foldername |
folders, packages and namespaces |
.. curremtmodule:: foldername |
|
.. automodule:: foldername |
|
:mod:`foldername` |
|
.. function:: funcname |
function definition and signature |
.. autofunction:: funcname() |
|
:func:`funcname` |
|
.. class:: classname() |
class definition and optional signature |
.. autoclass:: classname |
|
:class:`classname` |
|
.. method:: methname() |
method definition and signature |
.. automethod:: methname |
|
:meth:`methname` |
|
.. staticmethod:: statmethname() |
static method definition and signature |
.. automethod:: statmethname |
|
:meth:`methname` |
|
.. attribute:: attrname |
property definition |
.. autoattribute:: attrname |
|
:attr:`attrname` |
|
Several options are available for auto-directives.
:members: auto-document public members
:show-inheritance: list bases
:undoc-members: document members without docstrings
:annotation: specifies attribute annotation instead of default
There are also several config values that can be set in conf.py that will affect auto-docementation.
autoclass_content can be set to class, both or init, which determines which docstring is used for classes. The constructor docstring is used when this is set to init.
autodoc_member_order can be set to alphabetical, groupwise or bysource.
autodoc_default_flags can be set to a list of options to apply. Use the no-flag directive option to disable this config value once.
Example: given the following MATLAB source in folder test_data:
classdef MyHandleClass < handle & my.super.Class % a handle class % % :param x: a variable %% some comments properties x % a property end methods function h = MyHandleClass(x) h.x = x end function x = get.x(obj) % how is this displayed? x = obj.x end end methods (Static) function w = my_static_function(z) % A static function in :class:`MyHandleClass`. % % :param z: input z % :returns: w w = z end end end
Use the following to document:
Test Data ========= This is the test data module. .. automodule:: test_data :mod:`test_data` is a really cool module. My Handle Class --------------- This is the handle class definition. .. autoclass:: MyHandleClass :show-inheritance: :members:
Online Demo
The test docs in the repository are online here: http://bwanamarko.alwaysdata.net/matlabdomain/
Users
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 Distribution
Built Distributions
Hashes for sphinxcontrib-matlabdomain-0.2.14.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2be2cd3c6f355200cedafe3d3243c7e307b3bac2da9f5376aeffa106888c2bac |
|
MD5 | 6cf5d822fcb5c61df73271a317fecb5a |
|
BLAKE2b-256 | 504ca7630b6fd87df2f66001a9dd1a0fda51cf7162b415137ea6aaecbd1472b7 |
Hashes for sphinxcontrib_matlabdomain-0.2.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f1f005fa4cf513ae955c7c3e640862409e6f1d19e7af4bdcc216ff1e7920d7 |
|
MD5 | c19c1ef403b32e40cf54665b1abd26d5 |
|
BLAKE2b-256 | f11422981c81a646e9283abc654c6fec88ec6c4c973771254a07e9191a007c0d |
Hashes for sphinxcontrib_matlabdomain-0.2.14-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adfedda7ec869dcfc7c376ac2a50e7dcca6b6fb5fdf0090068e46e379f45610d |
|
MD5 | aa24fe8420bae8b9bb7793df305db09c |
|
BLAKE2b-256 | 27cc0a4a19cfe8002746b55dd702e2d9e5983593bee50adee684a1d2b935fd1c |