Files
image_table/CLAUDE.md
Maksimov V Vladimir b8e9f20ec3 fix: исправление багов, комментарии и документация
- Исправлена двойная обработка ITableRow через reflection
- Исправлен выход за границы изображения при отрисовке последнего разделителя
- Добавлена защита от пустых данных (header, blocks)
- Добавлена compile-time проверка интерфейса ITableRow
- Переименован tablle_block_style.go → table_block_style.go
- Добавлены комментарии на русском ко всем функциям и типам
- Написана документация README.md с примерами использования
- Добавлен CLAUDE.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 20:30:54 +03:00

35 lines
1.7 KiB
Markdown

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Go library for rendering data tables as PNG images. Provides two APIs:
- `DrawTableWarm()` — renders a single table with header and rows
- `RenderDocument()` — renders a multi-block document with titled table sections
## Build & Test Commands
```bash
go test ./... # run all tests
go test -run TestDrawTable # run single test
go test -run TestDocument # run document rendering test
```
Tests output PNG files to `test-data/` (gitignored). Verify rendering by inspecting the generated images visually.
## Architecture
- **`image_table.go`** — Core rendering engine. `DrawTableWarm()` draws a single table image. Contains font initialization (`init()`), text measurement/drawing utilities, rounded rect helper, and row-to-string conversion via reflection. Embeds `assets/jb.ttf` (JetBrains font) at compile time.
- **`document.go`** — `RenderDocument()` composes multiple `TableBlock`s into a single document image with titles, using a larger font face for block headings.
- **`table_block.go`** — `TableBlock` struct: a titled table with header and rows.
- **`tablle_block_style.go`** — `TableBlockStyle` implements `ITableRow` to allow per-row background colors.
- **`itablerow.go`** — `ITableRow` interface for custom row rendering (cells + background color).
## Key Patterns
- Rows accept `any` type: slices, structs (via reflection), or `ITableRow` implementors for custom styling.
- Column widths are auto-calculated from content measurement.
- Two `init()` functions parse the embedded TTF font at different sizes (10pt for table cells, 12pt for document titles).
- Comments and identifiers are in Russian.