Skip to content

Commit 112fb18

Browse files
author
FirstUnicorn
committed
feat(docs): add sphinx documentation with autoapi for 17-package monorepo
Scaffold: docs/conf.py (sphinx-autoapi + myst-parser + furo), Makefile, make.bat, .readthedocs.yaml. Per-package guide pages: 3 rich-doc wrappers (cqrs-core, sqlalchemy-repos, outbox-core) with {include} of existing .md, 14 new guides for README-only packages. Top-level: index.rst, quickstart, architecture, exception-comparison. Deps bumped to latest stable (Python 3.10 compatible): - sphinx 7->8.1, myst-parser 3->4, furo 2024->2025 - black 23->26, ruff 0.1->0.15, pytest-asyncio 0.23->1.3 - mypy 1.5->1.19, hypothesis 6.100->6.151 Minor myst compatibility fixes in existing docs (transition removal, code fence language tags, docstring condensing).
1 parent 694de06 commit 112fb18

32 files changed

Lines changed: 3428 additions & 27 deletions

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ __pycache__/
77
build/
88
develop-eggs/
99
dist/
10+
dist2/
11+
dist*/
1012
downloads/
1113
eggs/
1214
.eggs/
@@ -25,6 +27,7 @@ venv/
2527
ENV/
2628
env/
2729
.venv
30+
tmp_venv/
2831

2932
# IDEs
3033
.vscode/
@@ -55,4 +58,8 @@ dmypy.json
5558
*.tar.gz
5659

5760
# Distribution artifacts
58-
*.whl
61+
*.whl
62+
63+
# Sphinx docs
64+
docs/_build/
65+
docs/autoapi/

.readthedocs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.11"
7+
8+
sphinx:
9+
configuration: docs/conf.py
10+
11+
python:
12+
install:
13+
- method: pip
14+
path: .
15+
extra_requirements:
16+
- docs

docs/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SPHINXOPTS ?=
2+
SPHINXBUILD ?= sphinx-build
3+
SOURCEDIR = .
4+
BUILDDIR = _build
5+
6+
help:
7+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
8+
9+
.PHONY: help Makefile
10+
11+
%: Makefile
12+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/architecture.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Architecture
2+
3+
## Layer hierarchy
4+
5+
```
6+
Application layer (depends on Domain + Primitives)
7+
├── python-mediator
8+
├── python-cqrs-dispatcher (depends on cqrs-core + mediator)
9+
├── fastapi-config-patterns
10+
├── fastapi-middleware-toolkit
11+
├── python-structlog-config
12+
├── python-outbox-core
13+
├── sqlalchemy-async-session-factory
14+
└── sqlalchemy-async-repositories
15+
16+
Domain layer (depends on Primitives only)
17+
├── python-app-exceptions
18+
├── python-infrastructure-exceptions
19+
├── python-input-validation
20+
├── python-cqrs-core
21+
├── python-domain-events
22+
├── python-dto-mappers
23+
└── pydantic-response-models
24+
25+
Primitives layer (zero dependencies)
26+
└── python-technical-primitives
27+
```
28+
29+
## Import-linter contracts
30+
31+
Layer boundaries are enforced via `import-linter` in `pyproject.toml`:
32+
33+
- **Primitives** cannot import from domain or application
34+
- **Domain** can import from primitives, cannot import from application
35+
- **Application** can import from domain and primitives
36+
37+
## Inter-package dependencies
38+
39+
Only one cross-package dependency exists:
40+
41+
```
42+
python-cqrs-dispatcher
43+
├── python-cqrs-core (ICommand, IQuery interfaces)
44+
└── python-mediator (Mediator dispatch engine)
45+
```
46+
47+
All other packages are fully independent.
48+
49+
## Design patterns used
50+
51+
| Pattern | Package |
52+
|---------|---------|
53+
| Specification | `python-technical-primitives` |
54+
| Repository + Strategy | `sqlalchemy-async-repositories` |
55+
| Factory Method | `sqlalchemy-async-repositories` (pagination) |
56+
| Mediator | `python-mediator` |
57+
| CQRS | `python-cqrs-core`, `python-cqrs-dispatcher` |
58+
| Pipeline behaviors | `python-mediator` |
59+
| Transactional outbox | `python-outbox-core` |
60+
| Strategy (formatters) | `python-outbox-core` |
61+
| CloudEvents | `python-outbox-core` |

