Installation

This guide will help you install sphinxcontrib-matlabdomain, even if you’ve never used Sphinx before.

Prerequisites

Before installing, make sure you have:

  • Python 3.8 or higher

  • pip (Python package installer)

You can check your Python version with:

python --version

Installing sphinxcontrib-matlabdomain

Basic Installation

Install the package using pip:

pip install sphinxcontrib-matlabdomain

This will automatically install all required dependencies including:

  • Sphinx (≥4.0.0)

  • tree-sitter-matlab

  • tree-sitter

Verifying Installation

To verify the installation was successful, run:

python -c "import sphinxcontrib.matlab; print('Installation successful!')"

You should see “Installation successful!” printed.

What Gets Installed?

When you install sphinxcontrib-matlabdomain, you get:

  1. The Sphinx extension - For documenting MATLAB code in Sphinx projects

  2. sphinx-matlab-apidoc - A command-line tool for bulk documentation generation

  3. MATLAB lexer - Syntax highlighting for MATLAB code blocks

  4. Tree-sitter parser - Fast and accurate MATLAB code parsing

Next Steps

Now that you have sphinxcontrib-matlabdomain installed, you can:

Installing Sphinx Separately

If you already have a Sphinx project and just want to add MATLAB support, the basic installation above is all you need. Then add 'sphinxcontrib.matlab' to your extensions list in conf.py.

If you’re starting from scratch, see Your First Project for complete setup instructions.

Troubleshooting

Installation Fails

If installation fails, try upgrading pip first:

pip install --upgrade pip
pip install sphinxcontrib-matlabdomain

ImportError After Installation

If you get an ImportError when trying to use the extension, make sure:

  1. You activated your virtual environment (if using one)

  2. You’re using the correct Python interpreter

  3. The package was installed in the right environment

You can check where packages are installed:

pip show sphinxcontrib-matlabdomain

Python Version Issues

This extension requires Python 3.8 or higher. If you have an older Python version, you can:

  1. Install a newer Python version from python.org

  2. Use version 0.11.8 which supports Python 2:

    pip install sphinxcontrib-matlabdomain==0.11.8