Skip to main content

A tool for MkDocs and Zensical to execute code cells and create documentation dynamically.

Project description

md-transformer

pipeline coverage

md-transformer is a powerful tool for dynamic documentation. It allows you to execute code cells, save snippets to files, and include live Python source code directly into your Markdown documents.

It works seamlessly with MkDocs, Zensical, or as a standalone CLI tool.

Documentation: https://md-transformer.readthedocs.io/

Core Features

  • 🚀 Live Execution: Run shell commands and include their output in your docs.
  • 💾 Snippet Management: Write code in Markdown and automatically save it to files.
  • 🐍 Python Integration: Include the source code of any importable Python object.
  • 🔧 Extensible: Create your own Markdown transformers using a simple Python API.
  • 📦 Multi-Tool Support: Use it as an MkDocs plugin, a Zensical extension, or via the CLI.

Quick Start

1. Save and Execute Python Code

Use the python-code fence to save code to a file, and bash-execute to run it and show the output.

```python-code hello.py
print("Hello from md-transformer!")
```

```bash-execute
$ python hello.py
```

Result:

# hello.py

print("Hello from md-transformer!")
$ python hello.py
Hello from md-transformer!

2. Include Python Source

Include the source code of any function or class using include-python.

```include-python md_transformer.transformer.transform
```

Result:

def transform(fh_in, fh_out, transformers, max_line_length=100):
    with MarkdownRenderer(max_line_length=max_line_length) as renderer:
        text = expand_includes(fh_in.read())
        doc = mistletoe.Document(text)
        _transform(doc, list(transformers) + [FixLinebreak()])
        print(renderer.render(doc), file=fh_out)

Installation

pip install md-transformer

Documentation

For detailed information, please refer to our full documentation:

  • 📖 Usage Guide: Detailed integration instructions for MkDocs, Zensical, and the CLI.
  • 🛠️ Technical Details: Information on execution environments and object resolution.
  • 🧩 Custom Macros: How to extend the tool with your own macros.
  • 🔌 API Reference: Full API documentation for developers.

License

This project is licensed under the MIT License.

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

md_transformer-0.1.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

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

md_transformer-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file md_transformer-0.1.0.tar.gz.

File metadata

  • Download URL: md_transformer-0.1.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for md_transformer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb5d23c17d12f8203418f67d57d762adc8367e8d979413d496d075d7f581329c
MD5 c54f4dd3d83b9958f5599ba0542fc990
BLAKE2b-256 4dd708e817fd6dd5c1e2160d78ce8a509737fc8e5c99a149883f9c01f982b94e

See more details on using hashes here.

File details

Details for the file md_transformer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: md_transformer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for md_transformer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4517b44a37fc23f970c767b134e70ed1f2a0578d770b9ca16a10079a22dbeb4e
MD5 9dcb896b2c5b4ba6755ed91f0d5e63e0
BLAKE2b-256 9769f8da6a11b4d0a17ac13c5476f31a77972e066142232ce58269f1531214ff

See more details on using hashes here.

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