Skip to content

Commit b3351ca

Browse files
authored
Merge pull request #444 from tisnik/lcore-581-doc-for-all-modules
LCORE-581: generated documentation for all modules
2 parents dee018d + 8c9c736 commit b3351ca

File tree

10 files changed

+189
-0
lines changed

10 files changed

+189
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ openapi-doc: docs/openapi.json ## Generate OpenAPI documentation
4343
requirements.txt: pyproject.toml pdm.lock ## Generate requirements.txt file containing hashes for all non-devel packages
4444
pdm export --prod --format requirements --output requirements.txt --no-extras --without evaluation
4545

46+
doc:
47+
scripts/gen_doc.py
48+
4649
docs/config.puml: src/models/config.py ## Generate PlantUML class diagram for configuration
4750
pyreverse src/models/config.py --output puml --output-directory=docs/
4851
mv docs/classes.puml docs/config.puml

scripts/gen_doc.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
3+
"""Generate documentation for all modules from Lightspeed Stack core service."""
4+
5+
import os
6+
7+
import ast
8+
from pathlib import Path
9+
10+
11+
for path in Path("src").rglob("*"):
12+
if path.is_dir():
13+
directory = path
14+
cwd = os.getcwd()
15+
os.chdir(directory)
16+
print(directory)
17+
18+
try:
19+
with open("README.md", "w", encoding="utf-8", newline="\n") as indexfile:
20+
print(
21+
f"# List of source files stored in `{directory}` directory",
22+
file=indexfile,
23+
)
24+
print("", file=indexfile)
25+
files = sorted(os.listdir())
26+
27+
for file in files:
28+
if file.endswith(".py"):
29+
print(f"## [{file}]({file})", file=indexfile)
30+
with open(file, "r", encoding="utf-8") as fin:
31+
source = fin.read()
32+
try:
33+
mod = ast.parse(source)
34+
doc = ast.get_docstring(mod)
35+
except SyntaxError:
36+
doc = None
37+
if doc:
38+
print(doc.splitlines()[0], file=indexfile)
39+
print(file=indexfile)
40+
finally:
41+
os.chdir(cwd)

src/app/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# List of source files stored in `src/app` directory
2+
3+
## [__init__.py](__init__.py)
4+
REST API service based on FastAPI.
5+
6+
## [database.py](database.py)
7+
Database engine management.
8+
9+
## [main.py](main.py)
10+
Definition of FastAPI based web service.
11+
12+
## [routers.py](routers.py)
13+
REST API routers.
14+

src/app/endpoints/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# List of source files stored in `src/app/endpoints` directory
2+
3+
## [__init__.py](__init__.py)
4+
Implementation of all endpoints.
5+
6+
## [authorized.py](authorized.py)
7+
Handler for REST API call to authorized endpoint.
8+
9+
## [config.py](config.py)
10+
Handler for REST API call to retrieve service configuration.
11+
12+
## [conversations.py](conversations.py)
13+
Handler for REST API calls to manage conversation history.
14+
15+
## [feedback.py](feedback.py)
16+
Handler for REST API endpoint for user feedback.
17+
18+
## [health.py](health.py)
19+
Handlers for health REST API endpoints.
20+
21+
## [info.py](info.py)
22+
Handler for REST API call to provide info.
23+
24+
## [metrics.py](metrics.py)
25+
Handler for REST API call to provide metrics.
26+
27+
## [models.py](models.py)
28+
Handler for REST API call to list available models.
29+
30+
## [query.py](query.py)
31+
Handler for REST API call to provide answer to query.
32+
33+
## [root.py](root.py)
34+
Handler for the / endpoint.
35+
36+
## [streaming_query.py](streaming_query.py)
37+
Handler for REST API call to provide answer to streaming query.
38+

src/auth/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# List of source files stored in `src/auth` directory
2+
3+
## [__init__.py](__init__.py)
4+
This package contains authentication code and modules.
5+
6+
## [interface.py](interface.py)
7+
Abstract base class for all authentication method implementations.
8+
9+
## [jwk_token.py](jwk_token.py)
10+
Manage authentication flow for FastAPI endpoints with JWK based JWT auth.
11+
12+
## [k8s.py](k8s.py)
13+
Manage authentication flow for FastAPI endpoints with K8S/OCP.
14+
15+
## [noop.py](noop.py)
16+
Manage authentication flow for FastAPI endpoints with no-op auth.
17+
18+
## [noop_with_token.py](noop_with_token.py)
19+
Manage authentication flow for FastAPI endpoints with no-op auth and provided user token.
20+
21+
## [utils.py](utils.py)
22+
Authentication utility functions.
23+

src/metrics/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# List of source files stored in `src/metrics` directory
2+
3+
## [__init__.py](__init__.py)
4+
Metrics module for Lightspeed Stack.
5+
6+
## [utils.py](utils.py)
7+
Utility functions for metrics handling.
8+

src/models/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# List of source files stored in `src/models` directory
2+
3+
## [__init__.py](__init__.py)
4+
Pydantic models.
5+
6+
## [config.py](config.py)
7+
Model with service configuration.
8+
9+
## [requests.py](requests.py)
10+
Models for REST API requests.
11+
12+
## [responses.py](responses.py)
13+
Models for REST API responses.
14+

src/models/database/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# List of source files stored in `src/models/database` directory
2+
3+
## [__init__.py](__init__.py)
4+
Database models package.
5+
6+
## [base.py](base.py)
7+
Base model for SQLAlchemy ORM classes.
8+
9+
## [conversations.py](conversations.py)
10+
User conversation models.
11+

src/runners/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# List of source files stored in `src/runners` directory
2+
3+
## [__init__.py](__init__.py)
4+
Runners.
5+
6+
## [uvicorn.py](uvicorn.py)
7+
Uvicorn runner.
8+

src/utils/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# List of source files stored in `src/utils` directory
2+
3+
## [__init__.py](__init__.py)
4+
Utils.
5+
6+
## [checks.py](checks.py)
7+
Checks that are performed to configuration options.
8+
9+
## [common.py](common.py)
10+
Common utilities for the project.
11+
12+
## [endpoints.py](endpoints.py)
13+
Utility functions for endpoint handlers.
14+
15+
## [llama_stack_version.py](llama_stack_version.py)
16+
Check if the Llama Stack version is supported by the LCS.
17+
18+
## [mcp_headers.py](mcp_headers.py)
19+
MCP headers handling.
20+
21+
## [suid.py](suid.py)
22+
Session ID utility functions.
23+
24+
## [transcripts.py](transcripts.py)
25+
Transcript handling.
26+
27+
## [types.py](types.py)
28+
Common types for the project.
29+

0 commit comments

Comments
 (0)