Skip to content

Commit b924878

Browse files
committed
Release v2.1.0: Theme System
- Add complete theme infrastructure with 6 pre-built themes - Add technical architecture example with PlantUML integration - Implement theme customization capabilities - Add comprehensive documentation and release notes
2 parents a5d8de4 + 251788c commit b924878

25 files changed

+2835
-12
lines changed

04_tech_architecture

8.59 MB
Binary file not shown.

RELEASE_NOTES_v2.1.0.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# Release Notes - v2.1.0
2+
3+
## 🎨 go-docx v2.1.0 - Themes & Advanced Styling
4+
5+
**Release Date**: October 31, 2025
6+
7+
We're excited to announce **v2.1.0**, bringing powerful **theme support** and **advanced styling capabilities** to go-docx!
8+
9+
---
10+
11+
## 🆕 What's New
12+
13+
### 🎨 Theme System
14+
15+
Complete theme infrastructure for consistent document styling:
16+
17+
-**Pre-built Themes** - 6 professional themes ready to use
18+
-**Theme Colors** - Comprehensive color palettes (Primary, Secondary, Accent, Background, Text, etc.)
19+
-**Theme Fonts** - Font families for body, headings, and monospace
20+
-**Theme Spacing** - Configurable spacing for paragraphs, headings, and sections
21+
-**Custom Themes** - Clone and customize existing themes or create from scratch
22+
-**Theme Application** - Apply themes globally to documents with one method call
23+
24+
**Available Themes:**
25+
26+
| Theme | Description | Best For |
27+
|-------|-------------|----------|
28+
| `DefaultTheme` | Classic professional look | Business documents, reports |
29+
| `ModernLight` | Clean, contemporary design | Marketing materials, proposals |
30+
| `TechPresentation` | Tech-focused with blue accents | Technical documentation, specs |
31+
| `TechDarkMode` | Dark theme for technical docs | Developer documentation, coding guides |
32+
| `AcademicFormal` | Traditional academic styling | Research papers, academic reports |
33+
| `MinimalistClean` | Minimal, distraction-free | Focus documents, minimalist designs |
34+
35+
**Example: Using Themes**
36+
37+
```go
38+
package main
39+
40+
import (
41+
"log"
42+
docx "github.com/mmonterroca/docxgo"
43+
"github.com/mmonterroca/docxgo/domain"
44+
"github.com/mmonterroca/docxgo/themes"
45+
)
46+
47+
func main() {
48+
// Create document with theme
49+
doc := docx.NewDocument()
50+
themes.TechPresentation.ApplyTo(doc)
51+
52+
// Get theme colors and fonts
53+
colors := themes.TechPresentation.Colors()
54+
fonts := themes.TechPresentation.Fonts()
55+
56+
// Use theme settings
57+
title, _ := doc.AddParagraph()
58+
title.SetStyle(domain.StyleIDHeading1)
59+
titleRun, _ := title.AddRun()
60+
titleRun.AddText("Technical Architecture Document")
61+
62+
body, _ := doc.AddParagraph()
63+
bodyRun, _ := body.AddRun()
64+
bodyRun.AddText("This document uses the Tech Presentation theme")
65+
bodyRun.SetFont(domain.Font{Name: fonts.Body})
66+
bodyRun.SetColor(colors.Text)
67+
68+
if err := doc.SaveAs("themed.docx"); err != nil {
69+
log.Fatal(err)
70+
}
71+
}
72+
```
73+
74+
**Example: Custom Theme**
75+
76+
```go
77+
// Clone and customize existing theme
78+
customTheme := themes.ModernLight.Clone()
79+
customColors := themes.ThemeColors{
80+
Primary: domain.Color{R: 200, G: 50, B: 50}, // Custom red
81+
Secondary: domain.Color{R: 50, G: 50, B: 200}, // Custom blue
82+
Background: domain.Color{R: 255, G: 255, B: 255},
83+
Text: domain.Color{R: 33, G: 33, B: 33},
84+
// ... other colors
85+
}
86+
customTheme = customTheme.WithColors(customColors)
87+
customTheme.ApplyTo(doc)
88+
```
89+
90+
### 📐 Advanced Examples
91+
92+
#### Example 13: Technical Architecture Documents
93+
94+
New comprehensive example demonstrating:
95+
- Theme application (Light & Dark modes)
96+
- PlantUML diagram integration
97+
- Code blocks with syntax highlighting
98+
- Professional tables with tech styling
99+
- Architecture decision records
100+
- Multiple sections with consistent branding
101+
102+
See [`examples/13_themes/04_tech_architecture/`](examples/13_themes/04_tech_architecture/) for complete implementation.
103+
104+
**Features:**
105+
- Generates both light and dark mode versions
106+
- Integrates with PlantUML server for UML diagrams (Class, Sequence, Component)
107+
- Styled code blocks with language indicators
108+
- Technology comparison tables
109+
- Cover page with metadata
110+
- Headers and footers with theme colors
111+
112+
---
113+
114+
## 🔧 Improvements
115+
116+
### Style Management
117+
- Enhanced built-in style library (40+ styles)
118+
- Improved style inheritance and customization
119+
- Better style serialization and persistence
120+
121+
### Error Handling
122+
- More descriptive error messages for theme operations
123+
- Validation of theme color values
124+
- Clear feedback on theme application failures
125+
126+
### Documentation
127+
- Complete theme system documentation
128+
- New example showcasing all theme capabilities
129+
- Updated API documentation with theme methods
130+
131+
---
132+
133+
## 📦 Installation
134+
135+
```bash
136+
go get github.com/mmonterroca/docxgo@v2.1.0
137+
```
138+
139+
---
140+
141+
## 🚀 Migration from v2.0.0
142+
143+
v2.1.0 is **fully backward compatible** with v2.0.0. No breaking changes.
144+
145+
### New APIs Added
146+
147+
```go
148+
// Theme package
149+
import "github.com/mmonterroca/docxgo/themes"
150+
151+
// Pre-built themes
152+
themes.DefaultTheme
153+
themes.ModernLight
154+
themes.TechPresentation
155+
themes.TechDarkMode
156+
themes.AcademicFormal
157+
themes.MinimalistClean
158+
159+
// Theme application
160+
theme.ApplyTo(doc)
161+
162+
// Theme properties
163+
colors := theme.Colors()
164+
fonts := theme.Fonts()
165+
spacing := theme.Spacing()
166+
167+
// Customization
168+
customTheme := theme.Clone()
169+
customTheme = theme.WithColors(newColors)
170+
customTheme = theme.WithFonts(newFonts)
171+
customTheme = theme.WithSpacing(newSpacing)
172+
```
173+
174+
---
175+
176+
## 🐛 Bug Fixes
177+
178+
- Fixed style preservation when applying themes
179+
- Corrected font inheritance in themed documents
180+
- Improved color serialization in OOXML
181+
- Fixed spacing inconsistencies in themed headings
182+
183+
---
184+
185+
## 📊 Examples
186+
187+
All examples from v2.0.0 continue to work, plus:
188+
189+
| Example | Description | Key Features |
190+
|---------|-------------|--------------|
191+
| `13_themes/04_tech_architecture` | Technical documentation | Themes, PlantUML, code blocks, tables |
192+
193+
### Running the New Example
194+
195+
```bash
196+
cd examples/13_themes/04_tech_architecture
197+
go run main.go
198+
```
199+
200+
Generates:
201+
- `tech_architecture_light.docx` - Light mode technical document
202+
- `tech_architecture_dark.docx` - Dark mode technical document
203+
204+
---
205+
206+
## 🔗 Compatibility
207+
208+
- **Go Version**: 1.23+
209+
- **OOXML**: Office Open XML (ISO/IEC 29500)
210+
- **Microsoft Word**: 2007+ (Windows/Mac)
211+
- **LibreOffice**: 6.0+ (all platforms)
212+
- **Google Docs**: Full compatibility
213+
- **Operating Systems**: Linux, macOS, Windows
214+
215+
---
216+
217+
## 📚 Documentation
218+
219+
### New Documentation
220+
- **[themes/README.md](themes/README.md)** - Complete theme system guide
221+
- **[examples/13_themes/README.md](examples/13_themes/README.md)** - Theme example documentation
222+
223+
### Updated Documentation
224+
- **[README.md](README.md)** - Added theme examples
225+
- **[docs/V2_API_GUIDE.md](docs/V2_API_GUIDE.md)** - Theme API reference
226+
227+
---
228+
229+
## 🗺️ Roadmap
230+
231+
### v2.2.0 (Q1 2026) - Enhanced Reading
232+
- Complete Phase 10 (Document Reading to 100%)
233+
- Read headers/footers from existing documents
234+
- Read images and complex tables
235+
- Comments and change tracking
236+
237+
### v2.3.0 (Q2 2026) - Advanced Content
238+
- Custom XML parts
239+
- Advanced drawing shapes
240+
- Enhanced image manipulation
241+
- Content controls
242+
243+
See [docs/IMPLEMENTATION_STATUS.md](docs/IMPLEMENTATION_STATUS.md) for detailed roadmap.
244+
245+
---
246+
247+
## 🙏 Credits
248+
249+
**v2.1.0 Theme System**: [@mmonterroca](https://github.com/mmonterroca)
250+
251+
**Contributors**: See [CONTRIBUTORS](CONTRIBUTORS) file
252+
253+
---
254+
255+
## 📄 License
256+
257+
**MIT License** - See [LICENSE](LICENSE) file for details.
258+
259+
---
260+
261+
## 🎉 Thank You!
262+
263+
Thank you for using go-docx v2.1.0! We're excited to see the beautiful themed documents you create.
264+
265+
If you find this library useful, please:
266+
- ⭐ Star the repository on GitHub
267+
- 📣 Share with your colleagues
268+
- 🐛 Report issues you encounter
269+
- 💡 Suggest features you'd like to see
270+
271+
Happy theming! 🎨

builder.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ func NewDocumentBuilder(opts ...Option) *DocumentBuilder {
197197
// Create document with configuration
198198
doc := NewDocument()
199199

200+
builder := &DocumentBuilder{
201+
doc: doc,
202+
errors: make([]error, 0),
203+
}
204+
200205
// Apply configuration to document
201206
if config.Metadata != nil {
202207
if err := doc.SetMetadata(config.Metadata); err != nil {
@@ -206,10 +211,20 @@ func NewDocumentBuilder(opts ...Option) *DocumentBuilder {
206211
}
207212
}
208213

209-
return &DocumentBuilder{
210-
doc: doc,
211-
errors: make([]error, 0),
214+
// Apply theme if provided
215+
if config.Theme != nil {
216+
// Use type assertion to get Theme interface
217+
// This avoids import cycle between docx and themes packages
218+
if theme, ok := config.Theme.(interface {
219+
ApplyTo(domain.Document) error
220+
}); ok {
221+
if err := theme.ApplyTo(doc); err != nil {
222+
builder.errors = append(builder.errors, err)
223+
}
224+
}
212225
}
226+
227+
return builder
213228
}
214229

215230
// AddParagraph adds a new paragraph to the document and returns a ParagraphBuilder.

0 commit comments

Comments
 (0)