maxx (MATLAB Language Tools) is a Python library for parsing and analyzing MATLAB code. It provides comprehensive support for extracting signatures, documentation, and metadata from MATLAB projects including functions, classes, scripts, and packages.
- ๐ Parse MATLAB files - Extract functions, classes, properties, and methods
- ๐ Project structure analysis - Handle MATLAB packages, namespaces, and class folders
- ๐ Documentation extraction - Parse docstrings and comments from MATLAB code
- ๐ฏ Type information - Extract argument types, validation functions, and return types
- ๐ณ Tree-sitter based - Fast and accurate parsing using tree-sitter-matlab
- ๐ Integration ready - Built for documentation generators like MkDocs
Using pip
:
pip install maxx
Using uv
:
uv add maxx
from pathlib import Path
from maxx.treesitter import FileParser
# Parse a MATLAB function file
parser = FileParser(Path("myfunction.m"))
matlab_object = parser.parse()
print(f"Object type: {matlab_object.kind}")
print(f"Name: {matlab_object.name}")
print(f"Arguments: {matlab_object.arguments}")
print(f"Docstring: {matlab_object.docstring}")
from maxx.collection import PathsCollection
from pathlib import Path
# Collect all MATLAB objects from a project
paths = PathsCollection([Path("src"), Path("examples")])
# Access parsed objects
my_function = paths["myfunction"]
my_class = paths["MyClass"]
my_package = paths["+mypackage.MyFunction"]
# Access class members
matlab_class = paths["MyClass"]
print(f"Base classes: {matlab_class.bases}")
print(f"Properties: {list(matlab_class.members.keys())}")
# Access methods and properties
constructor = matlab_class.constructor
properties = [m for m in matlab_class.members.values() if m.is_property]
- Functions - Regular functions, nested functions, methods
- Classes - Class definitions, properties, methods, inheritance
- Scripts - Script files and their documentation
- Packages - Namespace packages (
+package
) and class folders (@class
) - Arguments blocks - Input/output validation and type information
- Properties blocks - Class properties with attributes and validation
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.