将 Markdown 配方作为 shell 脚本运行
项目描述
机械降价
如果您使用 markdown 为您的用户创建教程,这些 markdown 文件通常是一系列 shell 命令,用户将复制并粘贴到他们选择的 shell 中,以及每个命令正在执行的详细文本描述。
如果您定期发布软件并且每次创建发布时都必须通过将粘贴命令复制到终端来手动验证您的教程,那么这就是您的软件包。
mechanical-markdown 包是一个 Python 库和相应的 shell 脚本,允许您以自动方式运行带注释的 Markdown 教程。它将执行您的降价教程并根据预期的 stdout/stderr 验证输出,您可以将其直接嵌入到降价教程中。
安装
这个包需要一个工作的 python3 环境。您可以使用 pip 安装它:
pip install mechanical-markdown
这将安装 Python 模块,并创建mm.py
CLI 脚本。
快速开始
查看示例以获取一些快速简单的示例。
用法
命令行界面
mm.py
此软件包中包含一个名为的命令行实用程序。
% 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
从包含 markdown 文档的字符串创建 MechanicalMarkdown 实例:
from mechanical_markdown import MechanicalMarkdown
mm = MechanicalMarkdown(markdown_string, shell="bash -c")
机械降价方法
# 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)
贡献
问题和贡献总是受欢迎的!请确保您的提交具有适当的单元测试(请参阅测试)。
创建这个项目是为了支持dapr/quickstarts。我们分享它是希望它对其他人和我们一样有用。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
mechanical-markdown-0.5.2.tar.gz
(10.3 kB
查看哈希)
内置发行版
mechanical_markdown-0.5.2-py3.7.egg
(12.7 kB
查看哈希)
关
mechanical_markdown- 0.5.2 -py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 11b5f4b785f58fb3dbcd299d354c0fa793b03c489ca63ef1ab0a52640b7c0279 |
|
MD5 | 65307b3c175cfb19a3ff9e2fd3e82310 |
|
布莱克2-256 | d510675afcc3408639f557e9fcf85185e9edd3eb6b1062f498c62502c0baa02a |