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
- Reference_Table.md - Function signatures and parameters
- Formats.md - Complete formatter documentation with examples
Thread Safety
All operations are thread-safe with RLock protection for cache operations and atomic file writes.
Metadata
Release files for DocPrint 1.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docprint-1.2.5.tar.gz | 15.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docprint-1.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.9 kB
Release files / docprint-1.2.5.tar.gz
| Download URL | docprint-1.2.5.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29b952f454d6a03f740d7385483001d0281c1e442ab7cd66a7bb691503dd6129
|
|
BLAKE2b-256 checksum How to use checksums |
d9229fda42716117dce1c917f53890d9c47956afe46e0fe0de62fdad2e5c05a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / docprint-1.2.5-py3-none-any.whl
| Download URL | docprint-1.2.5-py3-none-any.whl |
|---|---|
| Size | 23.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9268652a509c29a94c4996d06dd3600430fa57ab1e204848ca55efd213e132d8
|
|
BLAKE2b-256 checksum How to use checksums |
d37babcc5699032fd751d7c355117864bdcbdbf2ab509d7ff6ae11b1360eedf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|