Skip to content

Commit 55e8919

Browse files
Merge pull request #2 from leonardosalasd/release/v1.0.0
feat: templates, theming, and source error checking for v1.0.0
2 parents 5018c20 + a19ba3a commit 55e8919

14 files changed

Lines changed: 936 additions & 91 deletions

File tree

README.md

Lines changed: 116 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
88
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-3776AB.svg?logo=python&logoColor=white)](https://www.python.org/downloads/)
9-
[![PyPI](https://img.shields.io/badge/PyPI-v0.1.0-006DAD.svg?logo=pypi&logoColor=white)](https://pypi.org/project/doc-engine-cli/)
9+
[![PyPI](https://img.shields.io/pypi/v/doc-engine-cli.svg?logo=pypi&logoColor=white&color=006DAD)](https://pypi.org/project/doc-engine-cli/)
10+
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/doc-engine-cli?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/doc-engine-cli)
1011
[![Typst](https://img.shields.io/badge/Powered_by-Typst-239DAD.svg?logo=typst&logoColor=white)](https://typst.app/)
1112
[![Code style: black](https://img.shields.io/badge/code_style-black-000000.svg)](https://github.com/psf/black)
1213

@@ -43,9 +44,10 @@ That's it. Zero configuration required.
4344
| Feature | Description |
4445
|---|---|
4546
| **Zero-Config** | Auto-detects `README.md`, Git author, and document title. No setup files needed. |
47+
| **Five Templates** | Academic, modern, minimal, technical, and book layouts, each with a configurable accent color. |
48+
| **Error Checking** | Reports source problems with line and column before compiling. A `--dry-run` mode runs the check on its own. |
4649
| **Premium Typography** | Inter font family with fallback chain, justified text, and optimized line spacing. |
4750
| **Code-Centric** | Syntax-highlighted code blocks with Cascadia Code font and GitHub-style backgrounds. |
48-
| **Academic Ready** | IEEE and white paper-inspired layout with cover page and table of contents. |
4951
| **Pure Python** | No external binaries required (no Pandoc, no LaTeX). Ships as a single `pip install`. |
5052
| **Cross-Platform** | Works on Windows, macOS, and Linux with Python 3.10+. |
5153

@@ -97,24 +99,29 @@ doc-engine build path/to/file.md -o output.pdf -t "Custom Title" -a "Author Name
9799

98100
## Usage
99101

100-
### CLI Reference
102+
### Commands
101103

102104
```
103-
Usage: doc-engine build [OPTIONS] [INPUT_FILE]
104-
105-
Convert a Markdown file into a professional PDF document.
105+
doc-engine build [INPUT_FILE] Convert a Markdown file into a PDF
106+
doc-engine info Show version, repository, and templates
107+
doc-engine --version Print the version and exit
108+
doc-engine --help Show all commands and flags
109+
```
106110

107-
Arguments:
108-
INPUT_FILE Path to Markdown file (default: auto-detect README.md)
111+
### `build` flags
109112

110-
Options:
111-
-o, --output TEXT Output PDF file path (default: <input>_doc.pdf)
112-
-t, --title TEXT Document title override (default: first # heading)
113-
-a, --author TEXT Author name override (default: git user.name)
114-
--open Open PDF after generation
115-
--version Show version and exit
116-
--help Show this message and exit
117-
```
113+
| Flag | Default | Description |
114+
|---|---|---|
115+
| `INPUT_FILE` | auto-detect `README.md` | Path to the Markdown file to convert. |
116+
| `-o, --output` | `<input>_doc.pdf` | Output PDF path. |
117+
| `-t, --title` | first `# heading` | Document title override. |
118+
| `-a, --author` | `git config user.name` | Author name override. |
119+
| `--template` | `academic` | Layout to render with: `academic`, `modern`, `minimal`, `technical`, `book`. |
120+
| `--accent` | template default | Accent color as a hex value (`#2563eb`) or a name (`blue`, `teal`, `rose`, ...). |
121+
| `--bib` | auto-detect `refs.bib` | Path to a custom `.bib` file for the bibliography. |
122+
| `--no-branding` | off | Hide the `doc-engine` attribution from the PDF. |
123+
| `--dry-run` | off | Check the Markdown for errors and exit without writing a PDF. |
124+
| `--open` | off | Open the PDF after it is generated. |
118125

119126
### Examples
120127

@@ -135,6 +142,22 @@ doc-engine build CONTRIBUTING.md -o contributing_guide.pdf
135142
doc-engine build -t "API Reference v2.0" -a "Engineering Team"
136143
```
137144

145+
**Pick a template and accent color:**
146+
```bash
147+
doc-engine build --template modern --accent teal
148+
doc-engine build --template technical --accent "#7c3aed"
149+
```
150+
151+
**Check for errors before building:**
152+
```bash
153+
doc-engine build --dry-run
154+
```
155+
156+
**Drop the engine attribution from the PDF:**
157+
```bash
158+
doc-engine build --no-branding
159+
```
160+
138161
**Generate and open immediately:**
139162
```bash
140163
doc-engine build --open
@@ -147,6 +170,44 @@ python -m doc_engine build README.md
147170

148171
---
149172

173+
## Templates
174+
175+
`doc-engine` ships with five layouts. Switch with `--template <name>`, and recolor any of them with `--accent`.
176+
177+
| Template | Look |
178+
|---|---|
179+
| `academic` | Serif IEEE-style report with cover page, table of contents, and running headers. The default. |
180+
| `modern` | Clean sans-serif layout with generous spacing and a left-aligned cover. |
181+
| `minimal` | No cover or table of contents — a compact title block, then straight into the content. |
182+
| `technical` | Bold layout with a filled accent banner and section markers. Good for engineering docs. |
183+
| `book` | Classic centered title page with chapter-style section breaks. |
184+
185+
```bash
186+
doc-engine build --template book
187+
doc-engine build --template modern --accent rose
188+
```
189+
190+
Accent colors take a hex value (`#0ea5e9`) or one of these names: `blue`, `sky`, `indigo`, `violet`, `purple`, `red`, `rose`, `orange`, `amber`, `green`, `emerald`, `teal`, `slate`, `black`.
191+
192+
---
193+
194+
## Checking for Errors
195+
196+
Before compiling, `doc-engine` scans the Markdown for problems and reports them with the exact line and column, so you can jump straight to the fix:
197+
198+
```
199+
README.md:42:8: error: link URL must not be empty
200+
README.md:51:1: warning: image source is empty
201+
```
202+
203+
Errors stop the build; warnings don't. Use `--dry-run` to run the check on its own without producing a PDF — handy in CI:
204+
205+
```bash
206+
doc-engine build --dry-run
207+
```
208+
209+
---
210+
150211
## Architecture
151212

152213
```
@@ -170,8 +231,8 @@ python -m doc_engine build README.md
170231
└──────┬──────┘ └───────┬──────┘
171232
│ │
172233
│ ┌──────────────┐ │
173-
└────► report.typ ◄─────┘
174-
(template)
234+
└────► templates/ ◄─────┘
235+
*.typ
175236
└──────┬──────┘
176237
177238
┌──────▼──────┐
@@ -184,9 +245,10 @@ python -m doc_engine build README.md
184245
| Stage | Module | Responsibility |
185246
|---|---|---|
186247
| **1. Input Resolution** | `cli.py` | Locate Markdown file, detect Git metadata |
187-
| **2. Markdown Parsing** | `converter.py` | Parse Markdown AST via `mistune`, emit Typst markup |
188-
| **3. Template Injection** | `compiler.py` | Merge converted content with `report.typ` template |
189-
| **4. PDF Compilation** | `compiler.py` | Compile via `typst` Python bindings |
248+
| **2. Source Checking** | `linter.py` | Report empty links and unclosed fences with line/column |
249+
| **3. Markdown Parsing** | `converter.py` | Parse Markdown AST via `mistune`, emit Typst markup |
250+
| **4. Template Injection** | `compiler.py` | Merge converted content with the selected template |
251+
| **5. PDF Compilation** | `compiler.py` | Compile via `typst` Python bindings |
190252

191253
---
192254

@@ -210,9 +272,9 @@ The converter module parses Markdown using [`mistune`](https://github.com/leptur
210272

211273
Special characters (`#`, `$`, `@`, `*`, `_`, etc.) are automatically escaped to prevent Typst interpretation.
212274

213-
### PDF Template
275+
### PDF Templates
214276

215-
The included `report.typ` template provides:
277+
Each template lives in `doc_engine/templates/` and exposes the same `setup_doc` entry point, so the compiler can swap between them with `--template`. The default `academic` template provides:
216278

217279
- **Cover page** with title, author, and date
218280
- **Table of contents** with depth-3 navigation
@@ -221,6 +283,8 @@ The included `report.typ` template provides:
221283
- **Code blocks** with rounded corners and subtle borders
222284
- **Heading hierarchy** with accent-colored H2 sections
223285

286+
The other templates (`modern`, `minimal`, `technical`, `book`) keep the same content but change the fonts, layout, and cover. The accent color is injected at compile time, so `--accent` recolors any of them.
287+
224288
---
225289

226290
## Project Structure
@@ -233,11 +297,18 @@ doc-engine-cli/
233297
│ ├── cli.py # Click-based CLI + Git detection
234298
│ ├── converter.py # Markdown → Typst transpiler
235299
│ ├── compiler.py # Typst → PDF compilation engine
300+
│ ├── linter.py # Source checks (line/column reporting)
236301
│ └── templates/
237-
│ └── report.typ # Professional Typst report template
302+
│ ├── academic.typ # Default IEEE-style report
303+
│ ├── modern.typ # Clean sans-serif layout
304+
│ ├── minimal.typ # Compact, no cover page
305+
│ ├── technical.typ # Accent banner + section markers
306+
│ └── book.typ # Centered title page, chapter breaks
238307
├── tests/
239308
│ ├── __init__.py
240-
│ └── test_converter.py # Unit tests for converter module
309+
│ ├── test_converter.py # Unit tests for the converter
310+
│ ├── test_linter.py # Unit tests for the linter
311+
│ └── test_cli.py # CLI and template/accent tests
241312
├── pyproject.toml # Package configuration + dependencies
242313
├── LICENSE # MIT License
243314
├── .gitignore
@@ -287,6 +358,22 @@ python -m doc_engine build README.md -o docs_output.pdf
287358

288359
---
289360

361+
## Docker
362+
363+
A container image is published to GitHub Container Registry on every release. Mount your project into `/workspace` and run `build` as usual:
364+
365+
```bash
366+
docker run --rm -v "$PWD:/workspace" ghcr.io/leonardosalasd/doc-engine-cli build
367+
```
368+
369+
The entrypoint is `doc-engine`, so you can pass any command or flag:
370+
371+
```bash
372+
docker run --rm -v "$PWD:/workspace" ghcr.io/leonardosalasd/doc-engine-cli build --template modern --accent teal
373+
```
374+
375+
---
376+
290377
## Supported Markdown Elements
291378

292379
- [x] Headings (H1–H6)
@@ -307,10 +394,11 @@ python -m doc_engine build README.md -o docs_output.pdf
307394

308395
## Roadmap
309396

310-
- [ ] Custom template injection via `--template` flag
397+
- [x] Template selection via `--template` flag
398+
- [x] Configurable accent color via `--accent`
399+
- [x] Source error checking with line/column and `--dry-run`
400+
- [ ] User-supplied template files (point `--template` at a path)
311401
- [ ] Multi-file documentation merge
312-
- [ ] GitHub Actions integration for CI/CD pipelines
313-
- [ ] Dark-mode PDF theme variant
314402
- [ ] Image downloading and embedding for remote URLs
315403
- [ ] YAML front-matter support for metadata override
316404
- [ ] PDF/A compliance for archival

doc_engine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""doc-engine-cli: Modern Markdown to Typst compiler."""
2-
__version__ = "0.1.2"
2+
__version__ = "1.0.0"

0 commit comments

Comments
 (0)