Skip to main content

Generate rich images for the GitHub Action 'rich-codex'

Project description

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

Rich-click searches markdown code for image embeds with 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 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 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/

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

rich-codex-1.0.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

rich_codex-1.0.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file rich-codex-1.0.1.tar.gz.

File metadata

  • Download URL: rich-codex-1.0.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for rich-codex-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cd3d61da1d1d1a1c2193607620bbf99789db96171f5450a9d299f5fba2a7cf34
MD5 55e50598546bb5bd0cfe65c447b1e8e1
BLAKE2b-256 c89a1fba4e2105017a5723c0acbdc6b6410c21b1aa47c103127af651a510fc6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rich_codex-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for rich_codex-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0979bfc4ce3c797f79c78e8955f55a4051665e3e19647632300abc41d28e35d2
MD5 d22aeeac91e3553e5b4967500fcdf96e
BLAKE2b-256 7347fc71ff21356fe9f9baa220cb1f684b4dc188f4a28230f22e48aaca1f26d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page