Browse Source

Remove code examples for Python 3.8 in `custom_docs_ui`

pull/14510/head
Yurii Motov 7 months ago
parent
commit
2679c58cbd
  1. 14
      docs/en/docs/how-to/custom-docs-ui-assets.md
  2. 0
      docs_src/custom_docs_ui/tutorial001_py39.py
  3. 0
      docs_src/custom_docs_ui/tutorial002_py39.py
  4. 2
      tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py
  5. 2
      tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py

14
docs/en/docs/how-to/custom-docs-ui-assets.md

@ -18,7 +18,7 @@ The first step is to disable the automatic docs, as by default, those use the de
To disable them, set their URLs to `None` when creating your `FastAPI` app: To disable them, set their URLs to `None` when creating your `FastAPI` app:
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[8] *} {* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[8] *}
### Include the custom docs { #include-the-custom-docs } ### Include the custom docs { #include-the-custom-docs }
@ -34,7 +34,7 @@ You can reuse FastAPI's internal functions to create the HTML pages for the docs
And similarly for ReDoc... And similarly for ReDoc...
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[2:6,11:19,22:24,27:33] *} {* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[2:6,11:19,22:24,27:33] *}
/// tip /// tip
@ -50,7 +50,7 @@ Swagger UI will handle it behind the scenes for you, but it needs this "redirect
Now, to be able to test that everything works, create a *path operation*: Now, to be able to test that everything works, create a *path operation*:
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[36:38] *} {* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[36:38] *}
### Test it { #test-it } ### Test it { #test-it }
@ -118,7 +118,7 @@ After that, your file structure could look like:
* Import `StaticFiles`. * Import `StaticFiles`.
* "Mount" a `StaticFiles()` instance in a specific path. * "Mount" a `StaticFiles()` instance in a specific path.
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[7,11] *} {* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[7,11] *}
### Test the static files { #test-the-static-files } ### Test the static files { #test-the-static-files }
@ -144,7 +144,7 @@ The same as when using a custom CDN, the first step is to disable the automatic
To disable them, set their URLs to `None` when creating your `FastAPI` app: To disable them, set their URLs to `None` when creating your `FastAPI` app:
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[9] *} {* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[9] *}
### Include the custom docs for static files { #include-the-custom-docs-for-static-files } ### Include the custom docs for static files { #include-the-custom-docs-for-static-files }
@ -160,7 +160,7 @@ Again, you can reuse FastAPI's internal functions to create the HTML pages for t
And similarly for ReDoc... And similarly for ReDoc...
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[2:6,14:22,25:27,30:36] *} {* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[2:6,14:22,25:27,30:36] *}
/// tip /// tip
@ -176,7 +176,7 @@ Swagger UI will handle it behind the scenes for you, but it needs this "redirect
Now, to be able to test that everything works, create a *path operation*: Now, to be able to test that everything works, create a *path operation*:
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[39:41] *} {* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[39:41] *}
### Test Static Files UI { #test-static-files-ui } ### Test Static Files UI { #test-static-files-ui }

0
docs_src/custom_docs_ui/tutorial001.py → docs_src/custom_docs_ui/tutorial001_py39.py

0
docs_src/custom_docs_ui/tutorial002.py → docs_src/custom_docs_ui/tutorial002_py39.py

2
tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py

@ -10,7 +10,7 @@ def client():
static_dir: Path = Path(os.getcwd()) / "static" static_dir: Path = Path(os.getcwd()) / "static"
print(static_dir) print(static_dir)
static_dir.mkdir(exist_ok=True) static_dir.mkdir(exist_ok=True)
from docs_src.custom_docs_ui.tutorial001 import app from docs_src.custom_docs_ui.tutorial001_py39 import app
with TestClient(app) as client: with TestClient(app) as client:
yield client yield client

2
tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py

@ -10,7 +10,7 @@ def client():
static_dir: Path = Path(os.getcwd()) / "static" static_dir: Path = Path(os.getcwd()) / "static"
print(static_dir) print(static_dir)
static_dir.mkdir(exist_ok=True) static_dir.mkdir(exist_ok=True)
from docs_src.custom_docs_ui.tutorial002 import app from docs_src.custom_docs_ui.tutorial002_py39 import app
with TestClient(app) as client: with TestClient(app) as client:
yield client yield client

Loading…
Cancel
Save