A CLI tool and Python library for generating professional documents from Markdown sources
Project description
Schopenhauer's Will
The Will to Document
A powerful CLI tool and Python library for generating Word documents from YAML/JSON specifications
Documentation • Installation • Quick Start • Features • API
Overview
Schopenhauer transforms YAML or JSON specifications into professional Word documents (.docx). Named after the philosopher Arthur Schopenhauer and his work "The World as Will and Representation," this tool embodies the will to create beautiful documents programmatically.
Why Schopenhauer?
- Version Control Friendly: Document specs are plain text (YAML/JSON)
- Reproducible: Same spec always produces the same output
- Automatable: Perfect for CI/CD pipelines and batch processing
- Customizable: Full control over styling, templates, and content
- Cloud Ready: REST API for microservices and cloud deployment
Installation
pip install schopenhauer
Optional Dependencies
# With REST API server
pip install schopenhauer[api]
# With documentation tools
pip install schopenhauer[docs]
# Everything
pip install schopenhauer[all]
Quick Start
CLI Usage
# Create a simple document
will create -o report.docx --title "Annual Report" --author "Jane Doe"
# Generate from YAML specification
will generate spec.yaml -o output.docx
# Initialize a YAML template
will template init report -o my-report.yaml
# Interactive document creation
will new -o document.docx
YAML Specification
Create a file report.yaml:
title: Quarterly Report
subtitle: Q4 2024 Results
author: Analytics Team
page_size: letter
margins: moderate
table_of_contents: true
sections:
- type: section
title: Executive Summary
- type: content
text: |
This report summarizes the key achievements
and metrics for the fourth quarter.
- type: content
title: Key Highlights
bullets:
- Revenue increased by 25%
- Customer satisfaction at all-time high
- New product launch successful
- type: table
title: Performance Metrics
headers: [Metric, Q3, Q4, Change]
data:
- [Revenue, "$1.2M", "$1.5M", "+25%"]
- [Users, "10K", "15K", "+50%"]
Generate the document:
will generate report.yaml -o quarterly-report.docx
Python API
from will import WordDocument, DocumentBuilder
# Simple approach
doc = WordDocument()
doc.add_title("My Report", subtitle="2024 Edition")
doc.add_heading("Introduction", level=1)
doc.add_paragraph("Welcome to the report.")
doc.add_bullets(["Point 1", "Point 2", "Point 3"])
doc.add_table(
data=[["Alice", "Engineering"], ["Bob", "Sales"]],
headers=["Name", "Department"]
)
doc.save("report.docx")
# Fluent builder approach
(DocumentBuilder()
.set_title("My Report")
.add_heading("Introduction")
.add_paragraph("Welcome to the report.")
.add_bullets(["Point 1", "Point 2"])
.save("report.docx"))
Features
Content Types
- Headings: Multiple levels (H1-H5) with custom styling
- Paragraphs: Rich text with formatting options
- Lists: Bullet and numbered lists with nesting
- Tables: Data tables with headers and styling
- Images: Inline images with captions
- Quotes: Blockquotes with attribution
- Code Blocks: Formatted code snippets
- Page Breaks: Manual page control
- Table of Contents: Automatic TOC generation
Document Features
- Templates: Built-in templates for reports, memos, proposals, etc.
- Placeholders:
{{PLACEHOLDER}}syntax for dynamic content - Headers/Footers: Configurable with page numbers
- Page Setup: Custom sizes, margins, orientation
- Styling: Brand colors, fonts, and formatting
Deployment Options
- CLI Tool:
willcommand for terminal usage - Python Library: Full API for programmatic use
- REST API: FastAPI server for cloud deployment
- Docker: Containerized deployment
- GCP Cloud Run: One-click deployment script
CLI Commands
| Command | Description |
|---|---|
will create |
Create a new document |
will generate |
Generate from YAML/JSON spec |
will inspect |
Inspect document or template |
will new |
Interactive document creation |
will add |
Add content to existing document |
will replace |
Replace placeholders |
will template |
Template management |
will cloud |
Cloud API commands |
Templates
Built-in templates for common document types:
default- Clean, professional defaultreport- Business report with header/footermemo- Internal memo formatletter- Formal business letteracademic- Academic paper (APA-style)proposal- Project proposalmanual- Technical documentationcontract- Legal contract format- And more...
# List templates
will template list
# Use a template
will create -o doc.docx --template report --title "Report"
# Initialize YAML from template
will template init proposal -o my-proposal.yaml
REST API
Deploy as a REST API for cloud-based document generation:
# Start the server
uvicorn will.api:app --host 0.0.0.0 --port 8000
# Or with Docker
docker build -t schopenhauer .
docker run -p 8000:8000 schopenhauer
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/templates |
GET | List templates |
/generate |
POST | Generate document |
/inspect |
POST | Inspect template |
/replace |
POST | Replace placeholders |
/batch/generate |
POST | Batch generation |
Example Request
curl -X POST "http://localhost:8000/generate" \
-H "Content-Type: application/json" \
-d '{
"title": "My Report",
"sections": [
{"type": "heading", "title": "Introduction", "level": 1},
{"type": "content", "text": "Hello, World!"}
]
}' \
--output report.docx
Cloud Deployment
GCP Cloud Run
# Deploy to Cloud Run
./deploy.sh --project my-project --region us-central1
# Build only
./deploy.sh --build-only --local
Docker
# Build image
docker build -t schopenhauer .
# Run container
docker run -p 8000:8000 schopenhauer
# Access API
curl http://localhost:8000/health
Documentation
Full documentation is available at schopenhauer.github.io/schopenhauer.
Building Docs Locally
pip install schopenhauer[docs]
mkdocs serve
Development
Setup
# Clone repository
git clone https://github.com/schopenhauer/schopenhauer.git
cd schopenhauer
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run linters
black src tests
ruff check src tests
mypy src
Running Tests
# All tests
pytest
# With coverage
pytest --cov=will --cov-report=html
# Specific test file
pytest tests/test_core.py
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Named after Arthur Schopenhauer (1788-1860), German philosopher
- Built with python-docx
- CLI powered by Click
- API built with FastAPI
The Will to Document
Made with ♥ by the Schopenhauer Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file schopenhauer-0.2.0.tar.gz.
File metadata
- Download URL: schopenhauer-0.2.0.tar.gz
- Upload date:
- Size: 22.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182299e9f8dc192295302e825bb10ee8749a117267dbe79c68982783e9e15a47
|
|
| MD5 |
48a3a5bdfe8634785448da97c5f467ab
|
|
| BLAKE2b-256 |
6852ef710c81b494c812268293720608d4bafd69c8a91b77d69b4f1393981ae8
|
Provenance
The following attestation bundles were made for schopenhauer-0.2.0.tar.gz:
Publisher:
publish.yml on yanndebray/schopenhauer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
schopenhauer-0.2.0.tar.gz -
Subject digest:
182299e9f8dc192295302e825bb10ee8749a117267dbe79c68982783e9e15a47 - Sigstore transparency entry: 984571210
- Sigstore integration time:
-
Permalink:
yanndebray/schopenhauer@fb3cb411c24b080d3b9ef4c55dcc933e82ad7d0a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yanndebray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fb3cb411c24b080d3b9ef4c55dcc933e82ad7d0a -
Trigger Event:
release
-
Statement type:
File details
Details for the file schopenhauer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: schopenhauer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddcbfa64fafe04b1e666e48d8f3ecb2873c783bb5c37bdf0519ada43035cf4f0
|
|
| MD5 |
1f5f2819ebb0f97f867b63b27aef33f4
|
|
| BLAKE2b-256 |
5d382b4c6824a93629e4354152160e3ccf969c66202ed54a1f4d84b9364371cc
|
Provenance
The following attestation bundles were made for schopenhauer-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on yanndebray/schopenhauer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
schopenhauer-0.2.0-py3-none-any.whl -
Subject digest:
ddcbfa64fafe04b1e666e48d8f3ecb2873c783bb5c37bdf0519ada43035cf4f0 - Sigstore transparency entry: 984571227
- Sigstore integration time:
-
Permalink:
yanndebray/schopenhauer@fb3cb411c24b080d3b9ef4c55dcc933e82ad7d0a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yanndebray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fb3cb411c24b080d3b9ef4c55dcc933e82ad7d0a -
Trigger Event:
release
-
Statement type: