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.2b9.tar.gz (107.7 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.2b9-cp314-cp314-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rdx_parser-0.1.2b9-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.2b9-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

rdx_parser-0.1.2b9-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.2b9-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.2b9-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.2b9-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.2b9.tar.gz.

File metadata

  • Download URL: rdx_parser-0.1.2b9.tar.gz
  • Upload date:
  • Size: 107.7 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.2b9.tar.gz
Algorithm Hash digest
SHA256 b35c141065e822cecf3c5bb5292369ea81f481cbcdfd25bdf7afb63de22427f0
MD5 b4c649e9cd0ab09eec35cd87fcbdb6f5
BLAKE2b-256 daa83a3fad150d3b156a09894e74fb1da7d51a2a3bd0e7872843f6dc68d2328a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9.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.2b9-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 312e4899165b90e3e455b612ae440aa19c585f04ecd49891e5586e6bcb803331
MD5 382cd0bffc057cbb752c096c44ad44d0
BLAKE2b-256 17908b33dab8c123599f689bdaeb9f35096803ae1b82cdc8d8d21f078c73144c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90cff98295d94725b46cc8bb807b0641576356ffc8190e4529009eb04671cf49
MD5 a718add40e29942c5f0d498ee91a1d3f
BLAKE2b-256 de1f3bde8f63912689ccdd348aed48e31536cb2a5a7fa0ea745e59d0f01b59f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6e1464e8d9d1745a70230d5fbb12fa5014a26f02565de67169239c394dcc41c6
MD5 811b53ef9ebe9616b99b65ca433b1c6f
BLAKE2b-256 51f9fbf945998e18f6757d753641fc24c76c387a57018415060c5065ed17955a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c089f0093be083d89b81412af254c81eb8285e5dd9e287ae5dbf28c1518a816
MD5 5cf6ee1675abb5af95fa02bed182dc60
BLAKE2b-256 093bd32eff113f802148cca59899ae450a45e940691d8ba081b3299b5bf4d2a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fc2f88245a9980c42f110286410f135c6369075416ee31736602a150968f333
MD5 1a1ec2a144c2b0ea183ebb02bdc1689a
BLAKE2b-256 867706515a8fd347c132bac0dfc846379b6d8848f9306e385f6580820189ceb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9a470d9b286fdd40399eff88a48b7758e1508900cc342b16d265ec7127033dc
MD5 2f4df72576c9681d1dd10af4bc618b8c
BLAKE2b-256 a046fb64708bdc49cc8cf96eb354c081e5e15f40525ae9a89b0a433d4a46c2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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.2b9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdx_parser-0.1.2b9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 571fe95eb2eb89f6e775d6f31c9977b531d3c8c5cbf62b8ba53d64dd93733882
MD5 e6a96ac333c7b789ef19f16714dd3b22
BLAKE2b-256 cc77ef2b1963cf1182a573762d04112949346008119d169999c7d7441d34540b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdx_parser-0.1.2b9-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