Skip to main content

Run markdown recipes as shell scripts

Project description

Mechanical Markdown

PyPI version codecov

If you are using markdown to create tutorials for your users, these markdown files will often be a series of shell commands that a user will copy and paste into their shell of choice, along with detailed text description of what each command is doing.

If you are regularly releasing software and having to manually verify your tutorials by copy pasting commands into a terminal every time you create a release, this is the package for you.

The mechanical-markdown package is a Python library and corresponding shell script that allow you to run annotated markdown tutorials in an automated fashion. It will execute your markdown tutorials and verify the output according to expected stdout/stderr that you can embed directly into your markdown tutorials.

Installing

This package requires a working python3 environment. You can install it using pip:

pip install mechanical-markdown

This will install the Python module, and create the mm.py CLI script.

Quick Start

Check out the examples for some quick and easy examples.

Usage

CLI

A command line utility called mm.py is included with this package.

% mm.py --help
usage: mm.py [-h] [--dry-run] [--manual] [--shell SHELL_CMD] markdown_file

Auto validate markdown documentation

positional arguments:
  markdown_file

options:
  -h, --help            show this help message and exit
  --dry-run, -d         Print out the commands we would run based on markdown_file
  --manual, -m          If your markdown_file contains manual validation steps, pause for user input
  --shell SHELL_CMD, -s SHELL_CMD
                        Specify a different shell to use

API

Creating a MechanicalMarkdown instance from a string which contains a markdown document:

from mechanical_markdown import MechanicalMarkdown

mm = MechanicalMarkdown(markdown_string, shell="bash -c")

MechanicalMarkdown methods

# Returns a string describing the commands that would be run
output = mm.dryrun()
print(ouput)

# Run the commands in the order they were specified and return a boolean for succes or failure
# Also returns a report summarizing what was run and stdout/sterr for each command
success, report = exectute_steps(manual, validate_links=False, link_retries=3)
print(report)

Contributing

Issues and contributions are always welcome! Please make sure your submissions have appropriate unit tests (see tests).

This project was created to support dapr/quickstarts. We're sharing it with the hope that it might be as usefull for somebody else as it was for us.

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

mechanical_markdown-0.8.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

mechanical_markdown-0.8.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file mechanical_markdown-0.8.0.tar.gz.

File metadata

  • Download URL: mechanical_markdown-0.8.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for mechanical_markdown-0.8.0.tar.gz
Algorithm Hash digest
SHA256 672301d7eb98aa6a660a974e5d64132bcf25fc3641015d1eb29b5ac292b6cac0
MD5 8209e5981f0e195dac3b340313aec3e0
BLAKE2b-256 e50ee980b8d3882fb9e4c0ba9c4966a6d0d1e99ef65e8fbf026354498bc20e29

See more details on using hashes here.

File details

Details for the file mechanical_markdown-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mechanical_markdown-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7c1746b087c43bd50ce320cc479ff5eb2da3b43ae6d334ac36571d086d156e
MD5 90d2522769174f69427ab25197844bbd
BLAKE2b-256 3c895a2b00dee852fe95da4f4aff3393fb4caa22b8ecedb029b90aa5ed02177d

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