Skip to content

Commit

Permalink
chore: replace sphinx-tabs with sphinx-design
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 committed Sep 17, 2024
1 parent 52b6233 commit 3d696ca
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 51 deletions.
6 changes: 3 additions & 3 deletions docs/api/cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/api/cors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ can be exposed.
Usage
-----

.. tabs::
.. tab-set::

.. tab:: WSGI
.. tab-item:: WSGI

.. code:: python
Expand All @@ -45,7 +45,7 @@ Usage
app = falcon.App(middleware=falcon.CORSMiddleware(
allow_origins='example.com', allow_credentials='*'))
.. tab:: ASGI
.. tab-item:: ASGI

.. code:: python
Expand Down
6 changes: 3 additions & 3 deletions docs/api/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +68,7 @@ All classes are available directly in the ``falcon`` package namespace:
# -- snip --
.. tab:: ASGI
.. tab-item:: ASGI

.. code:: python
Expand Down
12 changes: 6 additions & 6 deletions docs/api/media.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/api/middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ when instantiating Falcon's :ref:`App class <app>`. 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:

Expand Down Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions docs/api/multipart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <falcon.media.multipart.BodyPart>` in a form:

.. tabs::
.. tab-set::

.. group-tab:: WSGI
.. tab-item:: WSGI
:sync: wsgi

.. code:: python
Expand All @@ -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
Expand Down Expand Up @@ -72,17 +74,19 @@ 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:

.. autoclass:: falcon.media.multipart.BodyPart
:members:

.. group-tab:: ASGI
.. tab-item:: ASGI
:sync: asgi

.. autoclass:: falcon.asgi.multipart.MultipartForm
:members:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions docs/api/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -511,17 +511,17 @@ 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
# Handle the custom FOO method
def on_foo(self, req, resp):
pass
.. tab:: ASGI
.. tab-item:: ASGI

.. code:: python
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
'sphinx.ext.viewcode',
'sphinx_copybutton',
'sphinx_design',
'sphinx_tabs.tabs',
'myst_parser',
# Falcon-specific extensions
'ext.cibuildwheel',
Expand Down
8 changes: 5 additions & 3 deletions docs/user/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.upload_fileobj>`_:

.. tabs::
.. tab-set::

.. group-tab:: WSGI
.. tab-item:: WSGI
:sync: wsgi

.. code:: python
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions docs/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 <https://pypi.org/project/requests/>`_ package has been installed.
Expand Down Expand Up @@ -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 <https://pypi.org/project/httpx/>`_ package in lieu of
Expand Down
8 changes: 4 additions & 4 deletions falcon/media/validators/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,7 +71,7 @@ def on_post(self, req, resp):
# -- snip --
.. tab:: ASGI
.. tab-item:: ASGI
.. code:: python
Expand All @@ -84,7 +84,7 @@ async def on_post(self, req, resp):
# -- snip --
.. tab:: ASGI (Cythonized App)
.. tab-item:: ASGI (Cythonized App)
.. code:: python
Expand Down
1 change: 0 additions & 1 deletion requirements/docs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pydata-sphinx-theme
PyYAML
Sphinx
sphinx-copybutton
sphinx-tabs
sphinx_design

0 comments on commit 3d696ca

Please sign in to comment.