Skip to main content

DraftMk CLI automates setup and preview of MkDocs documentation using Docker, dynamic ports, and Copier templates.

Project description

draftmk

draftmk is an advanced command-line tool that automates the setup, management, and deployment of MkDocs-based documentation projects using Docker. It streamlines local previews, environment initialization, live editing, and supports CI/CD automation with flexible repository integration and configuration scaffolding for both public and internal documentation views.

Features

  • One-command environment bootstrap with optional Git initialization
  • CI-friendly flags: --no-git to skip Git setup, --repo to link existing repositories
  • Automatic port assignment (avoids conflicts)
  • Auto-generation of docs/index.md, mkdocs.public.yml, and mkdocs.internal.yml scaffolding
  • Colorful CLI output for improved user experience
  • Automatic Docker Compose setup via GitHub Gist download
  • Friendly preview logs and automatic browser launching
  • Supports seamless integration into CI pipelines

Installation

Install from PyPI:

pip install draftmk

Or add to a Poetry project:

poetry add draftmk

Requires Python ≥ 3.9, Docker, and Docker Compose.

Commands

init

Bootstraps a new DraftMk project.

draftmk init [<directory>] [--no-git] [--repo <repository-url>] [--force] [--force-git] [--template <path-or-url>]
  • Initializes .draftmk structure and .env file with dynamic ports
  • Uses Copier to scaffold (internal or custom template via --template)
  • Only initializes Git if not skipped with --no-git, or forced via --force-git
  • Uses --force to bypass directory emptiness check
  • --yes is deprecated and replaced with --force

You can override the default internal Copier template with --template, or configure one in .draftmk/settings.json.

up

Initializes the project (if needed), pulls images, builds containers, and opens the browser.

draftmk up
  • --no-browser: Do not open the frontend automatically

preview

Starts the full environment and shows Docker logs.

draftmk preview --open
  • --open: Launches the frontend in your default browser

view

Launches the frontend in your browser using the port defined in .env.

draftmk view
  • --print: Only print the preview URL instead of launching the browser

logs

Tails the last 50 lines of the .draftmk/logs/draftmk.log file.

draftmk logs

stop

Stops all DraftMk-related Docker containers.

draftmk stop

status

Shows the running status of all containers.

draftmk status

Usage Examples for CI Automation

To bootstrap a project without Git initialization (useful in CI pipelines):

draftmk init --no-git

To bootstrap and link to an existing repository:

draftmk init --repo yourusername/yourrepo

Directory Structure

.
├── .draftmk/
│   ├── config/
│   │   ├── mkdocs.internal.yml
│   │   └── mkdocs.public.yml
│   ├── site/
│   │   ├── public/
│   │   └── internal/
│   ├── logs/
│   │   └── draftmk.log
│   └── settings.json  # optional template override
├── docs/
│   └── index.md
├── .env
├── docker-compose.yml

Docker Images

DraftMk uses pre-built Docker images hosted on Docker Hub:

Docker Compose Template

DraftMk no longer downloads a remote docker-compose.yml from a GitHub Gist.

Instead, the file is scaffolded using Copier templates (either internal or from a configured template repo).

Copier Template Support

DraftMk scaffolds projects using Copier during draftmk init. To override the template, pass --template or define .draftmk/settings.json.

{
  "template_repo": "gh:your-org/your-template-repo"
}

This enables full customization of how your documentation project is initialized.

  • Copier variables supported include:
    project_name: "Your Docs"
    repo_name: "your-org/your-repo"
    site_url: "https://example.com"
    vite_env: "production"
    
  • DraftMk pre-fills dynamic ports and environment for the template using Copier's data injection.

Requirements

  • Python ≥ 3.9
  • Docker
  • Docker Compose

License

MIT © Jonatan Mata


echo "Pura Vida & Happy Coding!";

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

draftmk-0.7.4.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

draftmk-0.7.4-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file draftmk-0.7.4.tar.gz.

File metadata

  • Download URL: draftmk-0.7.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for draftmk-0.7.4.tar.gz
Algorithm Hash digest
SHA256 ac752f908f3dfe0020debab40f1942b5a39f921df9566a67f8d8ab682ae77ef7
MD5 60dc8cca07a5ebe268021bed5a94fb70
BLAKE2b-256 8a76a8899886d5f7a6ce88bd564402422a719c03cee0b10050635745e595263e

See more details on using hashes here.

File details

Details for the file draftmk-0.7.4-py3-none-any.whl.

File metadata

  • Download URL: draftmk-0.7.4-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for draftmk-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 33be6b9faf8135e90b3b3fac2e4acd6de0eb3e26025405d375a09643775920bf
MD5 df54df48fb936b279b0d6120f652cd1a
BLAKE2b-256 72c4c9ecce3fb66dcd4151a61a217b9b4c0a8e4fd4fd6809afee55c448da5e52

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