Skip to main content

A tool for bootstrapping and managing documentation project structures

Project description

DocStrap

A tool for creating structured documentation hierarchies.

Installation

# Using pipx (recommended for CLI usage)
pipx install docstrap

# Using pip
pip install docstrap

# Using poetry
poetry add docstrap

Usage

CLI

Generate a starter configuration:

# Create a new docstrap.yaml with defaults
docstrap init

# Overwrite existing config
docstrap init -f

Create documentation structure:

# Create structure using config
docstrap create -c docstrap.yaml

# Create in specific directory
docstrap create -c docstrap.yaml -d /path/to/project

# Preview changes without making them
docstrap create -c docstrap.yaml --dry-run

# Skip confirmation prompts
docstrap create -c docstrap.yaml -y

# Enable verbose output
docstrap create -c docstrap.yaml -v

Library

from pathlib import Path
from docstrap import DocumentationManager, StructureConfig, SilentFileHandler

# Load config from YAML
config = StructureConfig.from_yaml("docstrap.yaml")

# Or create programmatically
config = StructureConfig(
    docs_dir="docs",  # Use "." for project root
    use_numbered_prefix=True,
    use_markdown_headings=True,
    initial_prefix=10,
    dir_start_prefix=20,
    prefix_step=10,
    padding_width=3,
    directories={
        "guides": ["getting-started.md"],
        "reference": ["api.md"]
    },
    top_level_files=["index.md"]
)

# Choose handler:
# - SilentFileHandler: No prompts
# - InteractiveFileHandler: Prompt before changes
# - DryRunFileHandler: Preview only
handler = SilentFileHandler()

# Create structure
manager = DocumentationManager(config, handler)
manager.create_structure(Path("/path/to/project"))  # Optional path

Configuration

The easiest way to get started is to generate a config file:

docstrap init

This creates a docstrap.yaml with sensible defaults that you can customize:

# Documentation directory (use "." for project root)
docs_dir: "docs"

# Enable/disable numbered prefixes (010_, 020_, etc.)
use_numbered_prefix: true

# Enable/disable markdown h1 headings in .md files
use_markdown_headings: true

# Numbering configuration
initial_prefix: 10  # Start with 010
dir_start_prefix: 20  # Start with 020
prefix_step: 10  # Increment by 10
padding_width: 3  # For 010, 020, etc.

# Directory structure
directories:
  guides:
    - getting-started.md
    - configuration.md
  reference:
    - api.md
  examples:
    - basic.md
    - advanced.md

# Top-level files
top_level_files:
  - index.md

Output Example

With use_numbered_prefix: true:

docs/
├── README.md
├── 010_index.md
├── 020_guides/
│   ├── 010_getting-started.md
│   └── 020_configuration.md
├── 040_reference/
│   └── 010_api.md
└── 060_examples/
    ├── 010_basic.md
    └── 020_advanced.md

With use_numbered_prefix: false:

docs/
├── README.md
├── index.md
├── guides/
│   ├── getting-started.md
│   └── configuration.md
├── reference/
│   └── api.md
└── examples/
    ├── basic.md
    └── advanced.md

Development

# Setup
git clone https://github.com/yourusername/docstrap.git
cd docstrap
poetry install

# Setup pre-commit hooks
poetry run pre-commit install

# Test
poetry run pytest

# Lint (also run automatically on commit)
poetry run black .
poetry run isort .
poetry run mypy src/docstrap
poetry run pylint src/docstrap

License

MIT - see LICENSE.md

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

docstrap-0.1.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

docstrap-0.1.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file docstrap-0.1.1.tar.gz.

File metadata

  • Download URL: docstrap-0.1.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for docstrap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a236869a7dbe26dac173a575bfd657d6ed95eaa7661918de62e12505c9a76368
MD5 dc46abeba217eb32a188f84e3507cf3c
BLAKE2b-256 03005487db493a461a55920c763e47e9e6966e84e1b10a7d709d52aeef90cba0

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstrap-0.1.1.tar.gz:

Publisher: publish.yml on tjcunliffe/docstrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstrap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docstrap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for docstrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c35354d2fad735f066cc31ee33cb85e52773b00e93c3f31f5162e0a96620cf8
MD5 9c55a19a94b1af9d58c5b50735a42940
BLAKE2b-256 98c483493f3382485c17db413ca7a7f80a8d491922e77ab2097c81678833ab54

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstrap-0.1.1-py3-none-any.whl:

Publisher: publish.yml on tjcunliffe/docstrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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