Skip to content

Commit bdf561e

Browse files
committed
Merge dev → master: v2.0.0 stable release
Production-ready v2.0.0 release with document reading capabilities. Changes from beta to stable: - Phase 10: Document Reading (60% complete) * OpenDocument() for reading existing .docx files * Read/modify document structure (paragraphs, runs, tables) * Style preservation for all paragraph styles * Example 12: Read and modify documents workflow - Bug Fixes: * Fixed paragraph style preservation in reader * Enhanced example 12 with editing capabilities - Documentation: * Fixed README Quick Start API examples * Corrected function signatures and constants * Updated Phase 10 status to 60% complete * Updated example count to 11 - Release Materials: * Created RELEASE_NOTES_v2.0.0.md * Updated CHANGELOG.md with v2.0.0 section Commits: 852c3bf...4de1816 (7 commits) Ready for v2.0.0 tag and GitHub release.
2 parents 253f915 + 4de1816 commit bdf561e

33 files changed

+5878
-155
lines changed

CHANGELOG.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Added (Phase 1 - Foundation)
10+
### Planned for v2.1.0
11+
- Complete Phase 10: Document Reading to 100%
12+
- Read headers/footers from existing documents
13+
- Read images from existing documents
14+
- Comments and change tracking
15+
16+
---
17+
18+
## [2.0.0] - 2025-10-29
19+
20+
### 🎉 Production Release - v2.0.0 Stable
21+
22+
This is the first stable, production-ready release of go-docx v2!
23+
24+
### Added - Phase 10: Document Reading (NEW! 60% Complete)
25+
26+
#### Document Reading & Modification
27+
- **OpenDocument()** - Open and read existing .docx files
28+
- **Document parsing** - Parse document structure (paragraphs, runs, tables)
29+
- **Content modification** - Edit existing text, formatting, and table cells
30+
- **Style preservation** - Maintains all paragraph styles (Title, Subtitle, Heading1-9, Quote, Normal, ListParagraph)
31+
- **Content addition** - Add new paragraphs, runs, and sections to existing documents
32+
- **Round-trip workflow** - Create → Save → Open → Modify → Save
33+
- **Example 12** - Complete read/modify example with documentation
34+
35+
#### Bug Fixes Since Beta
36+
- **Fixed style preservation** - Paragraph styles now correctly preserved when reading documents (Oct 29, 2025)
37+
- Added `applyParagraphStyle()` function in `internal/reader/reconstruct.go`
38+
- Extracts `w:pStyle` from paragraph properties and applies via `para.SetStyle()`
39+
- All paragraph styles (Title, Subtitle, Heading1-3, Quote, Normal, ListParagraph) now working
40+
- **Enhanced example 12** - Now demonstrates both editing existing content AND adding new content
41+
42+
#### Documentation Improvements Since Beta
43+
- **Fixed README Quick Start** - Corrected all API examples to show accurate signatures
44+
- Separated Simple API vs Builder API clearly
45+
- Fixed `WithDefaultFont()` and `WithDefaultFontSize()` signatures
46+
- Corrected page size constant (`docx.A4` not `docx.PageSizeA4`)
47+
- Fixed alignment constant (`domain.AlignmentCenter` not `docx.AlignmentCenter`)
48+
- Added new Option 3: Read and Modify Existing Documents
49+
- **Updated example count** - All documentation now references 11 working examples (was 9)
50+
- **Updated Phase 10 status** - Marked as "60% complete - core features working" (was "Not Started")
51+
- **Fixed error handling examples** - Corrected builder pattern usage in README
52+
53+
### Commits Since Beta (v2.0.0-beta...v2.0.0)
54+
- `3a0832a` - docs: fix README Quick Start with correct API examples and update status
55+
- `19c0e73` - Update documentation: Phase 10 now 60% complete with working reader
56+
- `ca7f1f1` - Fix: Preserve paragraph styles when reading documents
57+
- `3289b54` - Enhance example 12: Add content editing capabilities
58+
- `852c3bf` - Add example 12: Read and modify documents
59+
- `497a94a` - Fix strict OOXML validation and update docs to beta-ready status
60+
61+
### Summary of v2.0.0 Complete Features
62+
63+
#### Core Features from Beta (Carried Forward)
1164
- **Core Interfaces** (domain package)
1265
- `Document` interface with metadata support
1366
- `Paragraph` interface with full formatting options

README.md

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ go get github.com/mmonterroca/docxgo
5151

5252
## Quick Start
5353

54-
### Using Builder Pattern (Recommended)
54+
### Option 1: Simple API (Direct Domain Interfaces)
5555

