From 54bfa15d389c9f8a8004818b9390c35b5c642f7d Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Mon, 13 Jan 2025 13:02:49 +0100 Subject: [PATCH] Add small documentation improvements --- docs/index.md | 40 ++++++++++++++++++++++++++-------------- mkdocs.yml | 12 ++++++++++++ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/docs/index.md b/docs/index.md index 293361e37..adbd8fd71 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,10 @@ + +

uvicorn

@@ -20,9 +27,13 @@ --- -# Introduction +**Documentation**: [https://www.uvicorn.org](https://www.uvicorn.org) + +**Source Code**: [https://www.github.com/encode/uvicorn](https://www.github.com/encode/uvicorn) -Uvicorn is an ASGI web server implementation for Python. +--- + +**Uvicorn** is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level server/application interface for async frameworks. The [ASGI specification][asgi] fills this gap, and means we're now able to @@ -35,13 +46,13 @@ Uvicorn currently supports **HTTP/1.1** and **WebSockets**. Install using `pip`: ```shell -$ pip install uvicorn +pip install uvicorn ``` This will install uvicorn with minimal (pure Python) dependencies. ```shell -$ pip install 'uvicorn[standard]' +pip install 'uvicorn[standard]' ``` This will install uvicorn with "Cython-based" dependencies (where possible) and other "optional extras". @@ -58,7 +69,7 @@ Moreover, "optional extras" means that: - the websocket protocol will be handled by `websockets` (should you want to use `wsproto` you'd need to install it manually) if possible. - the `--reload` flag in development mode will use `watchfiles`. -- windows users will have `colorama` installed for the colored logs. +- Windows users will have `colorama` installed for the colored logs. - `python-dotenv` will be installed should you want to use the `--env-file` option. - `PyYAML` will be installed to allow you to provide a `.yaml` file to `--log-config`, if desired. @@ -72,7 +83,8 @@ async def app(scope, receive, send): 'type': 'http.response.start', 'status': 200, 'headers': [ - [b'content-type', b'text/plain'], + (b'content-type', b'text/plain'), + (b'content-length', b'13'), ], }) await send({ @@ -84,7 +96,7 @@ async def app(scope, receive, send): Run the server: ```shell -$ uvicorn main:app +uvicorn main:app ``` --- @@ -194,7 +206,7 @@ def create_app(): ``` ```shell -$ uvicorn --factory main:create_app +uvicorn --factory main:create_app ``` ## The ASGI interface @@ -400,9 +412,9 @@ It is run widely in production, and supports HTTP/1.1, HTTP/2, and WebSockets. Any of the example applications given here can equally well be run using `daphne` instead. -``` -$ pip install daphne -$ daphne app:App +```shell +pip install daphne +daphne app:App ``` ### Hypercorn @@ -412,9 +424,9 @@ being separated out into a standalone ASGI server. Hypercorn supports HTTP/1.1, HTTP/2, HTTP/3 and WebSockets. -``` -$ pip install hypercorn -$ hypercorn app:App +```shell +pip install hypercorn +hypercorn app:App ``` --- diff --git a/mkdocs.yml b/mkdocs.yml index dbc8e40ea..858e24008 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,7 @@ site_name: Uvicorn site_description: The lightning-fast ASGI server. site_url: https://www.uvicorn.org +strict: true theme: name: material @@ -21,6 +22,7 @@ theme: name: "Switch to light mode" features: - content.code.copy # https://squidfunk.github.io/mkdocs-material/upgrade/?h=content+copy#contentcodecopy + - navigation.sections # https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation - navigation.top # https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#back-to-top-button - navigation.footer # https://squidfunk.github.io/mkdocs-material/upgrade/?h=content+copy#navigationfooter - toc.follow # https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#anchor-following @@ -29,6 +31,12 @@ repo_name: encode/uvicorn repo_url: https://github.com/encode/uvicorn edit_uri: edit/master/docs/ +# https://www.mkdocs.org/user-guide/configuration/#validation +validation: + omitted_files: warn + absolute_links: warn + unrecognized_links: warn + nav: - Introduction: index.md - Settings: settings.md @@ -38,6 +46,7 @@ nav: - Contributing: contributing.md markdown_extensions: + - attr_list - admonition - codehilite: css_class: highlight @@ -46,6 +55,9 @@ markdown_extensions: - pymdownx.inlinehilite - pymdownx.snippets - pymdownx.superfences + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg hooks: - docs/plugins/main.py