• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create rich code images for your docs.

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 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/

More Repositories

1

rich-click

Format click help output nicely with rich.
Python
589
star
2

sra-explorer

Web application to explore the Sequence Read Archive.
HTML
178
star
3

AWS-iGenomes

Documentation and description of AWS iGenomes S3 resource.
HTML
106
star
4

clusterflow

A pipelining tool to automate and standardise bioinformatics analyses on cluster environments.
Perl
96
star
5

CPT-Bootstrap-Carousel

WordPress plugin which generates a custom post type for choosing images and content. Outputs Bootstrap Image Carousel (slider) HTML from a shortcode.
PHP
50
star
6

Labrador

A web based tool to manage and automate the processing of publicly available datasets.
PHP
37
star
7

hemnet-commuter

Visualisation, annotation and powerful filtering tools for houses discovered on Hemnet.
PHP
25
star
8

ngi_visualizations

Development fork. Head fork here >>>
Prolog
6
star
9

niceLiftOver

Wrapper script to take an input file and liftOver the co-ordinates in place, leaving all other data in tact.
6
star
10

phil.ewels.co.uk

Website code for phil.ewels.co.uk
SCSS
5
star
11

sequences

A lightweight and quick DNA sequence manipulation tool.
HTML
4
star
12

global-bootstrap-banner

WordPress plugin: Add a global website banner using a Bootstrap alert box.
PHP
3
star
13

tower-action

See the main repo here:
Shell
2
star
14

dotfiles

Personal dotfiles for sharing setups and configs between machines.
Shell
1
star
15

bootstrap-feature-widgets

A simple widget which makes markup for a feature using Twitter Bootstrap styles
PHP
1
star
16

flask-subcommand-issue

Minimal test example for flask / click subcommand problem
Python
1
star