Skip to content
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# MD Click

MD-Click is a command line tool for creating `.md` files for any python's click CLI projects.

# The Problem

After creating new CLI project using click, we couldn't found out any tool that generates automatic
`.md` files documentation per each command. This is the reason we've create this quick and easy tool.
`.md` files documentation per each command. This is the reason we've created this quick and easy tool.

# The Solution

MD-Click creates `.md` files per each command exists under the `click` project CLI.
The tool runs recursively and generates a markdown file per each command, and sub commands.

# Installation

Just install it using pip:

```bash
> pip install md-click
```
Expand Down Expand Up @@ -41,14 +45,14 @@ def full_name(**kwargs):
""" A CLI that gets name and last name and returns the full name"""
firstname = kwargs.get('name')
lastname = kwargs.get('lastname')

click.secho(f'The full name is: {firstname} {lastname}', color='yellow')
```

and we want to create a nice md files per each command, we'll run the next cli command:

```shell
> mdclick dumps --baseModule=app.cli --baseCommand=main --docPath=./docs/commands
> mdclick dumps --baseModule=app.cli --baseCommand=main --docsPath=./docs/commands
```

The output:
Expand All @@ -60,4 +64,3 @@ The output:

As you can assume, all of the markdown files under `docs/commands` in this repository, generated automatically by `mdclick` command.
Use them as a reference.

11 changes: 7 additions & 4 deletions md_click/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click
import pathlib
import importlib
import pathlib

import click

md_base_template = """
# {command_name}
Expand Down Expand Up @@ -50,10 +51,10 @@ def dump_helper(base_command, docs_dir):
options = {
opt.name: {
"usage": '\n'.join(opt.opts),
"prompt": opt.prompt,
"prompt": None if type(opt) == click.core.Argument else opt.prompt,
"required": opt.required,
"default": opt.default,
"help": opt.help,
"help": None if type(opt) == click.core.Argument else opt.help,
"type": str(opt.type)
}
for opt in helpdct.get('params', [])
Expand Down Expand Up @@ -87,10 +88,12 @@ def dump_helper(base_command, docs_dir):
with open(md_file_path, 'w') as md_file:
md_file.write(md_template)


@click.group()
def cli():
pass


@cli.command('dumps')
@click.option('--baseModule', help='The base command module path to import', required=True)
@click.option('--baseCommand', help='The base command function to import', required=True)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
click>=7.0.0,<=7.1.2
click>=7.0.0,<=8.1.3