chore: documentation (#76)

* chore: update docstring example to use python code block

* docs: add documentation

* feat: add docs build + fix other workdlows

* fix: add missing return type
This commit is contained in:
d3vyce
2026-02-19 16:43:38 +01:00
committed by GitHub
parent 73fae04333
commit 6714ceeb92
42 changed files with 2008 additions and 40 deletions

View File

@@ -26,6 +26,7 @@ class FixtureRegistry:
"""Registry for managing fixtures with dependencies.
Example:
```python
from fastapi_toolsets.fixtures import FixtureRegistry, Context
fixtures = FixtureRegistry()
@@ -48,6 +49,7 @@ class FixtureRegistry:
return [
Post(id=1, title="Test", user_id=1),
]
```
"""
def __init__(
@@ -80,6 +82,7 @@ class FixtureRegistry:
contexts: List of contexts this fixture belongs to
Example:
```python
@fixtures.register
def roles():
return [Role(id=1, name="admin")]
@@ -87,6 +90,7 @@ class FixtureRegistry:
@fixtures.register(depends_on=["roles"], contexts=[Context.TESTING])
def test_users():
return [User(id=1, username="test", role_id=1)]
```
"""
def decorator(
@@ -124,6 +128,7 @@ class FixtureRegistry:
ValueError: If a fixture name already exists in the current registry
Example:
```python
registry = FixtureRegistry()
dev_registry = FixtureRegistry()
@@ -132,6 +137,7 @@ class FixtureRegistry:
return [...]
registry.include_registry(registry=dev_registry)
```
"""
for name, fixture in registry._fixtures.items():
if name in self._fixtures:

View File

@@ -59,9 +59,11 @@ async def load_fixtures(
Dict mapping fixture names to loaded instances
Example:
```python
# Loads 'roles' first (dependency), then 'users'
result = await load_fixtures(session, fixtures, "users")
print(result["users"]) # [User(...), ...]
```
"""
ordered = registry.resolve_dependencies(*names)
return await _load_ordered(session, registry, ordered, strategy)
@@ -85,11 +87,13 @@ async def load_fixtures_by_context(
Dict mapping fixture names to loaded instances
Example:
```python
# Load base + testing fixtures
await load_fixtures_by_context(
session, fixtures,
Context.BASE, Context.TESTING
)
```
"""
ordered = registry.resolve_context_dependencies(*contexts)
return await _load_ordered(session, registry, ordered, strategy)