Skip to main content

rich-codex ⚡️📖⚡️

A GitHub Action / command-line tool which generates screengrab images of a terminal window, containing command outputs or code snippets.

📚 Documentation: https://ewels.github.io/rich-codex/ 📚

PyPI Version

Introduction

Having code examples in your documentation is a fantastic way to help users understand what to expect from your tool.

Using terminal screenshots is a good way to do this because:

  • 🌈 Coloured terminal output is supported
  • ↔️ You can fit in long lines without scrolling or cropping (images are auto-resized)
  • 😎 They look cool

However, manually generating these screenshots is a pain 👎🏻 Remembering to update them every time you make a minor change means that they can easily get out of date.

Rich-codex automates this process for you. It searches markdown code for images with shell commands or code snippets. It runs these commands and saves a terminal screen-grab at the embedded path.

Typical use cases:

  • 📷 Example CLI tool outputs that automatically stay in sync with your package
  • ♻️ Syntax-highlighted code snippets that are always up to date with your examples/
  • 🤩 Fast and simple images for your docs with minimal setup

Quickstart

  1. 📖 Write some markdown docs, use an image tag with a backtick command inside:

    ![`cat docs/cat.txt | lolcat -S 1`](docs/img/cat.png)
    
  2. 🤖 Add a GitHub Action to automatically run the command, generate the image and commit to the repo:

    on: [push]
    jobs:
      rich_codex:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
    
          - name: Install your custom tools
            run: pip install lolcat
    
          - name: Generate terminal images with rich-codex
            uses: ewels/rich-codex@v1
            with:
              commit_changes: "true"
    
  3. 🌈 Enjoy reading your documentation My cat rainbow

How it works

Rich-codex is a command-line tool that you can run via a GitHub action or as a command line tool. It works with any markdown (including GitHub READMEs).

It collects either commands or code snippets, together with output filenames and configuration options. Commands are run in a subprocess and the standard output & standard error collected. These are then rendered as an image using Textualize/rich.

Rich-codex creates the images that your markdown docs expect. It doesn't require a HTML build-step and doesn't make any changes to your markdown or its output. As such, it's compatible with any documentation engine, including rendering markdown on github.com.

Rich-codex needs inputs (commands / snippets) and output filenames to work. These can be configured in four different ways:

  • 🖼 Markdown images
    • Search markdown files for image tags with command alt text. eg: ![`rich-codex --help`](docs/img/rich-codex-help.svg)
  • 💬 Markdown comments
    • Search markdown files for special HTML / JSX comments.
  • ➡️ Command-line / action inputs
    • Specify a command or snippet using the action with inputs.
  • ⚙️ Config files
    • Use one or more YAML config files for multiple images and more complex customisation.

Images can be generated as SVG, PNG or PDF (detected by filename extension).

Keep reading! 👉 https://ewels.github.io/rich-codex/

Download files

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

Source Distribution

rich_codex-1.3.1.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

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

rich_codex-1.3.1-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file rich_codex-1.3.1.tar.gz.

File metadata

  • Download URL: rich_codex-1.3.1.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rich_codex-1.3.1.tar.gz
Algorithm Hash digest
SHA256 7c7e0178fd30b3a6529f2aec62b63db7e0b32aca0c62823d9094102c59885dbd
MD5 f97eff5fa45fe3bd3aa0a094e87a6a98
BLAKE2b-256 dc5babbb64e532d84557305b0539571fe89831bc24d7414e473344d071fc9311

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_codex-1.3.1.tar.gz:

Publisher: deploy-pypi.yml on ewels/rich-codex

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

File details

Details for the file rich_codex-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: rich_codex-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rich_codex-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f9d68c320415935c52f8853389ea5d72a10820397ce4fe7e197e604f52bffe8
MD5 96a9fb70806f73d5dfd67d4f5490e3c6
BLAKE2b-256 1f843c3d7ffd58400d5cc80e3949b0f8e9bf73dd9e69bd8df3d127f0fb46fe4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_codex-1.3.1-py3-none-any.whl:

Publisher: deploy-pypi.yml on ewels/rich-codex

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 Sentry Error logging StatusPage Status page