Skip to content

Commit 734d559

Browse files
committed
adds sphinx module for handling pydantic models
1 parent 238150e commit 734d559

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

aim/digifeeds/database/schemas.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
"""Digifeeds Pydantic Models"""
2+
23
from pydantic import BaseModel, Field, ConfigDict
34
from datetime import datetime
45

56

67
class ItemStatus(BaseModel):
8+
"""
9+
Model of an individual ItemStatus. it includes the name,
10+
description, and creation date of the status for a given item. It is used
11+
for listing the statuses for a given Item.
12+
"""
13+
714
name: str = Field(alias="status_name")
815
description: str = Field(alias="status_description")
916
created_at: datetime
@@ -12,12 +19,23 @@ class ItemStatus(BaseModel):
1219

1320

1421
class ItemBase(BaseModel):
22+
"""
23+
Model of the most basic Item. One that only has a barcode. It's
24+
used as the base for a full Item listing, and for Item creation where
25+
barcode is the only necessary attribute.
26+
"""
27+
1528
model_config = ConfigDict(populate_by_name=True, from_attributes=True)
1629

1730
barcode: str = Field(alias="item_barcode")
1831

1932

2033
class Item(ItemBase):
34+
"""
35+
Model for the full listing of an item. It inherits from ItemBase
36+
which only has a barcode.
37+
"""
38+
2139
created_at: datetime
2240
statuses: list[ItemStatus] = []
2341
model_config = ConfigDict(
@@ -39,8 +57,12 @@ class Item(ItemBase):
3957
)
4058

4159

42-
4360
class ItemCreate(ItemBase):
61+
"""
62+
Model for Item creation. Only a Barcode is needed for creating an
63+
item, so it is identical to ItemBase
64+
"""
65+
4466
pass
4567

4668

@@ -67,6 +89,7 @@ class Response400(Response):
6789
}
6890
)
6991

92+
7093
class Response404(Response):
7194
model_config = ConfigDict(
7295
json_schema_extra={

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
"myst_parser",
2323
"sphinxcontrib.mermaid",
2424
"sphinx_toolbox.more_autodoc.autonamedtuple",
25+
"sphinxcontrib.autodoc_pydantic",
2526
]
2627
autodoc_mock_imports = ["sqlalchemy"]
2728
autosummary_generate = True
29+
autodoc_pydantic_model_show_config_summary = False
2830

2931
mermaid_d3_zoom = True
3032
mermaid_version = "11.3.0"

poetry.lock

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ sphinx-autobuild = "^2024.10.3"
3535
myst-parser = "^4.0.0"
3636
sphinxcontrib-mermaid = "^0.9.2"
3737
sphinx-toolbox = "^3.8.1"
38+
autodoc-pydantic = "^2.2.0"
3839

3940

4041
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)