Write documentation in comments and render it with templates.


Keywords
documentation, script, shell
License
ISC
Install
pip install shellman==0.2.1

Documentation

Shell Script Documentation

Write documentation in comments and render it with templates.

ci documentation pypi version

shellman can generate man pages, wiki pages and help text using documentation written in shell scripts comments.

For example:

#!/bin/bash

## \brief Just a demo
## \desc This script actually does nothing.

main() {
  case "$1" in
    ## \option -h, --help
    ## Print this help and exit.
    -h|--help) shellman "$0"; exit 0 ;;
  esac
}

## \usage demo [-h]
main "$@"

Output when calling ./demo -h:

Usage: demo [-h]

This script actually does nothing.

Options:
  -h, --help            Print this help and exit.

You can see more examples and all the documentation in the wiki!

Demo

In the demo above we saw the three builtin templates: helptext, manpage and wikipage.

You can use your own templates by specifying them with the --template path:my/template syntax.

You can also write a plugin: see the wiki page on GitLab or on GitHub.

Requirements

shellman requires Python 3.6 or above.

To install Python 3.6, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv

# setup pyenv (you should also put these three lines in .bashrc or similar)
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"

# install Python 3.6
pyenv install 3.6.12

# make it available globally
pyenv global system 3.6.12

Installation

With pip:

python3.6 -m pip install shellman

With pipx:

python3.6 -m pip install --user pipx

pipx install --python python3.6 shellman

Some projects using shellman

  • shellm — A collection of scripts and libraries built on a core inclusion-system, all installable with basher. Here are a few examples:
    • daemon — A library that facilitates the writing of daemonized scripts that consume files in a watched directory.
    • debug — A simple script that sets the verbose/dry-run/debug Bash flags before running another script.
    • format — Format your output with style and color.
    • home — A home for your shell scripts!
    • loop — Control the flow of your loops (pause/resume/etc.).