Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore ALL files from the dist directory
dist/
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```
Generate automatic command index from a program.

Usage:
make-readme [options] COMMAND

It outputs a Markdown section with program name,
help and version information.

Works for any installed program that has --help
and --version options. Especially useful for Docopt.
It can be used with the following command to generate readme files:
pip install -e .

Options:
-h LEVEL, --heading LEVEL Start from hLEVEL heading [default: 2].
--help Display this message.
--version Display version information.
```
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "markdown_help"
version = "0.9"
authors = [
{ name="Michal Moroz", email="michal@makimo.pl" },
{ name="Wojciech Mielczarek", email="wojciech.mielczarek@makimo.pl" },
]
description = "Generate automatic command index from a program."
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
'docopt == 0.6.2',
]

[project.urls]
"Homepage" = "https://github.com/makimo/markdown-help"
"Bug Tracker" = "https://github.com/makimo/markdown-help/issues"

[project.scripts]
markdown-help = "markdown_help:main"
34 changes: 34 additions & 0 deletions src/markdown_help.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Metadata-Version: 2.1
Name: markdown-help
Version: 0.9
Summary: Generate automatic command index from a program.
Author-email: Michal Moroz <michal@makimo.pl>, Wojciech Mielczarek <wojciech.mielczarek@makimo.pl>
Project-URL: Homepage, https://github.com/makimo/markdown-help
Project-URL: Bug Tracker, https://github.com/makimo/markdown-help/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docopt==0.6.2

```
Generate automatic command index from a program.

Usage:
make-readme [options] COMMAND

It outputs a Markdown section with program name,
help and version information.

Works for any installed program that has --help
and --version options. Especially useful for Docopt.
It can be used with the following command to generate readme files:
pip install -e .

Options:
-h LEVEL, --heading LEVEL Start from hLEVEL heading [default: 2].
--help Display this message.
--version Display version information.
```
11 changes: 11 additions & 0 deletions src/markdown_help.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LICENSE
README.md
pyproject.toml
src/markdown_help.py
src/markdown_help/__init__.py
src/markdown_help.egg-info/PKG-INFO
src/markdown_help.egg-info/SOURCES.txt
src/markdown_help.egg-info/dependency_links.txt
src/markdown_help.egg-info/entry_points.txt
src/markdown_help.egg-info/requires.txt
src/markdown_help.egg-info/top_level.txt
1 change: 1 addition & 0 deletions src/markdown_help.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions src/markdown_help.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[console_scripts]
markdown-help = markdown_help:main
1 change: 1 addition & 0 deletions src/markdown_help.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docopt==0.6.2
1 change: 1 addition & 0 deletions src/markdown_help.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
markdown_help
60 changes: 60 additions & 0 deletions src/markdown_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
Generate automatic command index from a program.

Usage:
make-readme [options] COMMAND

It outputs a Markdown section with program name,
help and version information.

Works for any installed program that has --help
and --version options. Especially useful for Docopt.
It can be used with the following command to generate readme files:
pip install -e .

Options:
-h LEVEL, --heading LEVEL Start from hLEVEL heading [default: 2].
--help Display this message.
--version Display version information.
"""

VERSION = '0.9'


import sys
import re

import subprocess

from docopt import docopt


TEXT = """{title_heading} {command_name} ({version})

```
{help_text}
```
"""


def doc_for(command_name, fmt_string=TEXT, title_heading="##"):
version = subprocess.check_output([command_name, '--version']).strip().decode('utf-8')
help_text = subprocess.check_output([command_name, '--help']).strip().decode('utf-8')

return fmt_string.format(
command_name=command_name,
title_heading=title_heading,
version=version,
help_text=help_text
)


def main():
arguments = docopt(__doc__, version=VERSION)

command = arguments['COMMAND']

print(doc_for(
command,
title_heading='#' * int(arguments['--heading'])
), end='')
Empty file added src/markdown_help/__init__.py
Empty file.