Skip to content

Commit

Permalink
dev: Improve Docs Generation (#4402)
Browse files Browse the repository at this point in the history
Co-authored-by: Kuchenpirat <[email protected]>
  • Loading branch information
michael-genson and Kuchenpirat authored Oct 21, 2024
1 parent 674ad23 commit a7c8b33
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
8 changes: 6 additions & 2 deletions dev/code-generation/gen_docs_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import json

from fastapi import FastAPI
from freezegun import freeze_time

from mealie.app import app
from mealie.core.config import determine_data_dir

Expand Down Expand Up @@ -36,11 +39,12 @@
HTML_PATH = DATA_DIR.parent.parent.joinpath("docs/docs/overrides/api.html")


def generate_api_docs(my_app):
def generate_api_docs(my_app: FastAPI):
with open(HTML_PATH, "w") as fd:
text = HTML_TEMPLATE.replace("MY_SPECIFIC_TEXT", json.dumps(my_app.openapi()))
fd.write(text)


if __name__ == "__main__":
generate_api_docs(app)
with freeze_time("2024-01-20T17:00:55Z"):
generate_api_docs(app)
2 changes: 1 addition & 1 deletion docs/docs/overrides/api.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions mealie/routes/recipe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

router = APIRouter()

router.include_router(recipe_crud_routes.router_exports)
router.include_router(recipe_crud_routes.router)
router.include_router(recipe_crud_routes.router_exports, tags=["Recipe: Exports"])
router.include_router(recipe_crud_routes.router, tags=["Recipe: CRUD"])
router.include_router(comments.router, prefix=prefix, tags=["Recipe: Comments"])
router.include_router(bulk_actions.router, prefix=prefix, tags=["Recipe: Bulk Exports"])
router.include_router(bulk_actions.router, prefix=prefix, tags=["Recipe: Bulk Actions"])
router.include_router(shared_routes.router, prefix=prefix, tags=["Recipe: Shared"])
router.include_router(timeline_events.events_router, prefix=prefix, tags=["Recipe: Timeline"])
2 changes: 1 addition & 1 deletion mealie/routes/recipe/bulk_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from mealie.schema.response.responses import SuccessResponse
from mealie.services.recipe.recipe_bulk_service import RecipeBulkActionsService

router = APIRouter(prefix="/bulk-actions", tags=["Recipe: Bulk Actions"])
router = APIRouter(prefix="/bulk-actions")


@controller(router)
Expand Down
4 changes: 2 additions & 2 deletions mealie/routes/recipe/recipe_crud_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class FormatResponse(BaseModel):
jinja2: list[str]


router_exports = UserAPIRouter(prefix="/recipes", tags=["Recipe: Exports"])
router_exports = UserAPIRouter(prefix="/recipes")


@controller(router_exports)
Expand Down Expand Up @@ -176,7 +176,7 @@ def get_recipe_as_zip(self, slug: str, token: str):
)


router = UserAPIRouter(prefix="/recipes", tags=["Recipe: CRUD"], route_class=MealieCrudRoute)
router = UserAPIRouter(prefix="/recipes", route_class=MealieCrudRoute)


@controller(router)
Expand Down
18 changes: 16 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ types-python-slugify = "^6.0.0"
types-requests = "^2.27.12"
types-urllib3 = "^1.26.11"
pydantic-to-typescript2 = "^1.0.4"
freezegun = "^1.5.1"


[build-system]
Expand Down

0 comments on commit a7c8b33

Please sign in to comment.