leafpress 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. leafpress-0.1.2/PKG-INFO +189 -0
  2. leafpress-0.1.2/README.md +147 -0
  3. leafpress-0.1.2/pyproject.toml +100 -0
  4. leafpress-0.1.2/src/leafpress/__init__.py +10 -0
  5. leafpress-0.1.2/src/leafpress/__main__.py +5 -0
  6. leafpress-0.1.2/src/leafpress/cli.py +307 -0
  7. leafpress-0.1.2/src/leafpress/config.py +236 -0
  8. leafpress-0.1.2/src/leafpress/docx/__init__.py +0 -0
  9. leafpress-0.1.2/src/leafpress/docx/html_converter.py +346 -0
  10. leafpress-0.1.2/src/leafpress/docx/renderer.py +310 -0
  11. leafpress-0.1.2/src/leafpress/docx/styles.py +56 -0
  12. leafpress-0.1.2/src/leafpress/exceptions.py +21 -0
  13. leafpress-0.1.2/src/leafpress/git_info.py +92 -0
  14. leafpress-0.1.2/src/leafpress/html/__init__.py +0 -0
  15. leafpress-0.1.2/src/leafpress/html/renderer.py +164 -0
  16. leafpress-0.1.2/src/leafpress/html/styles.py +328 -0
  17. leafpress-0.1.2/src/leafpress/html/templates/cover.html.j2 +21 -0
  18. leafpress-0.1.2/src/leafpress/html/templates/document.html.j2 +33 -0
  19. leafpress-0.1.2/src/leafpress/html/templates/page.html.j2 +9 -0
  20. leafpress-0.1.2/src/leafpress/html/templates/toc.html.j2 +12 -0
  21. leafpress-0.1.2/src/leafpress/markdown_renderer.py +184 -0
  22. leafpress-0.1.2/src/leafpress/mkdocs_parser.py +176 -0
  23. leafpress-0.1.2/src/leafpress/odt/__init__.py +0 -0
  24. leafpress-0.1.2/src/leafpress/odt/renderer.py +514 -0
  25. leafpress-0.1.2/src/leafpress/pdf/__init__.py +0 -0
  26. leafpress-0.1.2/src/leafpress/pdf/renderer.py +149 -0
  27. leafpress-0.1.2/src/leafpress/pdf/styles.py +166 -0
  28. leafpress-0.1.2/src/leafpress/pdf/templates/base.css +326 -0
  29. leafpress-0.1.2/src/leafpress/pdf/templates/cover.html.j2 +27 -0
  30. leafpress-0.1.2/src/leafpress/pdf/templates/page.html.j2 +9 -0
  31. leafpress-0.1.2/src/leafpress/pdf/templates/toc.html.j2 +16 -0
  32. leafpress-0.1.2/src/leafpress/pipeline.py +225 -0
  33. leafpress-0.1.2/src/leafpress/source.py +74 -0
  34. leafpress-0.1.2/src/leafpress/ui/__init__.py +1 -0
  35. leafpress-0.1.2/src/leafpress/ui/app.py +339 -0
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.3
2
+ Name: leafpress
3
+ Version: 0.1.2
4
+ Summary: Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding
5
+ Keywords: mkdocs,pdf,docx,documentation,converter
6
+ Author: Shane Hutchins
7
+ Author-email: Shane Hutchins <hutchins@users.noreply.github.com>
8
+ License: MIT
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Documentation
16
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
17
+ Requires-Dist: typer>=0.12.0
18
+ Requires-Dist: rich>=13.0.0
19
+ Requires-Dist: pyyaml>=6.0
20
+ Requires-Dist: pydantic>=2.0
21
+ Requires-Dist: markdown>=3.5
22
+ Requires-Dist: pymdown-extensions>=10.0
23
+ Requires-Dist: pygments>=2.17
24
+ Requires-Dist: weasyprint>=62.0
25
+ Requires-Dist: python-docx>=1.1.0
26
+ Requires-Dist: gitpython>=3.1.40
27
+ Requires-Dist: jinja2>=3.1
28
+ Requires-Dist: beautifulsoup4>=4.12
29
+ Requires-Dist: lxml>=5.0
30
+ Requires-Dist: requests>=2.32
31
+ Requires-Dist: python-dotenv>=1.0
32
+ Requires-Dist: odfpy>=1.4.1
33
+ Requires-Dist: pyqt6>=6.6.0 ; extra == 'ui'
34
+ Requires-Dist: pyobjc-framework-cocoa>=10.0 ; sys_platform == 'darwin' and extra == 'ui'
35
+ Maintainer: Shane Hutchins
36
+ Maintainer-email: Shane Hutchins <hutchins@users.noreply.github.com>
37
+ Requires-Python: >=3.13
38
+ Project-URL: Homepage, https://leafpress.dev
39
+ Project-URL: Repository, https://github.com/hutchins/leafpress
40
+ Provides-Extra: ui
41
+ Description-Content-Type: text/markdown
42
+
43
+ # LeafPress
44
+
45
+ [![Docs](https://img.shields.io/badge/docs-leafpress.dev-2e7d32)](https://leafpress.dev/)
46
+ [![PyPI](https://img.shields.io/pypi/v/leafpress?color=2e7d32)](https://pypi.org/project/leafpress/)
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-2e7d32.svg)](https://github.com/hutchins/leafpress/blob/main/LICENSE)
48
+ [![CI](https://github.com/hutchins/leafpress/actions/workflows/ci.yml/badge.svg)](https://github.com/hutchins/leafpress/actions/workflows/ci.yml)
49
+
50
+ Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding.
51
+
52
+ **[Documentation](https://leafpress.dev/)** · **[GitHub](https://github.com/hutchins/leafpress)** · **[PyPI](https://pypi.org/project/leafpress/)**
53
+
54
+ ## Features
55
+
56
+ - Generate **PDF**, **DOCX**, **HTML**, and **ODT** output from any MkDocs project
57
+ - Cover page, table of contents, and branded footer
58
+ - Logo, colors, and metadata via a simple `leafpress.yml` config
59
+ - Git version info (tag, branch, commit) embedded in output
60
+ - Convert from **local paths** or **remote git URLs**
61
+ - **Desktop UI** — macOS/Linux/Windows menu bar app
62
+ - **CI-friendly** — configure entirely via `LEAFPRESS_*` environment variables
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ # uv
68
+ uv add leafpress
69
+
70
+ # pip
71
+ pip install leafpress
72
+
73
+ # With desktop UI (PyQt6)
74
+ uv add 'leafpress[ui]'
75
+ pip install 'leafpress[ui]'
76
+ ```
77
+
78
+ WeasyPrint requires system libraries on Linux — see [Installation docs](https://leafpress.dev/installation) for details.
79
+
80
+ ## Quick Start
81
+
82
+ ```bash
83
+ # Generate a starter branding config
84
+ leafpress init
85
+
86
+ # Convert to PDF
87
+ leafpress convert /path/to/mkdocs/project
88
+
89
+ # Convert to PDF + DOCX with branding
90
+ leafpress convert /path/to/project -f both -c leafpress.yml
91
+
92
+ # Convert to HTML or ODT
93
+ leafpress convert /path/to/project -f html
94
+ leafpress convert /path/to/project -f odt
95
+
96
+ # Convert to all formats (PDF, DOCX, HTML, ODT)
97
+ leafpress convert /path/to/project -f all -c leafpress.yml
98
+
99
+ # Convert from a remote git repo
100
+ leafpress convert https://github.com/org/repo -b main -f pdf
101
+
102
+ # Show site info (pages, nav, git status)
103
+ leafpress info /path/to/project
104
+ ```
105
+
106
+ ## Desktop UI
107
+
108
+ ```bash
109
+ # Launch menu bar / system tray app
110
+ leafpress ui
111
+
112
+ # Open the window immediately on launch
113
+ leafpress ui --show
114
+ ```
115
+
116
+ On macOS, LeafPress lives in the menu bar (not the Dock). Click the icon to open the conversion window. Supports all the same options as the CLI, including "Open after conversion".
117
+
118
+ Requires the `[ui]` extra: `pip install 'leafpress[ui]'`
119
+
120
+ ## CI / GitHub Actions
121
+
122
+ LeafPress can be configured entirely via environment variables — no `leafpress.yml` needed.
123
+
124
+ ```yaml
125
+ jobs:
126
+ docs:
127
+ runs-on: ubuntu-latest
128
+ steps:
129
+ - uses: actions/checkout@v4
130
+
131
+ - name: Install WeasyPrint system dependencies
132
+ run: sudo apt-get install -y libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0
133
+
134
+ - name: Install leafpress
135
+ run: pip install leafpress
136
+
137
+ - name: Convert docs to PDF
138
+ env:
139
+ LEAFPRESS_COMPANY_NAME: ${{ vars.COMPANY_NAME }}
140
+ LEAFPRESS_PROJECT_NAME: My Project
141
+ LEAFPRESS_PRIMARY_COLOR: "#1a73e8"
142
+ run: leafpress convert . -f pdf -o dist/
143
+
144
+ - name: Upload artifact
145
+ uses: actions/upload-artifact@v4
146
+ with:
147
+ name: documentation
148
+ path: dist/*.pdf
149
+ ```
150
+
151
+ You can also place a `.env` file in your project root — LeafPress loads it automatically. Shell environment variables always take priority over `.env` values.
152
+
153
+ See [CI / GitHub Actions docs](https://leafpress.dev/ci) for the full environment variable reference.
154
+
155
+ ## Branding Configuration
156
+
157
+ Create `leafpress.yml` in your project root (or run `leafpress init`):
158
+
159
+ ```yaml
160
+ company_name: "Acme Corp"
161
+ project_name: "Platform Docs"
162
+ logo_path: "./logo.png" # local path or https:// URL
163
+ subtitle: "Internal Documentation"
164
+ author: "Engineering Team"
165
+ primary_color: "#1a73e8" # 6-digit hex
166
+ accent_color: "#ffffff"
167
+
168
+ footer:
169
+ include_tag: true
170
+ include_date: true
171
+ include_commit: true
172
+ include_branch: false
173
+ custom_text: "Confidential"
174
+
175
+ pdf:
176
+ page_size: "A4"
177
+ margin_top: "25mm"
178
+ margin_bottom: "25mm"
179
+ margin_left: "20mm"
180
+ margin_right: "20mm"
181
+ ```
182
+
183
+ ## Development
184
+
185
+ ```bash
186
+ uv sync --group dev
187
+ uv run pytest tests/ -v
188
+ uv run ruff check src/
189
+ ```
@@ -0,0 +1,147 @@
1
+ # LeafPress
2
+
3
+ [![Docs](https://img.shields.io/badge/docs-leafpress.dev-2e7d32)](https://leafpress.dev/)
4
+ [![PyPI](https://img.shields.io/pypi/v/leafpress?color=2e7d32)](https://pypi.org/project/leafpress/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-2e7d32.svg)](https://github.com/hutchins/leafpress/blob/main/LICENSE)
6
+ [![CI](https://github.com/hutchins/leafpress/actions/workflows/ci.yml/badge.svg)](https://github.com/hutchins/leafpress/actions/workflows/ci.yml)
7
+
8
+ Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding.
9
+
10
+ **[Documentation](https://leafpress.dev/)** · **[GitHub](https://github.com/hutchins/leafpress)** · **[PyPI](https://pypi.org/project/leafpress/)**
11
+
12
+ ## Features
13
+
14
+ - Generate **PDF**, **DOCX**, **HTML**, and **ODT** output from any MkDocs project
15
+ - Cover page, table of contents, and branded footer
16
+ - Logo, colors, and metadata via a simple `leafpress.yml` config
17
+ - Git version info (tag, branch, commit) embedded in output
18
+ - Convert from **local paths** or **remote git URLs**
19
+ - **Desktop UI** — macOS/Linux/Windows menu bar app
20
+ - **CI-friendly** — configure entirely via `LEAFPRESS_*` environment variables
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ # uv
26
+ uv add leafpress
27
+
28
+ # pip
29
+ pip install leafpress
30
+
31
+ # With desktop UI (PyQt6)
32
+ uv add 'leafpress[ui]'
33
+ pip install 'leafpress[ui]'
34
+ ```
35
+
36
+ WeasyPrint requires system libraries on Linux — see [Installation docs](https://leafpress.dev/installation) for details.
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ # Generate a starter branding config
42
+ leafpress init
43
+
44
+ # Convert to PDF
45
+ leafpress convert /path/to/mkdocs/project
46
+
47
+ # Convert to PDF + DOCX with branding
48
+ leafpress convert /path/to/project -f both -c leafpress.yml
49
+
50
+ # Convert to HTML or ODT
51
+ leafpress convert /path/to/project -f html
52
+ leafpress convert /path/to/project -f odt
53
+
54
+ # Convert to all formats (PDF, DOCX, HTML, ODT)
55
+ leafpress convert /path/to/project -f all -c leafpress.yml
56
+
57
+ # Convert from a remote git repo
58
+ leafpress convert https://github.com/org/repo -b main -f pdf
59
+
60
+ # Show site info (pages, nav, git status)
61
+ leafpress info /path/to/project
62
+ ```
63
+
64
+ ## Desktop UI
65
+
66
+ ```bash
67
+ # Launch menu bar / system tray app
68
+ leafpress ui
69
+
70
+ # Open the window immediately on launch
71
+ leafpress ui --show
72
+ ```
73
+
74
+ On macOS, LeafPress lives in the menu bar (not the Dock). Click the icon to open the conversion window. Supports all the same options as the CLI, including "Open after conversion".
75
+
76
+ Requires the `[ui]` extra: `pip install 'leafpress[ui]'`
77
+
78
+ ## CI / GitHub Actions
79
+
80
+ LeafPress can be configured entirely via environment variables — no `leafpress.yml` needed.
81
+
82
+ ```yaml
83
+ jobs:
84
+ docs:
85
+ runs-on: ubuntu-latest
86
+ steps:
87
+ - uses: actions/checkout@v4
88
+
89
+ - name: Install WeasyPrint system dependencies
90
+ run: sudo apt-get install -y libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0
91
+
92
+ - name: Install leafpress
93
+ run: pip install leafpress
94
+
95
+ - name: Convert docs to PDF
96
+ env:
97
+ LEAFPRESS_COMPANY_NAME: ${{ vars.COMPANY_NAME }}
98
+ LEAFPRESS_PROJECT_NAME: My Project
99
+ LEAFPRESS_PRIMARY_COLOR: "#1a73e8"
100
+ run: leafpress convert . -f pdf -o dist/
101
+
102
+ - name: Upload artifact
103
+ uses: actions/upload-artifact@v4
104
+ with:
105
+ name: documentation
106
+ path: dist/*.pdf
107
+ ```
108
+
109
+ You can also place a `.env` file in your project root — LeafPress loads it automatically. Shell environment variables always take priority over `.env` values.
110
+
111
+ See [CI / GitHub Actions docs](https://leafpress.dev/ci) for the full environment variable reference.
112
+
113
+ ## Branding Configuration
114
+
115
+ Create `leafpress.yml` in your project root (or run `leafpress init`):
116
+
117
+ ```yaml
118
+ company_name: "Acme Corp"
119
+ project_name: "Platform Docs"
120
+ logo_path: "./logo.png" # local path or https:// URL
121
+ subtitle: "Internal Documentation"
122
+ author: "Engineering Team"
123
+ primary_color: "#1a73e8" # 6-digit hex
124
+ accent_color: "#ffffff"
125
+
126
+ footer:
127
+ include_tag: true
128
+ include_date: true
129
+ include_commit: true
130
+ include_branch: false
131
+ custom_text: "Confidential"
132
+
133
+ pdf:
134
+ page_size: "A4"
135
+ margin_top: "25mm"
136
+ margin_bottom: "25mm"
137
+ margin_left: "20mm"
138
+ margin_right: "20mm"
139
+ ```
140
+
141
+ ## Development
142
+
143
+ ```bash
144
+ uv sync --group dev
145
+ uv run pytest tests/ -v
146
+ uv run ruff check src/
147
+ ```
@@ -0,0 +1,100 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.10.9,<0.11"]
3
+ build-backend = "uv_build"
4
+
5
+ [project]
6
+ name = "leafpress"
7
+ version = "0.1.2"
8
+ description = "Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding"
9
+ readme = "README.md"
10
+ authors = [{name = "Shane Hutchins", email = "hutchins@users.noreply.github.com"}]
11
+ maintainers = [
12
+ {name = "Shane Hutchins", email = "hutchins@users.noreply.github.com"}
13
+ ]
14
+ requires-python = ">=3.13"
15
+ license = {text = "MIT"}
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Documentation",
24
+ "Topic :: Text Processing :: Markup :: Markdown",
25
+ ]
26
+ keywords = ["mkdocs", "pdf", "docx", "documentation", "converter"]
27
+
28
+ dependencies = [
29
+ "typer>=0.12.0",
30
+ "rich>=13.0.0",
31
+ "pyyaml>=6.0",
32
+ "pydantic>=2.0",
33
+ "markdown>=3.5",
34
+ "pymdown-extensions>=10.0",
35
+ "pygments>=2.17",
36
+ "weasyprint>=62.0",
37
+ "python-docx>=1.1.0",
38
+ "gitpython>=3.1.40",
39
+ "jinja2>=3.1",
40
+ "beautifulsoup4>=4.12",
41
+ "lxml>=5.0",
42
+ "requests>=2.32",
43
+ "python-dotenv>=1.0",
44
+ "odfpy>=1.4.1",
45
+ ]
46
+
47
+ [project.optional-dependencies]
48
+ ui = [
49
+ "pyqt6>=6.6.0",
50
+ "pyobjc-framework-cocoa>=10.0; sys_platform == 'darwin'",
51
+ ]
52
+
53
+ [dependency-groups]
54
+ dev = [
55
+ "pytest>=8.0",
56
+ "pytest-cov>=5.0",
57
+ "ruff>=0.5.0",
58
+ "mypy>=1.10",
59
+ ]
60
+
61
+ [project.scripts]
62
+ leafpress = "leafpress.cli:cli"
63
+
64
+ [project.urls]
65
+ Homepage = "https://leafpress.dev"
66
+ Repository = "https://github.com/hutchins/leafpress"
67
+
68
+ [tool.uv]
69
+ package = true
70
+
71
+ [tool.uv.build-backend]
72
+ module-root = "src"
73
+
74
+ [tool.ruff]
75
+ target-version = "py310"
76
+ line-length = 100
77
+
78
+ [tool.ruff.lint]
79
+ select = ["E", "F", "I", "N", "W", "UP", "B", "SIM", "RUF"]
80
+
81
+ [tool.ruff.lint.per-file-ignores]
82
+ "src/leafpress/cli.py" = ["B008"]
83
+
84
+ [tool.pytest.ini_options]
85
+ testpaths = ["tests"]
86
+ addopts = "-v --tb=short"
87
+ markers = ["docker: tests requiring Docker (may be slow)"]
88
+
89
+ [tool.coverage.run]
90
+ source = ["leafpress"]
91
+ omit = ["src/leafpress/ui/*"]
92
+
93
+ [tool.coverage.report]
94
+ show_missing = true
95
+ skip_empty = true
96
+ fail_under = 70
97
+
98
+ [tool.mypy]
99
+ python_version = "3.10"
100
+ strict = true
@@ -0,0 +1,10 @@
1
+ """leafpress - Convert MkDocs sites to PDF, Word, HTML, and ODT documents."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("leafpress")
7
+ except PackageNotFoundError:
8
+ __version__ = "0.0.0"
9
+
10
+ from leafpress.pipeline import convert # noqa: F401
@@ -0,0 +1,5 @@
1
+ """Allow running as `python -m leafpress`."""
2
+
3
+ from leafpress.cli import cli
4
+
5
+ cli()