From 3d696ca7d02ed657c50c11a238109acf1a0f9c7e Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Tue, 17 Sep 2024 19:38:18 +0200 Subject: [PATCH] chore: replace sphinx-tabs with sphinx-design --- docs/api/cookies.rst | 6 +++--- docs/api/cors.rst | 6 +++--- docs/api/errors.rst | 6 +++--- docs/api/media.rst | 12 ++++++------ docs/api/middleware.rst | 6 +++--- docs/api/multipart.rst | 24 +++++++++++++++--------- docs/api/routing.rst | 18 +++++++++--------- docs/conf.py | 1 - docs/user/faq.rst | 8 +++++--- docs/user/quickstart.rst | 16 ++++++++++------ falcon/media/validators/jsonschema.py | 8 ++++---- requirements/docs | 1 - 12 files changed, 61 insertions(+), 51 deletions(-) diff --git a/docs/api/cookies.rst b/docs/api/cookies.rst index 719e025e4..359fdc2a8 100644 --- a/docs/api/cookies.rst +++ b/docs/api/cookies.rst @@ -24,9 +24,9 @@ need a collection of all the cookies in the request. Here's an example showing how to get cookies from a request: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -43,7 +43,7 @@ Here's an example showing how to get cookies from a request: # will need to choose how to handle the additional values. v = my_cookie_values[0] - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python diff --git a/docs/api/cors.rst b/docs/api/cors.rst index d19bf7a78..899278074 100644 --- a/docs/api/cors.rst +++ b/docs/api/cors.rst @@ -29,9 +29,9 @@ can be exposed. Usage ----- -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -45,7 +45,7 @@ Usage app = falcon.App(middleware=falcon.CORSMiddleware( allow_origins='example.com', allow_credentials='*')) - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python diff --git a/docs/api/errors.rst b/docs/api/errors.rst index 462e188a6..da48ebe39 100644 --- a/docs/api/errors.rst +++ b/docs/api/errors.rst @@ -48,9 +48,9 @@ To customize what data is passed to the serializer, subclass All classes are available directly in the ``falcon`` package namespace: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -68,7 +68,7 @@ All classes are available directly in the ``falcon`` package namespace: # -- snip -- - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python diff --git a/docs/api/media.rst b/docs/api/media.rst index dbff05383..250e35507 100644 --- a/docs/api/media.rst +++ b/docs/api/media.rst @@ -26,9 +26,9 @@ Zero configuration is needed if you're creating a JSON API. Simply use :attr:`~falcon.asgi.Response.media` (ASGI) to let Falcon do the heavy lifting for you. -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -52,7 +52,7 @@ do the heavy lifting for you. resp.media = {'message': message} resp.status = falcon.HTTP_200 - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python @@ -109,9 +109,9 @@ response. If you do need full negotiation, it is very easy to bridge the gap using middleware. Here is an example of how this can be done: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -121,7 +121,7 @@ middleware. Here is an example of how this can be done: def process_request(self, req: Request, resp: Response) -> None: resp.content_type = req.accept - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python diff --git a/docs/api/middleware.rst b/docs/api/middleware.rst index 3cfbb18cd..88c7674eb 100644 --- a/docs/api/middleware.rst +++ b/docs/api/middleware.rst @@ -18,9 +18,9 @@ when instantiating Falcon's :ref:`App class `. A middleware component is simply a class that implements one or more of the event handler methods defined below. -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI Falcon's middleware interface is defined as follows: @@ -96,7 +96,7 @@ defined below. app = App(middleware=[ExampleMiddleware()]) - .. tab:: ASGI + .. tab-item:: ASGI The ASGI middleware interface is similar to WSGI, but also supports the standard ASGI lifespan events. However, because lifespan events are an diff --git a/docs/api/multipart.rst b/docs/api/multipart.rst index cf2620414..add4d18fe 100644 --- a/docs/api/multipart.rst +++ b/docs/api/multipart.rst @@ -11,9 +11,10 @@ Falcon features easy and efficient access to submitted multipart forms by using default, allowing you to use ``req.get_media()`` to iterate over the :class:`body parts ` in a form: -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi .. code:: python @@ -38,7 +39,8 @@ default, allowing you to use ``req.get_media()`` to iterate over the # Do something else form_data[part.name] = part.text - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi .. code:: python @@ -72,9 +74,10 @@ default, allowing you to use ``req.get_media()`` to iterate over the Multipart Form and Body Part Types ---------------------------------- -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi .. autoclass:: falcon.media.multipart.MultipartForm :members: @@ -82,7 +85,8 @@ Multipart Form and Body Part Types .. autoclass:: falcon.media.multipart.BodyPart :members: - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi .. autoclass:: falcon.asgi.multipart.MultipartForm :members: @@ -126,9 +130,10 @@ way is to directly modify the properties of this attribute on the media handler In order to use your customized handler in an app, simply replace the default handler for ``multipart/form-data`` with the new one: -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi .. code:: python @@ -137,7 +142,8 @@ handler for ``multipart/form-data`` with the new one: # handler is instantiated and configured as per the above snippet app.req_options.media_handlers[falcon.MEDIA_MULTIPART] = handler - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi .. code:: python diff --git a/docs/api/routing.rst b/docs/api/routing.rst index 347b3516d..5abb410e2 100644 --- a/docs/api/routing.rst +++ b/docs/api/routing.rst @@ -29,9 +29,9 @@ associated resource for processing. Here's a quick example to show how all the pieces fit together: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -66,7 +66,7 @@ Here's a quick example to show how all the pieces fit together: images = ImagesResource() app.add_route('/images', images) - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python @@ -205,9 +205,9 @@ A PUT request to ``'/user/kgriffs'`` would cause the framework to invoke the ``on_put()`` responder method on the route's resource class, passing ``'kgriffs'`` via an additional `name` argument defined by the responder: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -216,7 +216,7 @@ the ``on_put()`` responder method on the route's resource class, passing def on_put(self, req, resp, name): pass - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python @@ -511,9 +511,9 @@ support custom HTTP methods, use one of the following methods: Once you have used the appropriate method, your custom methods should be active. You then can define request methods like any other HTTP method: -.. tabs:: +.. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -521,7 +521,7 @@ You then can define request methods like any other HTTP method: def on_foo(self, req, resp): pass - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python diff --git a/docs/conf.py b/docs/conf.py index 28039872a..2eb71f4e1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -75,7 +75,6 @@ 'sphinx.ext.viewcode', 'sphinx_copybutton', 'sphinx_design', - 'sphinx_tabs.tabs', 'myst_parser', # Falcon-specific extensions 'ext.cibuildwheel', diff --git a/docs/user/faq.rst b/docs/user/faq.rst index 11a394b63..2284337a1 100644 --- a/docs/user/faq.rst +++ b/docs/user/faq.rst @@ -689,9 +689,10 @@ The `stream` of a body part is a file-like object implementing the ``read()`` method, making it compatible with ``boto3``\'s `upload_fileobj `_: -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi .. code:: python @@ -705,7 +706,8 @@ method, making it compatible with ``boto3``\'s if part.name == 'myfile': s3.upload_fileobj(part.stream, 'mybucket', 'mykey') - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi .. code:: python diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 43157ac9f..38f0f88c7 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -13,9 +13,10 @@ Learning by Example Here is a simple example from Falcon's README, showing how to get started writing an app. -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi .. literalinclude:: ../../examples/things.py :language: python @@ -41,7 +42,8 @@ started writing an app. $ pip install --upgrade httpie $ http localhost:8000/things - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi .. literalinclude:: ../../examples/things_asgi.py :language: python @@ -75,9 +77,10 @@ A More Complex Example Here is a more involved example that demonstrates reading headers and query parameters, handling errors, and working with request and response bodies. -.. tabs:: +.. tab-set:: - .. group-tab:: WSGI + .. tab-item:: WSGI + :sync: wsgi Note that this example assumes that the `requests `_ package has been installed. @@ -135,7 +138,8 @@ parameters, handling errors, and working with request and response bodies. • Error handlers: ⇜ StorageError handle - .. group-tab:: ASGI + .. tab-item:: ASGI + :sync: asgi Note that this example requires the `httpx `_ package in lieu of diff --git a/falcon/media/validators/jsonschema.py b/falcon/media/validators/jsonschema.py index 8fc53ade9..0e6f14b67 100644 --- a/falcon/media/validators/jsonschema.py +++ b/falcon/media/validators/jsonschema.py @@ -56,9 +56,9 @@ def validate(req_schema=None, resp_schema=None, is_async=False): Example: - .. tabs:: + .. tab-set:: - .. tab:: WSGI + .. tab-item:: WSGI .. code:: python @@ -71,7 +71,7 @@ def on_post(self, req, resp): # -- snip -- - .. tab:: ASGI + .. tab-item:: ASGI .. code:: python @@ -84,7 +84,7 @@ async def on_post(self, req, resp): # -- snip -- - .. tab:: ASGI (Cythonized App) + .. tab-item:: ASGI (Cythonized App) .. code:: python diff --git a/requirements/docs b/requirements/docs index ae5df3bbd..34368b81c 100644 --- a/requirements/docs +++ b/requirements/docs @@ -5,5 +5,4 @@ pydata-sphinx-theme PyYAML Sphinx sphinx-copybutton -sphinx-tabs sphinx_design