5656
```go
5757
package main
@@ -62,31 +62,52 @@ import (
6262
)
6363

6464
func main() {
65-
// Option 1: Simple API (direct domain interfaces)
65+
// Create document
6666
doc := docx.NewDocument()
6767

68+
// Add paragraph with formatted text
6869
para, _ := doc.AddParagraph()
6970
run, _ := para.AddRun()
7071
run.SetText("Hello, World!")
7172
run.SetBold(true)
7273
run.SetColor(docx.Red)
7374

74-
doc.SaveAs("simple.docx")
75-
76-
// Option 2: Builder API (fluent, chainable)
75+
// Save document
76+
if err := doc.SaveAs("simple.docx"); err != nil {
77+
log.Fatal(err)
78+
}
79+
}
80+
```
81+
82+
### Option 2: Builder API (Fluent, Chainable - Recommended)
83+
84+
```go
85+
package main
86+
87+
import (
88+
"log"
89+
docx "github.com/mmonterroca/docxgo"
90+
"github.com/mmonterroca/docxgo/domain"
91+
)
92+
93+
func main() {
94+
// Create builder with options
7795
builder := docx.NewDocumentBuilder(
78-
docx.WithDefaultFont("Calibri", 11),
79-
docx.WithPageSize(docx.PageSizeA4),
8096
docx.WithTitle("My Report"),
8197
docx.WithAuthor("John Doe"),
98+
docx.WithDefaultFont("Calibri"),
99+
docx.WithDefaultFontSize(22), // 11pt in half-points
100+
docx.WithPageSize(docx.A4),
101+
docx.WithMargins(docx.NormalMargins),
82102
)
83103

84104
// Add content using fluent API
85105
builder.AddParagraph().
86106
Text("Project Report").
87107
Bold().
88108
FontSize(16).
89-
Alignment(docx.AlignmentCenter).
109+
Color(docx.Blue).
110+
Alignment(domain.AlignmentCenter).
90111
End()
91112

92113
builder.AddParagraph().
@@ -107,15 +128,58 @@ func main() {
107128
}
108129
```
109130

131+
### Option 3: Read and Modify Existing Documents 🆕
132+
133+
```go
134+
package main
135+
136+
import (
137+
"log"
138+
docx "github.com/mmonterroca/docxgo"
139+
)
140+
141+
func main() {
142+
// Open existing document
143+
doc, err := docx.OpenDocument("template.docx")
144+
if err != nil {
145+
log.Fatal(err)
146+
}
147+
148+
// Read existing content
149+
paragraphs := doc.Paragraphs()
150+
for _, para := range paragraphs {
151+
// Modify existing text
152+
runs := para.Runs()
153+
for _, run := range runs {
154+
if run.Text() == "PLACEHOLDER" {
155+
run.SetText("Updated Value")
156+
run.SetBold(true)
157+
}
158+
}
159+
}
160+
161+
// Add new content
162+
newPara, _ := doc.AddParagraph()
163+
newRun, _ := newPara.AddRun()
164+
newRun.SetText("This paragraph was added by the reader")
165+
166+
// Save modified document
167+
if err := doc.SaveAs("modified.docx"); err != nil {
168+
log.Fatal(err)
169+
}
170+
}
171+
```
172+
110173
### More Examples
111174

112-
See the [`examples/`](examples/) directory for comprehensive examples:
175+
See the [`examples/`](examples/) directory for comprehensive examples (11 working examples):
113176

114177
- **[01_basic](examples/01_basic/)** - Simple document with builder pattern
115178
- **[02_intermediate](examples/02_intermediate/)** - Professional product catalog
116-
- **[04_fields](examples/04_fields/)** - TOC, page numbers, hyperlinks (⚠️ needs v2 API update)
179+
- **[04_fields](examples/04_fields/)** - TOC, page numbers, hyperlinks
117180
- **[08_images](examples/08_images/)** - Image insertion and positioning
118181
- **[09_advanced_tables](examples/09_advanced_tables/)** - Cell merging, nested tables, styling
182+
- **[12_read_and_modify](examples/12_read_and_modify/)** - 🆕 Read and modify existing documents
119183

120184
---
121185

@@ -239,11 +303,12 @@ github.com/mmonterroca/docxgo/
239303

240304
### 🚧 In Development
241305

242-
**Phase 10: Document Reading** (Not Started)
243-
- Open and read existing .docx files
244-
- Parse document structure
245-
- Modify existing documents
246-
- Roundtrip testing (create → save → open → verify)
306+
**Phase 10: Document Reading** (60% Complete - Core Features Working ✅)
307+
- ✅ Open and read existing .docx files
308+
- ✅ Parse document structure (paragraphs, runs, tables)
309+
- ✅ Modify existing documents (edit text, formatting, add content)
310+
- ✅ Style preservation (Title, Subtitle, Headings, Quote, Normal)
311+
- 🚧 Advanced features (headers/footers, complex tables, images in existing docs)
247312

248313
**Phase 12: Beta Testing & Release** (In Progress)
249314
- Community feedback integration
@@ -286,15 +351,15 @@ if err != nil {
286351
}
287352

288353
// Builder pattern accumulates errors
289-
doc := docx.NewDocument()
290-
doc.AddParagraph().
354+
builder := docx.NewDocumentBuilder()
355+
builder.AddParagraph().
291356
Text("Hello").
292357
FontSize(9999). // Invalid - error recorded
293358
Bold().
294359
End()
295360

296361
// All errors surface at Build()
297-
finalDoc, err := doc.Build()
362+
doc, err := builder.Build()
298363
if err != nil {
299364
// Returns first accumulated error with full context
300365
log.Fatal(err)

0 commit comments

Comments
 (0)