Skip to content

Commit afc2300

Browse files
committed
feat/dpcs: create api docs html template generator, fix bugs, improve docs
1 parent 4c1b03a commit afc2300

File tree

13 files changed

+1709
-22
lines changed

13 files changed

+1709
-22
lines changed

Doxyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Doxyfile 1.12.0
1+
\# Doxyfile 1.12.0
22

33
# This file describes the settings to be used by the documentation system
44
# Doxygen (www.doxygen.org) for a project.
@@ -48,7 +48,7 @@ PROJECT_NAME = "pyEchoNext"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = "0.5.5"
51+
PROJECT_NUMBER = "0.5.6"
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Welcome to **EchoNext**, where innovation meets simplicity! Are you tired of the
4141

4242
**Imagine** a lightweight framework that empowers you to create modern web applications with lightning speed and flexibility. With EchoNext, you're not just coding; you're building a masterpiece!
4343

44-
> Last unstable version: 0.5.5 alpha
45-
> Last stable version: 0.5.4 alpha
44+
> Last unstable version: 0.5.6 alpha
45+
> Last stable version: 0.5.5 alpha
4646
4747
## 🤔 Why Choose SqlSymphony?
4848

SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ currently being supported with security updates.
77

88
| Version | Supported |
99
| ------- | ------------------ |
10+
| 0.5.6 | :white_check_mark: |
1011
| 0.5.5 | :white_check_mark: |
1112
| 0.5.4 | :white_check_mark: |
1213
| 0.5.3 | :white_check_mark: |

docs/ru/article1.md

Lines changed: 1428 additions & 0 deletions
Large diffs are not rendered by default.

docs/ru/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010

1111
## Дополнительные материалы
1212

13+
+ [Как создать свой веб-фреймворк на Python](./article1.md)
1314
+ [ASGI Documentation](https://asgi.readthedocs.io/_/downloads/en/stable/pdf/)
1415
+ [PEP 333](https://peps.python.org/pep-0333/#the-application-framework-side)

docs/ru/webframework_design.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
+ Обработчики маршрутизации (routes):
88
- Простые: `/index`
99
- Параметризованные: `/article/{article_id}`
10-
+ Обработчики запросов (views, handlers).
10+
+ Обработчики запросов (views).
11+
+ Middleware
12+
+ Request/Response
13+
+ i18n/l10n
14+
+ Конфигурация
1115

12-
Основное требование: веб-фреймворк должен поддерживаться быстрым, легким и эффективным сервером (например gunicorn). Для этого в Python есть руководство по WSGI.
16+
Основное требование: веб-фреймворк должен поддерживаться быстрым, легким и эффективным сервером (например gunicorn). Для этого в Python есть руководство по WSGI - [PEP 333](https://peps.python.org/pep-0333/#the-application-framework-side).
1317

1418
## Устройство веб-сервера на Python
1519

examples/example_locale.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pyechonext.template_engine.jinja import render_template
99
from pyechonext.middleware import middlewares
1010
from pyechonext.docsgen import ProjDocumentation
11-
from pyechonext.apidoc_ui import APIDocumentation
11+
from pyechonext.apidoc_ui import APIDocumentation, APIDocUI
1212

1313

1414
class UsersView(View):
@@ -41,7 +41,8 @@ def post(self, request, response, **kwargs):
4141

4242
@echonext.route_page('/api-docs')
4343
def api_docs(request, response):
44-
return Response(request, content_type='application/json', body=apidoc.generate_spec())
44+
ui = APIDocUI(apidoc.generate_spec())
45+
return ui.generate_html_page()
4546

4647

4748
@echonext.route_page("/book")

examples/example_locale/docs/api/Initiation-Project_example_locale.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Initiation-Project example_locale
22
Project Documentation for example_locale
33

4-
+ *Creation date*: 2024-11-12 23:30:10
5-
+ *Modification date*: 2024-11-12 23:30:10
4+
+ *Creation date*: 2024-11-13 19:23:55
5+
+ *Modification date*: 2024-11-13 19:23:55
66

77
## Routes
88
/api-docs, /book
@@ -12,7 +12,7 @@ Project Documentation for example_locale
1212
## Subsections
1313

1414
### /book
15-
Creation date: 2024-11-12 23:30:10
15+
Creation date: 2024-11-13 19:23:55
1616

1717
#### Route
1818
Methods: ['GET', 'POST']

pyechonext/apidoc_ui/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from pyechonext.apidoc_ui.api_documentation import APIDocumentation
2+
from pyechonext.apidoc_ui.ui import APIDocUI
23

3-
all = APIDocumentation
4+
all = [APIDocumentation, APIDocUI]

pyechonext/apidoc_ui/api_documentation.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,23 @@ def generate_spec(self) -> str:
4141
for url in self._app.urls:
4242
spec["paths"][url.url] = {
4343
"get": {
44-
"summary": str(url.view.__doc__)
45-
.strip()
46-
.replace("\n", ".")
47-
.replace("\t", ";"),
48-
"responses": {"200": {"description": "Successful response"}},
49-
}
44+
"summary": str(f"{url.view.__doc__}. {url.view.get.__doc__}")
45+
.replace("\n", "<br>")
46+
.strip(),
47+
"responses": {
48+
"200": {"description": "Successful response"},
49+
"405": {"description": "Method not allow"},
50+
},
51+
},
52+
"post": {
53+
"summary": str(f"{url.view.__doc__}. {url.view.post.__doc__}")
54+
.replace("\n", "<br>")
55+
.strip(),
56+
"responses": {
57+
"200": {"description": "Successful response"},
58+
"405": {"description": "Method not allow"},
59+
},
60+
},
5061
}
5162

5263
for path, handler in self._app.routes.items():
@@ -56,8 +67,21 @@ def generate_spec(self) -> str:
5667
.strip()
5768
.replace("\n", ".")
5869
.replace("\t", ";"),
59-
"responses": {"200": {"description": "Successful response"}},
60-
}
70+
"responses": {
71+
"200": {"description": "Successful response"},
72+
"405": {"description": "Method not allow"},
73+
},
74+
},
75+
"post": {
76+
"summary": str(handler.__doc__)
77+
.strip()
78+
.replace("\n", ".")
79+
.replace("\t", ";"),
80+
"responses": {
81+
"200": {"description": "Successful response"},
82+
"405": {"description": "Method not allow"},
83+
},
84+
},
6185
}
6286

6387
return spec

0 commit comments

Comments
 (0)