Skip to main content

RDX parser for Python — parse .rdx documents at Rust speed

Project description

rdx-py

Python bindings for the RDX parser via PyO3 and maturin. Parse .rdx documents at Rust speed, get plain Python dicts back.

Installation

pip install rdx-parser

Usage

import rdx

ast = rdx.parse("""---
title: API Reference
---

# {$title}

<Notice type="warning">
  This endpoint is deprecated.
</Notice>
""")

print(ast["frontmatter"])  # {'title': 'API Reference'}
print(ast["children"][0]["type"])  # 'heading'

API

rdx.parse(input: str) -> dict

Parse an RDX document into an AST dict.

rdx.parse_with_defaults(input: str) -> dict

Parse with built-in transforms (auto-slug headings + table of contents).

rdx.parse_with_transforms(input: str, transforms: list[str]) -> dict

Parse with selected transforms. Available: "auto-slug", "toc".

rdx.validate(ast: dict, schema: dict) -> list[dict]

Validate an AST against a component schema.

schema = {
    "strict": True,
    "components": {
        "Notice": {
            "props": {
                "type": {"type": "enum", "required": True, "values": ["info", "warning", "error"]}
            }
        }
    }
}

diagnostics = rdx.validate(ast, schema)
for d in diagnostics:
    print(f"{d['severity']}: {d['message']} at line {d['line']}")

rdx.collect_text(ast: dict) -> str

Extract all plain text from the AST. Useful for search indexing, embeddings, and reading time estimation.

text = rdx.collect_text(ast)
words = text.split()
reading_time = len(words) // 200  # minutes

rdx.query_all(ast: dict, node_type: str) -> list[dict]

Find all nodes of a given type.

headings = rdx.query_all(ast, "heading")
components = rdx.query_all(ast, "component")

rdx.version() -> str

Returns the RDX parser version.

RAG / AI Pipeline Example

import rdx

def prepare_for_embedding(rdx_source: str) -> list[str]:
    """Parse RDX and split into clean text chunks by heading."""
    ast = rdx.parse(rdx_source)
    chunks = []
    current = []

    for node in ast["children"]:
        if node["type"] == "heading":
            if current:
                chunks.append(rdx.collect_text({"type": "root", "frontmatter": None, "children": current, "position": ast["position"]}))
            current = [node]
        else:
            current.append(node)

    if current:
        chunks.append(rdx.collect_text({"type": "root", "frontmatter": None, "children": current, "position": ast["position"]}))

    return chunks

Development

pip install maturin
maturin develop
python -c "import rdx; print(rdx.parse('# Hello'))"

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdx_parser-0.1.2b11.tar.gz (107.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rdx_parser-0.1.2b11-cp314-cp314-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rdx_parser-0.1.2b11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rdx_parser-0.1.2b11-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

rdx_parser-0.1.2b11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rdx_parser-0.1.2b11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rdx_parser-0.1.2b11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rdx_parser-0.1.2b11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file rdx_parser-0.1.2b11.tar.gz.

File metadata

  • Download URL: rdx_parser-0.1.2b11.tar.gz
  • Upload date:
  • Size: 107.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rdx_parser-0.1.2b11.tar.gz
Algorithm Hash digest
SHA256 cde4854f317c1034bc5c08e58485d2fcdae674b9456afd2c52d882c7756b0898
MD5 23380b39c014bc695c579d1ecdf219d9
BLAKE2b-256 81f891f3168dcb04588df5fd1998867a40a6fa90e57665bfa814611a63991024

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11.tar.gz:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d833842ca362690b312d4a814bf391a3c9061086ed228cf5b51f8c38dc9aa19d
MD5 827db9ce93d53faeec955bcc831fd721
BLAKE2b-256 e54d25d6afe547fce93705a95a4f8449e9fd3d0867ee2fdfa88fbc0ed845b0c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccfcfa04430de54a26d5e6aa3efd419677149b8f6e426dc2fb75e3598a8ece6b
MD5 0138b20fc4c5fd8c2ea34605f3931d43
BLAKE2b-256 c53412c6008d18c08e81245cd2681268f71143c1cee8a6b0457e0ce0ee4ba54c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6f30bfc2c1a32a7d25e2f44dd44f7f7255dfc0a58efa2508ad096a3a7c9cf10c
MD5 fe48b9f7b90fcb59d3b4835c1139a249
BLAKE2b-256 bf5d71170ca3d44969e5af7371f20e812e845442126df600ddbd0387b9f9dec1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp312-cp312-win_amd64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2bd8a3d98d073d31cd1bfff28be00f5e78706eadb4bb2bb71018aef8b3befc9c
MD5 921ac0040e09c4065714369d2de2b295
BLAKE2b-256 28806561cd1ab6cce37c713a99cee1d21c62b4794bc8ea53bb62674b18bdf42b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 381959cf0633912928c202b440aa5f12c2b441572b9a240eb75c43c9c753fedd
MD5 fcb0b15bf0ce7ce81df582fb1ea3da85
BLAKE2b-256 a4b8454bac96bc9425cd9074543b4a0e32e1836e10f85403f1cc02c91e2b1038

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bad79ecb7736bb1d07236c45e2bc80e6526f6e03bb0e2e60a2cfd00af0abf76
MD5 0068457b28cb44ccc2165bc3ddc30729
BLAKE2b-256 5f468fdf11ca36e358d838a33c3968ecda64043b0764969ce172ca4ad7090914

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdx_parser-0.1.2b11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e40094d417b1cdd3722a29af2d57b643aba3cc78b93a9ee5688ea03eeae2ff7f
MD5 0b8b56c5fe2c0204787b724f50ccd15e
BLAKE2b-256 8047c9586c1847f0e6e9d895f32d54f5f64970df599f15121bc736f3bc2207c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rdx-lang/rdx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page