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.2b7.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.2b7-cp314-cp314-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

File metadata

  • Download URL: rdx_parser-0.1.2b7.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.2b7.tar.gz
Algorithm Hash digest
SHA256 56c864e9d4f4092bba81c99fbe7c04912f114e2bd1ffc11ace2db487603fbd27
MD5 fc9d5d8aac64a271cbc98de174cda3c1
BLAKE2b-256 e3ca209d364974c98e8fd5ed55c54ccc59b69b64a4a6b198c4d12117c091f1da

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2653946f287f609a060868f4126046fef6147c1dc197b211acbaead6131b542
MD5 72afd5c001f2e20bd16fe3496e003874
BLAKE2b-256 032c1149b34a79319160d2b76330e7c426fc8cb116e0d84752d5c7f7fa319ab9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1451043b7922a32f182be3cfb5654a6c3ef5e9cd87229328fdb4e4bfc895c2ff
MD5 5d4659586c32bf938b10186571cdfa40
BLAKE2b-256 73342dc98e83205fd499123f4fddb8c4e1a886cf52262d6f26af3356fbc732ac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8b7369ed47d52d81cadc71d52617a5ef14ab17841c92f8051962678bcbba4f7b
MD5 1e55b53700f8b536dfc3915ce4695120
BLAKE2b-256 c5d2896068ea6b508c9e7f3d815ad42709e6e6731ba282699896b29dd427bc8c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af44b0e6e33affa067c451c1958c45b9dc47c580806be20d155857f3dc5c9694
MD5 7b0d2ad402a120f443ffcd1c9cbe4929
BLAKE2b-256 3ec79d9e00f60ec56cfd659806dbbdc70eafba57570e04f9a629366046cd440a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91f4bde23441dd41efd6ca86606c68bf28eb1a650bd834fa08ef34c045826092
MD5 1a9e2e878ce02ed055dbf18d3dd999c5
BLAKE2b-256 c7e2cdcbce0507c9e2e40fbf555d52d741aad275ef8f39859402448c559cd74d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45b197ec8f9e854e074b2f55c605c67ef508fc09627f93670e85c8ea0cfb60e1
MD5 0ef69c8e0a2b4df1a2da2684882222dd
BLAKE2b-256 df1d789a2cad1c1daccc13dc7014764b33b48e1c72ae42e78af811e52a5c1f83

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d4f9a0cac2ff446510448291b9d71a0456132f0c88cfc42cbd784ad22760995
MD5 813028b6125fdf2a8734d4259f8a11c5
BLAKE2b-256 67c11663172a264230be0b7043603b5821e6b7838b183505741f1a74abfd8c53

See more details on using hashes here.

Provenance

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