Run markdown recipes as shell scripts
Project description
Mechanical Markdown
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mechanical-markdown-0.7.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47d750cee16aa365865ddfa52c87f6aabaf8c70c5ff4b74bc8f42754a07580de |
|
MD5 | 14b35eee77fce65c8606311eca2ba2bc |
|
BLAKE2b-256 | f80c8564d108a92d7d310daa50937beb1b10c1649077de7ab8302f8642c8e5dd |
Hashes for mechanical_markdown-0.7.0-py3.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88846ebc3a6431593c5e3f3096fca0ecaf88dd4b1539aaa7c15615378264e0b5 |
|
MD5 | f52b4fc3b3a64b75ec867bf1a1f9fbb1 |
|
BLAKE2b-256 | ceb8b836a6b7dabed27a1cb35e557a4232492c3c726c6747bd18837fcda8c35c |
Hashes for mechanical_markdown-0.7.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656f76363f7e9713a3dd9973c83594c9537834e5a159372c5876d090491c22d5 |
|
MD5 | e628ab310f04fd0670ac0a60a11c00af |
|
BLAKE2b-256 | c52605bdb8b52bcbf142edc84a69b7634b9290c0a83d904ca40fb02e867e2262 |