docs/conf.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""Sphinx configuration for python-web-toolkit monorepo."""
2+
import os
3+
import sys
4+
5+
project = "python-web-toolkit"
6+
copyright = "2026, GridFlow"
7+
author = "GridFlow"
8+
9+
extensions = [
10+
"autoapi.extension",
11+
"myst_parser",
12+
"sphinx_copybutton",
13+
]
14+
15+
autoapi_dirs = [
16+
f"../packages/{pkg}/src"
17+
for pkg in [
18+
"python-technical-primitives",
19+
"python-app-exceptions",
20+
"python-infrastructure-exceptions",
21+
"python-input-validation",
22+
"postgres-data-sanitizers",
23+
"pydantic-response-models",
24+
"python-cqrs-core",
25+
"python-mediator",
26+
"python-cqrs-dispatcher",
27+
"python-dto-mappers",
28+
"python-domain-events",
29+
"python-structlog-config",
30+
"fastapi-config-patterns",
31+
"fastapi-middleware-toolkit",
32+
"python-outbox-core",
33+
"sqlalchemy-async-session-factory",
34+
"sqlalchemy-async-repositories",
35+
]
36+
]
37+
autoapi_type = "python"
38+
autoapi_options = [
39+
"members",
40+
"undoc-members",
41+
"show-inheritance",
42+
"show-module-summary",
43+
]
44+
autoapi_keep_files = True
45+
46+
myst_enable_extensions = ["colon_fence", "deflist"]
47+
myst_heading_anchors = 3
48+
49+
html_theme = "furo"
50+
html_static_path = ["_static"]
51+
templates_path = ["_templates"]
52+
53+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
54+
55+
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
56+
57+
suppress_warnings = ["myst.header", "myst.xref_missing"]

docs/exception-comparison.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```{include} ../packages/EXCEPTION_LIBRARIES_COMPARISON.md
2+
:relative-images:
3+
```

docs/index.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
python-web-toolkit
2+
==================
3+
4+
17-package Python monorepo for building async web applications with FastAPI, SQLAlchemy, CQRS, and domain-driven design.
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
:caption: Getting started
9+
10+
quickstart
11+
architecture
12+
13+
.. toctree::
14+
:maxdepth: 2
15+
:caption: Packages
16+
17+
packages/index
18+
19+
.. toctree::
20+
:maxdepth: 1
21+
:caption: Comparisons
22+
23+
exception-comparison
24+
25+
.. toctree::
26+
:maxdepth: 2
27+
:caption: API reference
28+
29+
autoapi/index

docs/make.bat

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@ECHO OFF
2+
pushd %~dp0
3+
4+
if "%SPHINXBUILD%" == "" (
5+
set SPHINXBUILD=sphinx-build
6+
)
7+
set SOURCEDIR=.
8+
set BUILDDIR=_build
9+
10+
%SPHINXBUILD% >NUL 2>NUL
11+
if errorlevel 9009 (
12+
echo.sphinx-build not found.
13+
exit /b 1
14+
)
15+
16+
if "%1" == "" goto help
17+
18+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
19+
goto end
20+
21+
:help
22+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
23+
24+
:end
25+
popd
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# fastapi-config-patterns
2+
3+
Reusable Pydantic settings classes for FastAPI applications.
4+
5+
## Installation
6+
7+
```bash
8+
pip install fastapi-config-patterns
9+
```
10+
11+
## Public API
12+
13+
| Class/Function | Purpose |
14+
|----------------|---------|
15+
| `BaseFastAPISettings` | Base settings with `app_name`, `debug`, `allowed_origins`, env loading |
16+
| `BaseDatabaseSettings` | Database settings mixin (`database_url`, pool config) |
17+
| `assemble_cors_origins(v)` | Parse CORS origins from string or list |
18+
19+
## Usage
20+
21+
```python
22+
from fastapi_config_patterns import BaseFastAPISettings, BaseDatabaseSettings
23+
24+
class Settings(BaseFastAPISettings, BaseDatabaseSettings):
25+
redis_url: str = "redis://localhost"
26+
27+
settings = Settings() # loads from environment / .env
28+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# fastapi-middleware-toolkit
2+
3+
Reusable FastAPI middleware: CORS, error handlers, cache control, lifespan, health checks.
4+
5+
## Installation
6+
7+
```bash
8+
pip install fastapi-middleware-toolkit
9+
```
10+
11+
## Public API
12+
13+
| Function/Class | Purpose |
14+
|----------------|---------|
15+
| `setup_cors_middleware(app, allowed_origins, ...)` | CORS with secure defaults |
16+
| `setup_error_handlers(app, custom_exception_class)` | Global error handlers |
17+
| `CacheControlMiddleware` | Default Cache-Control headers |
18+
| `setup_cache_control_middleware(app)` | Register cache control |
19+
| `create_lifespan_manager(on_startup, on_shutdown)` | Lifespan context manager |
20+
| `create_health_check_endpoint(service_name, version)` | Health check factory |
21+
22+
## Usage
23+
24+
```python
25+
from fastapi import FastAPI
26+
from fastapi_middleware_toolkit import (
27+
setup_cors_middleware,
28+
setup_error_handlers,
29+
create_lifespan_manager,
30+
)
31+
32+
lifespan = create_lifespan_manager(service_name="api")
33+
app = FastAPI(lifespan=lifespan)
34+
setup_cors_middleware(app, ["http://localhost:3000"])
35+
setup_error_handlers(app)
36+
```

0 commit comments

Comments
 (0)