Skip to main content

malt-index (Python)

The MATLAB search path as a Python module: the functions, classes, properties, enumerations, arguments, packages, folders and live scripts on the path, read by malt's native index (crates/malt_index). It is the first part of the replacement for the Python library maxx, for mkdocstrings-matlab. Nothing is evaluated: every value is a fact read from the source.

The distribution is malt-index and the module is malt_index. It is a separate wheel from malt (the CLI): maturin builds one kind of artifact per project, so a PyO3 module cannot share a wheel with the malt binary.

Licence: MIT. maxx is GPL-3.0; nothing here is copied from it (see malt-index's README).

The package ships type stubs (malt_index/malt_index.pyi) and the py.typed marker, so type checkers see the API above.

Use

from malt_index import PathsCollection, ParserConfig, parse_file, parse_source, parse_live_script

paths = PathsCollection(
    ["src", "lib"],                       # folders, relative to working_directory
    recursive=False,
    working_directory="/path/to/project",
    parser_config=ParserConfig(docstring_before_properties=True),
    parse_live_scripts=False,             # True: .mlx files on the path are live scripts
)

fn = paths["pkg.fn"]                      # KeyError when the name is not on the path
fn.kind, fn.filepath, fn.lineno           # "function", ".../pkg/fn.m", 1
[a.name for a in fn.arguments]            # inputs, then the `arguments` block
fn.docstring                              # comment text, markers removed, not parsed

cls = paths.get("pkg.Widget")             # None when nothing matches
cls.bases, cls.mro                        # as written; mro in C3 order
cls.bases_expr[0].lineno                  # the base as an Expr, with its span
cls.inherited_members["Size"].is_alias    # True: a copy of the base's member
cls.members["Size"].type                  # a Property; .type_expr for the Expr

paths["src/sub"]                          # a folder on the path (a path has a slash)
paths["src/sub/fn.m"]                     # a file in one
paths.addpath("extra", recursive=True)
paths.rmpath("extra", recursive=True)
paths.resolve("helper", from_dir="src")   # looks in src/ and src/private first

paths.lines_collection["src/x.m"]         # the source lines of a file (cached)
paths["pkg.fn"].source                    # the declaration's lines, dedented

live = parse_live_script("demo.mlx")      # or parse_live_script("demo.m", plaintext=True)
[(s.kind, s.content) for s in live.sections]

obj = parse_file("src/x.m")               # the object of one file, no parent
obj = parse_source(text, "src/x.m")       # the same, from text (the file is not read)

API

Name What it is
PathsCollection(paths, recursive=False, working_directory=None, parser_config=None, parse_live_scripts=False) The search path. Raises FilePathError for a folder that cannot be read.
.members {name: object}: the top-level names, as maxx's collection lists them.
.get(identifier), [identifier], in The object, or None / KeyError / False. A path (with a /) gives a folder or a file in one.
.resolve(identifier, from_dir=None) Like get, but a plain name looks next to from_dir first. Raises NameResolutionError.
.addpath(path, *, to_end=False, recursive=False), .rmpath(path, recursive=False) Change the path. rmpath returns whether the folder was on it.
.search_path The folders, in precedence order.
.lines_collection LinesCollection: lines(path), [path], path in lines, keys().
parse_file(path, parser_config=None) The object of one file (its parent is None). Raises FilePathError, or ValueError for a .mlx that is not one.
parse_source(source, path, parser_config=None) The object of MATLAB text, named after path. The file is not read.
parse_live_script(path, plaintext=False) A LiveScript: a .mlx by its contents, or a plain-text live .m with plaintext=True.
Object kind, name, path (dotted identifier; a folder's /name), filepath, lineno, endlineno, docstring, docstring_raw, docstring_lineno, docstring_endlineno, attributes, access, is_private, is_hidden, is_internal (the file is in a +internal package, the package itself included), canonical_path (the dotted name without the folder it was found in), is_alias, target, members, parent, lines, source, lines_collection, is_folder, is_namespace, is_class, is_function, is_script, is_live_script, is_property, is_enumeration, and the member views all_members (the inherited members of a class first), folders, namespaces, scripts, classes, functions, properties, enumerations.
Folder(Object), Namespace(Object), Script(Object) A plain folder, a package, a script.
LiveScript(Object) sections: a list of LiveScriptSection (kind, content, lineno, endlineno).
Class(Object) bases (text), bases_expr (Exprs), events (the names of the events entries, sorted), declares_constructor (a method named as the class is declared), mro, inherited_members, constructor, arguments (those of the constructor), resolved_bases (the superclasses found on the path).
Function(Object) arguments, returns, is_method, is_constructor_method, is_getter, is_setter.
Property(Object) type, dimensions, validators, default, and type_expr, validators_expr, default_expr; getter and setter (Function, with parent the property).
Enumeration(Object) value, value_expr.
Argument name, kind, required, type, dimensions, validators, default, docstring, docstring_raw, and the *_expr versions of the type, validators and default.
Expr text, lineno, column, endlineno, endcolumn, doc (the MathWorks documentation URL of the first builtin name, or ""). Iterating gives the text in tokens: identifiers, blanks and single characters. str(expr) is the text; expr == "double" compares the text (and == another Expr compares the text); hashes as its text.
ParserConfig(docstring_before_properties, docstring_before_arguments, docstring_before_enumerations, parse_live_scripts) Which comment block documents a declaration (default: the one after, as maxx does), and whether .mlx files are live scripts.
Kind, ArgumentKind, AccessKind, SectionKind str enums. Kind has folder, namespace, class, enumeration, function, script, live_script, property (the values of Object.kind).
FilePathError, NameResolutionError, CyclicAliasError Exceptions. CyclicAliasError is raised when the superclasses of a class lead back to it (from mro and inherited_members).

Object.kind is a plain string, equal to the matching Kind member. Argument.kind is positional-only, optional, keyword-only or varargin. Argument.required is true for a positional input with no default.

Docstrings

docstring is the comment block's text with the comment markers removed, as malt's index keeps it. It is not parsed: no sections, no Google or NumPy style. docstring_raw is the block exactly as written, markers included. The consumer (griffe in mkdocstrings-matlab) parses the text.

Expressions

A type, default, validator or base is a str (type, default, bases, ...), the same as before. The matching *_expr attribute is the Expr, with its span, for a consumer that needs the position. Expressions are raw text: Expr does not map a name to a documentation URL.

Live scripts

LiveScriptSection.kind is text or code. A text section's content is the paragraphs' text with the markers removed; a code section's is the code lines as written. Line numbers are None for a .mlx. The sections stop at %[appendix]; outputs are not sections.

Lines

LinesCollection.lines(path) returns the lines of a file, read once and cached. Lines are split on \n with a \r before it removed; a final newline adds no empty line. An object's lines is its declaration's span ([] without one); source is those lines, dedented.

Logging

The index logs through Python's logging logger malt_index, at the levels the record has: DEBUG for each file parsed, INFO for each live script, WARNING for recovered syntax errors, unreadable paths and unreadable document.xml. Nothing is configured by the module: set a handler or a level on the malt_index logger.

import logging
logging.getLogger("malt_index").setLevel(logging.WARNING)

The bridge is a log logger in malt-index's binding (src/logging.rs): a record is passed to Python as logger.log(level, message), so Python's own filtering applies. The bridge is installed when the module is imported; it is not installed if another Rust logger was set first.

Not provided yet

Compared with maxx's surface, these are missing: Alias (inherited members carry is_alias and target instead; imports are not modelled), FileParser and LiveScriptParser as classes (the functions above replace them), PathsCollection.get_path, get_member, as_local_collection, Object.resolve, has_docstring, is_kind, and the maxx logger.configure function, and the Kind.ENUMERATION == "class" alias (malt says enumeration). Enumeration members are Enumeration objects with kind enumeration (maxx reports class).

Build and test

pip install maturin
maturin build -m crates/malt_py/Cargo.toml --release -o dist    # the wheel
pip install dist/malt_index-*.whl pytest
pytest crates/malt_py/python/tests

cargo test -p malt-py checks the Rust side; the Python tests need the built wheel (the module is a compiled extension). The sample project in python/tests/project is written for test_index.py; test_live_expr_folders.py writes its own projects under tmp_path, including a .mlx built with zipfile.

Metadata

Release files for malt-index 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for malt-index 0.3.0
File Size Uploaded Provenance Actions
malt_index-0.3.0.tar.gz 128.1 kB Without provenance Details for malt_index-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for malt-index 0.3.0
File Actions
malt_index-0.3.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for malt_index-0.3.0-cp310-abi3-win_arm64.whl
malt_index-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for malt_index-0.3.0-cp310-abi3-win_amd64.whl
malt_index-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for malt_index-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
malt_index-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for malt_index-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
malt_index-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for malt_index-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
malt_index-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for malt_index-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
malt_index-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for malt_index-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 5.7 MB

Release files / malt_index-0.3.0.tar.gz

Download URL malt_index-0.3.0.tar.gz
Size 128.1 kB
Tags Source
SHA-256 checksum
How to use checksums
39b1728fab055824081cc4d320ac7eb7c1b2b5a7a4b78156a02623c3102fb592
BLAKE2b-256 checksum
How to use checksums
e92ac58fc0276988c05ba6511fbd91d208bbdc8fdc9ed1f7585eef29434633c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-win_arm64.whl

Download URL malt_index-0.3.0-cp310-abi3-win_arm64.whl
Size 673.1 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
98439460dd64acd080313f8c68c55009ed25b6334f0acab0ea56677553bd7f41
BLAKE2b-256 checksum
How to use checksums
cff3a0f3b7bc37d26871890571bbd7ac5b41bf2b9bcc172776e13de6d4beb499
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-win_amd64.whl

Download URL malt_index-0.3.0-cp310-abi3-win_amd64.whl
Size 709.7 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b940beb46bca2602c9724dcf27d834e8737e060121951b6f59170f1ab30a679e
BLAKE2b-256 checksum
How to use checksums
8126c5ff4a78aa175852d1b515f391d4535af24294ab4848ed8425a0138602f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL malt_index-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 991.5 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
932d6d2d40b60e2669a9cbc9c6d612f4da4261ec52f9fb7dd006b71c51c478d4
BLAKE2b-256 checksum
How to use checksums
34ffc7d0bccdede4c7339301f9627cdd619ccf7acee7c2cf2740e58e9ae9d3b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL malt_index-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 927.3 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
4555c611a163c067d77474a4354b4832b6c44d1203b0233e2b23c237dd126260
BLAKE2b-256 checksum
How to use checksums
66debc00a9936aab642f702d71b26aa250dc2dd3a56568ba860ec7a2dfeeef8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL malt_index-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 778.9 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d7330541f820e7d0cc58fc1fabb0050788e150a4c1a1998f440a62b23ec0495c
BLAKE2b-256 checksum
How to use checksums
55fb53994cef1a0774ae746fda87065925016294a936e55356af61125096619a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL malt_index-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 744.1 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
6d488f176aa06a893cc108c3e45d1d8544c7350ae26ef76c127acf953b0ee1d2
BLAKE2b-256 checksum
How to use checksums
a66cd3798a031705454e83e29e905cf1d58d705f3d3f3c49e5b31d308ee335da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / malt_index-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL malt_index-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 725.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8ff2324a4daea0e7317b3620189fcbb888047d59fbdf51edee23229273ceaf3f
BLAKE2b-256 checksum
How to use checksums
3156b315b183c201464950d99a4556c36abf867f2e7ee05041ee708eb3e411ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for malt-index 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page