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_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.
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.
Function(Object) arguments, returns, 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. 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, canonical_path, has_docstring, is_kind, the maxx logger.configure function, the iteration of an Expr over its tokens, 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.2.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.2.0
File Size Uploaded Provenance Actions
malt_index-0.2.0.tar.gz 101.8 kB Without provenance Details for malt_index-0.2.0.tar.gz

Built distributions (wheels)

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

Total release size: 5.1 MB

Release files / malt_index-0.2.0.tar.gz

Download URL malt_index-0.2.0.tar.gz
Size 101.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b6609f6f7ea6e4cba8777cc8e055234277ccc37d30b892028b243df2c4a573c1
BLAKE2b-256 checksum
How to use checksums
05a1a0fc4126fa574ed4fe648a28b574287653c25729e174756cdfecaa6becc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-win_arm64.whl

Download URL malt_index-0.2.0-cp310-abi3-win_arm64.whl
Size 600.4 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
1b43d9b6f95348aef389783d6bf2a0c318ca429cca55291987c3c81c41b6a4a6
BLAKE2b-256 checksum
How to use checksums
ea774fbaa70a2dfce263cc0c797e3a4ac70457bf7270a4554d1b1f0e5844540d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-win_amd64.whl

Download URL malt_index-0.2.0-cp310-abi3-win_amd64.whl
Size 636.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
531dd2f34be2d7465f12f20e9b0aa3fea41bb1cade14c9d462cfaf5134b39aa9
BLAKE2b-256 checksum
How to use checksums
00c986784d049c8d9ba5a5018a519f81d44b3f2efb30b6599c678b22a0e5cebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL malt_index-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 915.2 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
2942b33bdf783d660d7cc89ece1f267e06a8f50882314fc998596ec4004bad3a
BLAKE2b-256 checksum
How to use checksums
7a9c80bf4ac6573ea22ff5965ba31bb3381e9fedc0cec1af8a7e8045f349eabb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL malt_index-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 854.6 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ce7e9d2be61f490b5d5a672ff68215e0f41e80dcda64f12702c933ab3c2c6e58
BLAKE2b-256 checksum
How to use checksums
c63ffe35f51539c24195b381bdf661e795dd3dce6e2d2956ab28ba6d5d9f92a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL malt_index-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 701.7 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b2d3a3bea50890b73ff11cedcd6ccd3b6c28a0aa4acfb9d880b7c52ae33c271e
BLAKE2b-256 checksum
How to use checksums
d374d8eff13bbe8f63755cb1966e3bee996747a5d18b103d4ef7cf013d32394a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL malt_index-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 672.2 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b09cc06c499bde255079837186cc2ef8c3f4f1d32a6fcdde5c80ecff97344b56
BLAKE2b-256 checksum
How to use checksums
52ff14a8659e665161d81d0d045123bccd10bbbc6223faf2e939699cccba0f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL malt_index-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 650.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0a1504bad8199cdf2ae2749ccd24ebe7fbcd9ed8345a43f6148740038373b0c0
BLAKE2b-256 checksum
How to use checksums
57b409f233225671c3a6ab1009bee7f7f3a8b16349c4ffc8b50c3182dda4a3af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.2.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