Skip to content

Commit f0b45f6

Browse files
committed
rework docs to use backend instead of server
1 parent 1074366 commit f0b45f6

File tree

10 files changed

+60
-55
lines changed

10 files changed

+60
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _Writing Your Own Backend:
2+
3+
Writing Your Own Backend 🚧
4+
===========================
5+
6+
.. note::
7+
8+
Under construction 🚧

docs/source/guides/escape-hatches/writing-your-own-server.rst

-8
This file was deleted.

docs/source/guides/getting-started/installing-idom.rst

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
Installing IDOM
22
===============
33

4-
Installing IDOM with ``pip`` will generally require doing so alongside a supported
5-
server implementation. This can be done by specifying an installation extra using square
6-
brackets. For example, if we want to run IDOM using `Starlette
7-
<https://www.starlette.io/>`__ we would run:
4+
Installing IDOM with ``pip`` will typically require doing so alongside a built-in
5+
backend implementation. This can be done by specifying an installation extra using
6+
square brackets. For example, if we want to run IDOM using the `Starlette
7+
<https://www.starlette.io/>`__ backend we would run:
88

99
.. code-block:: bash
1010
1111
pip install "idom[starlette]"
1212
13-
If you want to install a "pure" version of IDOM without a server implementation you can
14-
do so without any installation extras. You might do this if you wanted to user a server
15-
which is not officially supported or if you wanted to manually pin your dependencies:
13+
If you want to install a "pure" version of IDOM without a backend implementation you can
14+
do so without any installation extras. You might do this if you wanted to use a backend
15+
which does not have built-in support or if you wanted to manually pin your dependencies:
1616

1717
.. code-block:: bash
1818
1919
pip install idom
2020
2121
22-
Officially Supported Servers
23-
----------------------------
22+
Built-in Backends
23+
-----------------
2424

25-
IDOM includes built-in support for a variety web server implementations. To install the
25+
IDOM includes built-in support for a variety backend implementations. To install the
2626
required dependencies for each you should substitute ``starlette`` from the ``pip
2727
install`` command above with one of the options below:
2828

@@ -39,15 +39,15 @@ If you need to, you can install more than one option by separating them with com
3939
pip install "idom[fastapi,flask,sanic,starlette,tornado]"
4040
4141
Once this is complete you should be able to :ref:`run IDOM <Running IDOM>` with your
42-
chosen server implementation.
42+
chosen implementation.
4343

4444

45-
Installing In Other Frameworks
46-
------------------------------
45+
Using Other Backends
46+
--------------------
4747

48-
While IDOM can run in a variety of contexts, sometimes web frameworks require extra work
49-
in order to integrate with them. In these cases, the IDOM team distributes bindings for
50-
various frameworks as separate Python packages. For documentation on how to install and
48+
While IDOM can run in a variety of contexts, sometimes frameworks require extra work in
49+
order to integrate with them. In these cases, the IDOM team distributes bindings for
50+
those frameworks as separate Python packages. For documentation on how to install and
5151
run IDOM in these supported frameworks, follow the links below:
5252

5353
.. raw:: html

docs/source/guides/getting-started/running-idom.rst

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Running IDOM in Production
1212
--------------------------
1313

1414
The first thing you'll need to do if you want to run IDOM in production is choose a
15-
server implementation and follow its documentation on how to create and run an
16-
application. This is the server :ref:`you probably chose <Officially Supported Servers>`
17-
when installing IDOM. Then you'll need to configure that application with an IDOM view.
18-
We should the basics how how to run each supported server below, but all implementations
19-
will follow a pattern similar to the following:
15+
backend implementation and follow its documentation on how to create and run an
16+
application. This is the backend :ref:`you probably chose <Officially Supported
17+
Backends>` when installing IDOM. Then you'll need to configure that application with an
18+
IDOM view. We show the basics of how to set up, and then run, each supported backend
19+
below, but all implementations will follow a pattern similar to the following:
2020

2121
.. code-block::
2222
@@ -34,17 +34,17 @@ will follow a pattern similar to the following:
3434
app = Application()
3535
configure(app, HelloWorld)
3636
37-
You'll then run this ``app`` using a `ASGI <https://asgi.readthedocs.io/en/latest/>`__ or
38-
`WSGI <https://wsgi.readthedocs.io/>`__ server from the command line.
37+
You'll then run this ``app`` using an `ASGI <https://asgi.readthedocs.io/en/latest/>`__
38+
or `WSGI <https://wsgi.readthedocs.io/>`__ server from the command line.
3939

4040

4141
Running with `FastAPI <https://fastapi.tiangolo.com>`__
4242
.......................................................
4343

4444
.. idom:: _examples/run_fastapi
4545

46-
Then assuming you put this in ``main.py``, you can run the ``app`` using `Uvicorn
47-
<https://www.uvicorn.org/>`__:
46+
Then assuming you put this in ``main.py``, you can run the ``app`` using the `Uvicorn
47+
<https://www.uvicorn.org/>`__ ASGI server:
4848

4949
.. code-block:: bash
5050
@@ -56,8 +56,8 @@ Running with `Flask <https://palletsprojects.com/p/flask/>`__
5656

5757
.. idom:: _examples/run_flask
5858

59-
Then assuming you put this in ``main.py``, you can run the ``app`` using `Gunicorn
60-
<https://gunicorn.org/>`__:
59+
Then assuming you put this in ``main.py``, you can run the ``app`` using the `Gunicorn
60+
<https://gunicorn.org/>`__ WSGI server:
6161

6262
.. code-block:: bash
6363
@@ -82,8 +82,8 @@ Running with `Starlette <https://www.starlette.io/>`__
8282

