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

optional arguments:
  -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.7.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distributions

mechanical_markdown-0.7.0-py3.7.egg (13.3 kB view details)

Uploaded Source

mechanical_markdown-0.7.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file mechanical-markdown-0.7.0.tar.gz.

File metadata

  • Download URL: mechanical-markdown-0.7.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.9.6 requests/2.31.0 setuptools/47.1.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.7.16

File hashes

Hashes for mechanical-markdown-0.7.0.tar.gz
Algorithm Hash digest
SHA256 47d750cee16aa365865ddfa52c87f6aabaf8c70c5ff4b74bc8f42754a07580de
MD5 14b35eee77fce65c8606311eca2ba2bc
BLAKE2b-256 f80c8564d108a92d7d310daa50937beb1b10c1649077de7ab8302f8642c8e5dd

See more details on using hashes here.

File details

Details for the file mechanical_markdown-0.7.0-py3.7.egg.

File metadata

  • Download URL: mechanical_markdown-0.7.0-py3.7.egg
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.9.6 requests/2.31.0 setuptools/47.1.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.7.16

File hashes

Hashes for mechanical_markdown-0.7.0-py3.7.egg
Algorithm Hash digest
SHA256 88846ebc3a6431593c5e3f3096fca0ecaf88dd4b1539aaa7c15615378264e0b5
MD5 f52b4fc3b3a64b75ec867bf1a1f9fbb1
BLAKE2b-256 ceb8b836a6b7dabed27a1cb35e557a4232492c3c726c6747bd18837fcda8c35c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mechanical_markdown-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.9.6 requests/2.31.0 setuptools/47.1.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.7.16

File hashes

Hashes for mechanical_markdown-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 656f76363f7e9713a3dd9973c83594c9537834e5a159372c5876d090491c22d5
MD5 e628ab310f04fd0670ac0a60a11c00af
BLAKE2b-256 c52605bdb8b52bcbf142edc84a69b7634b9290c0a83d904ca40fb02e867e2262

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