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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

File metadata

  • Download URL: rdx_parser-0.1.2b6.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.2b6.tar.gz
Algorithm Hash digest
SHA256 d15165d8a8c31d402018b485a5b39945c765cac6a3b44db85f3a18080bba2bbc
MD5 1311835c306f55a00a8899a06134e719
BLAKE2b-256 d2c86f7d758a150fd0172f2421c5e2e3316f0572cd67893730b8e708a3fb3ef0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b53826d7a61eb8dfb4c4c8c590b529a0a39b9256f10769e18c249f552a57002d
MD5 1b6979bb44266f38912b7629dc057527
BLAKE2b-256 de0488c75d471dba8a19b41caacdcf0a70b98fde2da10047795870de91342410

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 486fb4ec5fb6b8706b9eba8ec987ce2005ec99ffabca17a2f5bedcdcf62b3aa1
MD5 28747b8ded9e22104f2b08cd94f004ac
BLAKE2b-256 321981ea81432ae82aac1ffecda5985e7c06ca314a34bc299e40223b805d8cca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 433f22ad6c85b7c0eb3377547933975039a546a161ba5f008fbba46ec8eb179d
MD5 98b61464047e849edbad8ebb52c4b23b
BLAKE2b-256 de559f6d5e3f638a4c6c0c1560de758cddab165da769c3e42bd42acefe1bd127

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7e52bb2f24bd60699102a26b225ae82d5595d7beab2fbb985719a1347d4f6cb
MD5 5a3186a03e090a28822d15d5ef24a07b
BLAKE2b-256 2eca220cca735553db99bf4544696a1ca254a9cdb924ed7985f7bddeabae5c8e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7437090abe8b2f187fcd07a9fe6386b14251fcf5729a472035fa5656feaf9b6f
MD5 57681d5bc288b0271a250fa2a905798e
BLAKE2b-256 2cbdb3635ae1ee9f5bdfa9bfe5517a53700ed19cf17a393546b2979e7d5b651f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 420c6c47b28c7e045edb99755eaa597320694f8b617d501eca2b9d0673775aac
MD5 a5e7253540e2d54d16ba9741c641ff85
BLAKE2b-256 e2d852f526b214eacd06a6308b3611a5fade4cf88ead78c40cd81908d0e4f4dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rdx_parser-0.1.2b6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3af7e69750c56f926621c4d43e9640ab7e9990f18e044723f41cf9e43a318b8a
MD5 13c26d805daeedc7102749d4e1139077
BLAKE2b-256 68e0849f8fbec29fe6d7361ae803446607db41678bbf20bed4a752cdd5acae54

See more details on using hashes here.

Provenance

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