Add concise docstrings to all Python modules, classes, and public functions. Configure Sphinx with napoleon extension for Google-style docstring parsing and autodoc pages for each module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
953 B
Python
31 lines
953 B
Python
"""Category and word list models."""
|
|
|
|
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from models import Base
|
|
|
|
|
|
class Category(Base):
|
|
"""A word category such as 'animals' or 'food'."""
|
|
|
|
__tablename__ = "categories"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(50), unique=True, nullable=False)
|
|
|
|
words = relationship("CategoryWord", back_populates="category")
|
|
|
|
|
|
class CategoryWord(Base):
|
|
"""A word belonging to a category, used as a candidate for board generation."""
|
|
|
|
__tablename__ = "category_words"
|
|
__table_args__ = (UniqueConstraint("category_id", "word"),)
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False)
|
|
word = Column(String(20), nullable=False)
|
|
|
|
category = relationship("Category", back_populates="words")
|