Skip to main content

Runtime documentation generation tool for live markdown output

Project description

DocPrint

Runtime documentation generation tool that creates live markdown output with intelligent caching, content deduplication, and optional GitHub integration.

Installation

pip install docprint

Performance dependencies (recommended):

pip install docprint[performance]

Quick Start

from docprint import docPrint, docFlush, docPrintFile, enableGitCommits

# Basic usage - writes to DOC.PRINT.md
docPrint('text', 'Status', 'Application started')
docPrint('table', 'Metrics', [{'cpu': '45%', 'memory': '2.1GB'}])

# Custom output file
docPrintFile("logs/app.md")
docPrint('header', 'System Status', 'All services operational')

# Force write cached content
docFlush()

GitHub Integration

Automatically sync documentation changes to GitHub:

import os

# Enable auto-sync (requires personal access token)
enableGitCommits(True, 
                token=os.getenv('GITHUB_TOKEN'), 
                repo="username/repository")

# Custom sync interval (default: 1 minute)
enableGitCommits(True, 
                token=token, 
                repo="user/repo", 
                interval_minutes=5)

Setup requirements:

  • GitHub personal access token with repo permissions
  • Target repository must exist and be accessible
  • Respects API rate limits

File Management

# Default output
docPrint('text', 'Status', 'Running')  # → DOC.PRINT.md

# Custom files
docPrintFile("reports/daily.md")
docPrint('text', 'Report', 'Daily metrics')  # → reports/daily.md

# Reset to default
docPrintFile("")  # → DOC.PRINT.md

Creates directories automatically. Thread-safe operations with atomic file writes.

Available Formatters

Basic content: text, header, table, bullets, code_block

Structure: horizontal_rule, blockquote, ordered_list, unordered_list, footnotes, divider

Layout: flex_layout, table_layout, grid_layout

Visual: badge, html_block, css_block, svg_animation

Rich content: alert, collapsible, image, link_collection

See Formats.md for complete examples.

Smart Features

Content deduplication: Identical content automatically deduplicated

Header management: Duplicate headers get counters (Status, Status (1), Status (2))

Content updates: Same headers update existing sections in place

Auto-flush: Every 30 seconds or 1000 calls

Performance

  • Hash-based content comparison (xxhash/MD5)
  • Memory-mapped files for large documents
  • Layout content normalization
  • Zero redundant I/O operations
  • Thread-safe concurrent access

Production Example

import os
from docprint import docPrint, docPrintFile, enableGitCommits

# Application setup
docPrintFile("logs/production.md")
enableGitCommits(True, 
                token=os.getenv('GITHUB_TOKEN'), 
                repo="company/logs")

# Runtime logging
docPrint('header', 'Application Startup', f'Started at {datetime.now()}')

def process_batch(data):
    docPrint('text', 'Processing', f'Batch size: {len(data)}')
    
    if errors:
        docPrint('alert', 'Errors', error_list, alert_type='error')
    
    # Dashboard layout
    docPrint('flex_layout', 'System Status', [
        {'type': 'text', 'header': 'CPU', 'content': f'{cpu}%'},
        {'type': 'text', 'header': 'Memory', 'content': f'{mem}GB'}
    ])

Documentation

Thread Safety

All operations are thread-safe with RLock protection for cache operations and atomic file writes.

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

docprint-1.2.5.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

docprint-1.2.5-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file docprint-1.2.5.tar.gz.

File metadata

  • Download URL: docprint-1.2.5.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for docprint-1.2.5.tar.gz
Algorithm Hash digest
SHA256 29b952f454d6a03f740d7385483001d0281c1e442ab7cd66a7bb691503dd6129
MD5 306d5857b0566f211fc6ea81a5e3c95f
BLAKE2b-256 d9229fda42716117dce1c917f53890d9c47956afe46e0fe0de62fdad2e5c05a5

See more details on using hashes here.

File details

Details for the file docprint-1.2.5-py3-none-any.whl.

File metadata

  • Download URL: docprint-1.2.5-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for docprint-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9268652a509c29a94c4996d06dd3600430fa57ab1e204848ca55efd213e132d8
MD5 633f9d8125b934a8539c29b3c8317ae7
BLAKE2b-256 d37babcc5699032fd751d7c355117864bdcbdbf2ab509d7ff6ae11b1360eedf1

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