Skip to content

Commit f6be6c2

Browse files
committed
claude18
1 parent 7c41834 commit f6be6c2

1 file changed

Lines changed: 76 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ tests/
4242
├── test_asyncpg.py # asyncpg integration tests
4343
├── test_dataclasses.py # ModelBase tests
4444
└── test_sqlalchemy.py # SQLAlchemy integration tests
45+
46+
docs/
47+
├── source/
48+
│ ├── conf.py # Sphinx configuration
49+
│ ├── index.rst # Main documentation page
50+
│ ├── api/ # API reference documentation
51+
│ │ ├── index.rst
52+
│ │ ├── base.rst # sql_athame.base module docs
53+
│ │ └── dataclasses.rst # sql_athame.dataclasses module docs
54+
│ ├── examples/ # Usage examples and tutorials
55+
│ │ └── index.rst
56+
│ └── _static/ # Static files for documentation
57+
├── build/ # Generated documentation (gitignored)
58+
└── Makefile # Standard Sphinx Makefile
4559
```
4660

4761
## Development Environment
@@ -50,16 +64,32 @@ tests/
5064
- Core: `typing-extensions` only
5165
- Optional: `asyncpg` for PostgreSQL, `SQLAlchemy` for ORM integration
5266
- Dev tools: `ruff` (linting), `mypy` (type checking), `pytest` (testing)
67+
- Documentation: `sphinx`, `sphinx-rtd-theme`, `sphinx-autodoc-typehints`
68+
69+
### Build Commands (via ./run script)
70+
- `./run tests` - Run tests with coverage and linting
71+
- `./run lint` - Run linting and type checking
72+
- `./run refmt` - Reformat code with ruff
73+
- `./run docs-build` - Build documentation
74+
- `./run docs-serve` - Build and serve documentation locally at http://localhost:8000
75+
- `./run docs-clean` - Clean documentation build artifacts
76+
- `./run bump2version {major|minor|patch}` - Bump version number
5377

5478
### Testing
55-
Run tests with: `pytest`
79+
Run tests with: `./run tests` or `uv run pytest`
5680
The project has comprehensive test coverage including async database operations.
5781

5882
### Code Quality
5983
- Uses `ruff` for linting and formatting
6084
- Type checked with `mypy`
6185
- Follows modern Python conventions (3.9+)
6286

87+
### Documentation
88+
- Full Sphinx documentation with Read the Docs theme
89+
- Auto-generated API reference from comprehensive docstrings
90+
- Usage examples and tutorials
91+
- Available locally via `./run docs-serve`
92+
6393
## Common Operations
6494

6595
### Building Queries
@@ -87,15 +117,22 @@ result = await conn.fetch(*query)
87117

88118
### Dataclass Models
89119
```python
120+
from typing import Annotated, Optional
121+
from sql_athame import ModelBase, ColumnInfo
122+
90123
@dataclass
91124
class User(ModelBase, table_name="users", primary_key="id"):
92125
id: UUID
93126
name: str
94127
email: Optional[str] = None
128+
metadata: Optional[Annotated[dict, ColumnInfo(type="JSONB")]] = None
95129

96130
# Generate SQL
97131
create_sql = User.create_table_sql()
98132
select_sql = User.select_sql(where=sql("active = {}", True))
133+
134+
# Use with asyncpg
135+
users = await User.select(pool, where=sql("department_id = {}", dept_id))
99136
```
100137

101138
## Safety Notes
@@ -104,6 +141,44 @@ select_sql = User.select_sql(where=sql("active = {}", True))
104141
- The library automatically handles parameter numbering and escaping
105142
- Dataclass serialization handles JSON/JSONB conversion automatically
106143

144+
## Key API Reference
145+
146+
### Core Classes (sql_athame.base)
147+
- `Fragment` - Core SQL fragment class with comprehensive methods
148+
- `SQLFormatter` (available as `sql`) - Main query builder with utility methods
149+
150+
### ORM Classes (sql_athame.dataclasses)
151+
- `ModelBase` - Base class for dataclass models with full CRUD operations
152+
- `ColumnInfo` - Column metadata for type mapping and constraints
153+
- `ReplaceMultiplePlan` - Planning class for bulk replace operations
154+
155+
### Important Methods
156+
- **SQL Building**: `sql()`, `sql.all()`, `sql.any()`, `sql.list()`, `sql.literal()`
157+
- **Model Operations**: `create_table_sql()`, `select_sql()`, `insert_sql()`, `upsert_sql()`
158+
- **Database Operations**: `select()`, `create()`, `insert()`, `upsert()`, `delete_multiple()`
159+
- **Bulk Operations**: `insert_multiple()`, `upsert_multiple()`, `replace_multiple()`
160+
161+
## Documentation & Development Notes
162+
163+
### Docstring Coverage
164+
All major classes and methods have comprehensive Sphinx-style docstrings including:
165+
- Parameter descriptions with types
166+
- Return value documentation
167+
- Usage examples where helpful
168+
- Cross-references to related functionality
169+
170+
### Column Configuration
171+
Use `Annotated` types with `ColumnInfo` for column metadata:
172+
```python
173+
price: Annotated[Decimal, ColumnInfo(type="NUMERIC(10,2)", constraints="CHECK (price > 0)")]
174+
tags: Annotated[list, ColumnInfo(type="JSONB", serialize=json.dumps, deserialize=json.loads)]
175+
```
176+
177+
### Bulk Insert Modes
178+
- `unnest` (default): Most efficient for PostgreSQL using UNNEST
179+
- `array_safe`: Uses VALUES syntax with chunking for large datasets
180+
- `executemany`: Uses asyncpg's executemany (slowest but most compatible)
181+
107182
## Version Info
108183
Current version: 0.4.0-alpha-12 (as of analysis)
109184
License: MIT

0 commit comments

Comments
 (0)