Skip to main content

Convert a help message to markdown text

Project description

Convert a help message to markdown text

This module provides the help2md Python function that converts a help message (the output from a command when the -h flag is given) to a valid and well-formated markdown text.

The module is inspired by the awk script help2md and my own version of this awk script updated to better match the help message generated by the argparse module: help2md-argparse.awk (web-friendly format).

Install the help2md module

The help2md module should be installed with pip:

pip install help2md

This will install the module help2md implementing the help2md function and the console script help2md. The help2md function is also embedded in the pypimdoc module. The source code of the module (without the console script part) can be found at my file repository.

Function help2md

help2md(help_msg: str) -> str

Convert a help message to markdown text

Convert a command help message (the output from a command when the -h flag is given) to a valid and well-formated markdown text. This function is tailored for the help messages produced by Python programs using the argparse module.

Arguments/return value:

help_msg: The help message to convert

returns: The markdown text

Use the help2md module as a console script

You can use the module as a console script to convert the help message output of a command to markdown. In this example the helpmessage of the pypimdoc command is converted to markdown and saved in the file pypimdoc-help.md:

pypimdoc -h | help2md -o pypimdoc-help.md

Command help2md

Convert a help message to markdown text

Usage:

help2md [-h] [-V] [-o OUTFILE] [-i INFILE]

Options:

Name Description
-h, --help show this help message and exit
-V, --version show program's version number and exit
-o, --outfile OUTFILE output file (default stdout)
-i, --infile INFILE input file (default stdin)

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

help2md-1.5.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file help2md-1.5.tar.gz.

File metadata

  • Download URL: help2md-1.5.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for help2md-1.5.tar.gz
Algorithm Hash digest
SHA256 ae77837cb3dd4796ff284302a4e78a09b636f1a14a7c280101568546724fcc62
MD5 aa16ccd2f4886189d9723faae5d42117
BLAKE2b-256 c21eaaa5eea78bcc793ed5b165d015a527e84052568fbfcbbd671e960a716b9d

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