8383
.. idom:: _examples/run_starlette
8484

85-
Then assuming you put this in ``main.py``, you can run the application using `Uvicorn
86-
<https://www.uvicorn.org/>`__:
85+
Then assuming you put this in ``main.py``, you can run the application using the
86+
`Uvicorn <https://www.uvicorn.org/>`__ ASGI server:
8787

8888
.. code-block:: bash
8989
@@ -143,10 +143,10 @@ Errors will be displayed where the uppermost component is located in the view:
143143
.. idom:: _examples/debug_error_example
144144

145145

146-
Server Configuration Options
147-
----------------------------
146+
Backend Configuration Options
147+
-----------------------------
148148

149-
IDOM's various server implementations come with ``Options`` that can be passed to their
149+
IDOM's various backend implementations come with ``Options`` that can be passed to their
150150
respective ``configure()`` functions in the following way:
151151

152152
.. code-block::
@@ -187,8 +187,8 @@ embedding one the examples from this documentation into your own webpage:
187187
.. note::
188188

189189
For more information on how to use the client see the :ref:`Javascript API`
190-
reference. Or if you need to, your can :ref:`write your own server implementation
191-
<writing your own server>`.
190+
reference. Or if you need to, your can :ref:`write your own backend implementation
191+
<writing your own backend>`.
192192

193193
As mentioned though, this is connecting to the server that is hosting this
194194
documentation. If you want to connect to a view from your own server, you'll need to

docs/source/index.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ of HTML element called an ``h1`` `section heading
7373
<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements>`__.
7474
Importantly though, a ``@component`` decorator has been applied to the ``App`` function
7575
to turn it into a :ref:`component <Your First Components>`. Finally, we :ref:`run
76-
<Running IDOM>` an application server by passing the ``App`` component to the ``run()``
76+
<Running IDOM>` a development server by passing the ``App`` component to the ``run()``
7777
function.
7878

79+
.. note::
80+
81+
See :ref:`Running IDOM in Production` to learn how to use a production-grade server
82+
to run IDOM.
83+
7984

8085
Learning IDOM
8186
-------------

src/idom/backend/default.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from idom.types import RootComponentConstructor
77

8-
from .types import Location, ServerImplementation
8+
from .types import BackendImplementation, Location
99
from .utils import all_implementations
1010

1111

@@ -45,10 +45,10 @@ def use_location() -> Location:
4545
return _default_implementation().use_location()
4646

4747

48-
_DEFAULT_IMPLEMENTATION: ServerImplementation[Any] | None = None
48+
_DEFAULT_IMPLEMENTATION: BackendImplementation[Any] | None = None
4949

5050

51-
def _default_implementation() -> ServerImplementation[Any]:
51+
def _default_implementation() -> BackendImplementation[Any]:
5252
"""Get the first available server implementation"""
5353
global _DEFAULT_IMPLEMENTATION
5454

src/idom/backend/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
@runtime_checkable
16-
class ServerImplementation(Protocol[_App]):
16+
class BackendImplementation(Protocol[_App]):
1717
"""Common interface for IDOM's builti-in server implementations"""
1818

1919
def configure(

src/idom/backend/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from idom.config import IDOM_WEB_MODULES_DIR
1414
from idom.types import RootComponentConstructor
1515

16-
from .types import ServerImplementation
16+
from .types import BackendImplementation
1717

1818

1919
logger = logging.getLogger(__name__)
@@ -32,7 +32,7 @@ def run(
3232
component: RootComponentConstructor,
3333
host: str = "127.0.0.1",
3434
port: int | None = None,
35-
implementation: ServerImplementation[Any] | None = None,
35+
implementation: BackendImplementation[Any] | None = None,
3636
) -> None:
3737
"""Run a component with a development server"""
3838
logger.warn(
@@ -113,15 +113,15 @@ def find_available_port(
113113
)
114114

115115

116-
def all_implementations() -> Iterator[ServerImplementation[Any]]:
116+
def all_implementations() -> Iterator[BackendImplementation[Any]]:
117117
"""Yield all available server implementations"""
118118
for name in SUPPORTED_PACKAGES:
119119
try:
120120
module = import_module(f"idom.server.{name}")
121121
except ImportError: # pragma: no cover
122122
continue
123123

124-
if not isinstance(module, ServerImplementation):
124+
if not isinstance(module, BackendImplementation):
125125
raise TypeError( # pragma: no cover
126126
f"{module.__name__!r} is an invalid implementation"
127127
)

src/idom/testing/server.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from urllib.parse import urlencode, urlunparse
99

1010
from idom.backend import default as default_server
11-
from idom.backend.types import ServerImplementation
11+
from idom.backend.types import BackendImplementation
1212
from idom.backend.utils import find_available_port
1313
from idom.widgets import hotswap
1414

@@ -36,7 +36,7 @@ def __init__(
3636
host: str = "127.0.0.1",
3737
port: Optional[int] = None,
3838
app: Any | None = None,
39-
implementation: ServerImplementation[Any] | None = None,
39+
implementation: BackendImplementation[Any] | None = None,
4040
options: Any | None = None,
4141
) -> None:
4242
self.host = host

src/idom/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- :mod:`idom.server.types`
55
"""
66

7-
from .backend.types import Location, ServerImplementation
7+
from .backend.types import BackendImplementation, Location
88
from .core.hooks import Context
99
from .core.types import (
1010
ComponentConstructor,
@@ -45,5 +45,5 @@
4545
"VdomChildren",
4646
"VdomDict",
4747
"VdomJson",
48-
"ServerImplementation",
48+
"BackendImplementation",
4949
]

0 commit comments

Comments
 (0)