Skip to content

Commit f6196f1

Browse files
committed
add docs for new render servers
1 parent c53d871 commit f6196f1

File tree

6 files changed

+52
-16
lines changed

6 files changed

+52
-16
lines changed

docs/source/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@
225225
# Example configuration for intersphinx: refer to the Python standard library.
226226
intersphinx_mapping = {
227227
"https://docs.python.org/": None,
228-
"https://pyalect.readthedocs.io/en/latest": None,
228+
"pyalect": ("https://pyalect.readthedocs.io/en/latest", None),
229+
"sanic": ("https://sanic.readthedocs.io/en/latest/", None),
230+
"tornado": ("https://www.tornadoweb.org/en/stable/", None),
231+
"flask": ("https://flask.palletsprojects.com/en/1.1.x/", None),
229232
}
230233

231234
# -- Options for todo extension ----------------------------------------------

docs/source/core-concepts.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,32 @@ Layout Server
170170
The :ref:`Dispatcher <Layout Dispatcher>` allows you to animate the layout, but we still
171171
need to get the models on the screen. One of the last steps in that journey is to send
172172
them over the wire. To do that you need an
173-
:class:`~idom.server.base.AbstractRenderServer` implementation. Right now we have a
174-
built in subclass that relies on :mod:`sanic`, an async enabled web server. In principle
175-
though, the base server class is capable of working with any other async enabled server
176-
framework. Potential candidates range from newer frameworks like
177-
`vibora <https://vibora.io/>`__, `starlette <https://www.starlette.io/>`__, and
178-
`aiohttp <https://aiohttp.readthedocs.io/en/stable/>`__ to older ones that are
179-
starting to add support for asyncio like
180-
`tornado <https://www.tornadoweb.org/en/stable/asyncio.html>`__.
173+
:class:`~idom.server.base.AbstractRenderServer` implementation. Presently, IDOM comes
174+
with support for the following web servers:
181175

182-
.. note::
183-
If using or implementing a bridge between IDOM and these servers interests you post
184-
an `issue <https://github.com/rmorshea/idom/issues>`__.
176+
- :class:`sanic.app.Sanic` (``pip install idom[sanic]``)
177+
178+
- :class:`idom.server.sanic.PerClientStateServer`
179+
180+
- :class:`idom.server.sanic.SharedClientStateServer`
181+
182+
- :class:`flask.Flask` (``pip install idom[flask]``)
185183

186-
In the case of our :class:`~idom.server.sanic.SanicRenderServer` types we have one
187-
implementation per built in :ref:`Dispatcher <Layout Dispatcher>`:
184+
- :class:`idom.server.flask.PerClientStateServer`
188185

189-
- :class:`idom.server.sanic.PerClientStateServer`
186+
- :class:`tornado.web.Application` (``pip install idom[tornado]``)
187+
188+
- :class:`idom.server.tornado.PerClientStateServer`
189+
190+
However, in principle, the base server class is capable of working with any other async
191+
enabled server framework. Potential candidates range from newer frameworks like
192+
`vibora <https://vibora.io/>`__ and `starlette <https://www.starlette.io/>`__ to
193+
`aiohttp <https://aiohttp.readthedocs.io/en/stable/>`__.
194+
195+
.. note::
190196

191-
- :class:`idom.server.sanic.SharedClientStateServer`
197+
If using or implementing a bridge between IDOM and an async server not listed here
198+
interests you, post an `issue <https://github.com/rmorshea/idom/issues>`__.
192199

193200
The main thing to understand about server implementations is that they can function in
194201
two ways - as a standalone application or as an extension to an existing application.

docs/source/package-api.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ Sanic Servers
4646
:members:
4747

4848

49+
Flask Servers
50+
-------------
51+
52+
.. automodule:: idom.server.flask
53+
:members:
54+
55+
56+
Tornado Servers
57+
---------------
58+
59+
.. automodule:: idom.server.tornado
60+
:members:
61+
62+
4963
HTML Widgets
5064
------------
5165

idom/server/flask.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525

2626
class Config(TypedDict, total=False):
27+
"""Render server config for :class:`FlaskRenderServer`"""
28+
2729
import_name: str
2830
url_prefix: str
2931
cors: Union[bool, Dict[str, Any]]
@@ -161,6 +163,8 @@ def _generic_run_application(
161163

162164

163165
class PerClientStateServer(FlaskRenderServer):
166+
"""Each client view will have its own state."""
167+
164168
_dispatcher_type = SingleViewDispatcher
165169

166170

idom/server/sanic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525

2626
class Config(TypedDict, total=False):
27+
"""Config for :class:`SanicRenderServer`"""
28+
2729
cors: Union[bool, Dict[str, Any]]
2830
url_prefix: str
2931
server_static_files: bool

idom/server/tornado.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020

2121
class Config(TypedDict):
22+
"""Render server config for :class:`TornadoRenderServer` subclasses"""
23+
2224
base_url: str
2325
serve_static_files: bool
2426
redirect_root_to_index: bool
2527

2628

2729
class TornadoRenderServer(AbstractRenderServer[Application, Config]):
30+
"""A base class for all Tornado render servers"""
2831

2932
_model_stream_handler_type: Type[WebSocketHandler]
3033

@@ -117,6 +120,7 @@ def _run_application_in_thread(
117120

118121

119122
class PerClientStateModelStreamHandler(WebSocketHandler):
123+
"""A web-socket handler that serves up a new model stream to each new client"""
120124

121125
_dispatcher_type: Type[AbstractDispatcher] = SingleViewDispatcher
122126
_dispatcher_inst: AbstractDispatcher
@@ -155,4 +159,6 @@ def on_close(self):
155159

156160

157161
class PerClientStateServer(TornadoRenderServer):
162+
"""Each client view will have its own state."""
163+
158164
_model_stream_handler_type = PerClientStateModelStreamHandler

0 commit comments

Comments
 (0)