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.1

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.1
File Size Uploaded Provenance Actions
malt_index-0.2.1.tar.gz 101.9 kB Without provenance Details for malt_index-0.2.1.tar.gz

Built distributions (wheels)

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

Total release size: 5.1 MB

Release files / malt_index-0.2.1.tar.gz

Download URL malt_index-0.2.1.tar.gz
Size 101.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cd5f398d2049b96603b2dac9e355dd6e739fc1a694fae6d4c688317838937904
BLAKE2b-256 checksum
How to use checksums
619e9bb3ba7cf0712c2ea3b57b32ee6cc47fe33dc85c3d2dbeaff8142a4df4b5
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.1-cp310-abi3-win_arm64.whl

Download URL malt_index-0.2.1-cp310-abi3-win_arm64.whl
Size 600.4 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6614750e9f48b4483b892fc3672c0c454ef1c15451cb1b6c88073b17cd90eb7e
BLAKE2b-256 checksum
How to use checksums
2893b06527605eadd8c7f884ed9434419abe3bcb4afba4fac8107581fe3493b0
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.1-cp310-abi3-win_amd64.whl

Download URL malt_index-0.2.1-cp310-abi3-win_amd64.whl
Size 636.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ec065bc3476cda9296f415d3d84f67d3ed9a0e18b4c7c1f3ad06a1b6d2085a83
BLAKE2b-256 checksum
How to use checksums
fce777fcfb197b65fe32073cf097cb59082990757adf026bfed4b551691ec1cf
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.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL malt_index-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 913.4 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
0702a106a28c646de61f65f63f4e4948b9db1ff68d960df92b738b0c906cddf1
BLAKE2b-256 checksum
How to use checksums
33a7e050ace82f6daf87016de2377d06f68d35e43880c499c798f481e5fd19c8
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.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL malt_index-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 853.8 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d0ae56ec99ab235e5a67a504bb4b0319a3f33fe108488ab869ecefec8b767796
BLAKE2b-256 checksum
How to use checksums
38b6c7cda23f842069a54bb8dd925ca87e5efc5b9efd18aaa375a98bc4e78874
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.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL malt_index-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
Size 699.9 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
951f41ff0d10da857ae10e287b877df08b9147bc4ceb99f9906e59646553e812
BLAKE2b-256 checksum
How to use checksums
e81583afdaf441b7a20888a36fd1b6430e84426dc2c3249b52af8722de8042c9
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.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL malt_index-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
Size 670.9 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
006929535d658b96a646627808ca98354b10525d66cb04ba7ca0efa2bccb4ff4
BLAKE2b-256 checksum
How to use checksums
e8a34cfb7fc40501c5e2c2878f483f1af20c6a02f1fed0a995080d6cb2f80c39
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL malt_index-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 652.8 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
50bc55384aba7ed3e94efc1c8ba3be69667d3ca6cfd54e7fc381b166fcf5023f
BLAKE2b-256 checksum
How to use checksums
c0df44c9871ca2e56e62a027e55c50eccc75160bebac20bbf9ec33d07c7cc021
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.1

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