Skip to content

Commit 4df08a7

Browse files
committed
more doc updates
1 parent 48dd36b commit 4df08a7

13 files changed

+43
-74
lines changed

docs/source/core-concepts.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ the addage "the best code is no code at all," we make the related claim that "th
1919
way to manage state is to have no state at all."
2020

2121
With IDOM the core of your application will be built on the back of basic functions and
22-
coroutines that return :term:`VDOM` models and which do so without state and without
23-
`side effects`_. We call these kinds of model rendering functions
24-
:term:`Pure Elements <Pure Element>`. For example, one might want a function which
22+
coroutines that return :ref:`VDOM <VDOM Mimetype>` models and which do so without state
23+
and without `side effects`_. We call these kinds of model rendering functions
24+
:ref:`Pure Elements`. For example, one might want a function which
2525
accepted a list of strings and turned it into a series of paragraph elements:
2626

2727
.. code-block::
@@ -33,7 +33,7 @@ accepted a list of strings and turned it into a series of paragraph elements:
3333
Stateful Elements
3434
-----------------
3535

36-
A Stateful Element is one which uses a :ref:`Life Cycle Hook`. These life cycle hooks
36+
A Stateful Element is one which uses a :ref:`Life Cycle Hooks`. These life cycle hooks
3737
allow you to add state to otherwise stateless functions. To create a stateful element
3838
you'll need to apply the :func:`~idom.core.element.element` decorator to a coroutine_
3939
whose body contains a hook usage. We'll demonstrate that with a simple
@@ -57,9 +57,9 @@ whose body contains a hook usage. We'll demonstrate that with a simple
5757
Element Layout
5858
--------------
5959

60-
Displaying an element requires you to turn elements into :term:`VDOM` - this is done
61-
using a :class:`~idom.core.layout.Layout`. Layouts are responsible for rendering
62-
elements (turning them into VDOM) and scheduling their re-renders when they
60+
Displaying an element requires you to turn elements into :ref:`VDOM <VDOM Mimetype>` -
61+
this is done using a :class:`~idom.core.layout.Layout`. Layouts are responsible for
62+
rendering elements (turning them into VDOM) and scheduling their re-renders when they
6363
:meth:`~idom.core.layout.Layout.update`. To create a layout, you'll need an
6464
:class:`~idom.core.element.Element` instance, which will become its root, and won't
6565
ever be removed from the model. Then you'll just need to call and await a

docs/source/examples.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ Source of ``chart.js``:
167167
Shared Client Views
168168
-------------------
169169

170-
This example requires the :ref:`~idom.server.sanic.SharedClientStateServer`. Be sure to
171-
replace it in your boilerplate code before going further! Once you've done this we can
172-
just re-display our :ref:`Slideshow` example using the new server. Now all we need to do
173-
is connect to the server with a couple clients to see that their views are synced. This
174-
can be done by navigating to the server URL in seperate browser tabs. Likewise if you're
175-
using a Jupyter Notebook you would display it in multiple cells like this:
170+
This example requires the :class:`~idom.server.sanic.SharedClientStateServer`. Be sure
171+
to replace it in your boilerplate code before going further! Once you've done this we
172+
can just re-display our :ref:`Slideshow` example using the new server. Now all we need
173+
to do is connect to the server with a couple clients to see that their views are synced.
174+
This can be done by navigating to the server URL in seperate browser tabs. Likewise if
175+
you're using a Jupyter Notebook you would display it in multiple cells like this:
176176

177177
**Jupyter Notebook**
178178

docs/source/examples/custom_chart.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,19 @@
2020

2121
@idom.element
2222
async def ShowChartClicks():
23-
shared_last_event = idom.hooks.Shared({})
24-
idom.html.div(
25-
ClickableChart(shared_last_event),
26-
LastEventView(shared_last_event),
27-
)
28-
29-
30-
@idom.element
31-
async def Chart(shared_last_event):
32-
set_last_event = idom.hooks.use_state(shared_last_event)[1]
33-
34-
async def log_event(event):
35-
set_last_event(event)
36-
37-
return ClickableChart(
38-
{"data": data, "onClick": log_event, "style": {"parent": {"width": "500px"}}},
39-
)
40-
41-
42-
@idom.element
43-
async def LastEventView(shared_last_event):
44-
last_event = idom.hooks.use_state(shared_last_event)[0]
45-
23+
last_event, set_last_event = idom.hooks.use_state({})
4624
return idom.html.div(
47-
{"class": "highlight"}, idom.html.pre(json.dumps(last_event, indent=2))
25+
ClickableChart(
26+
{
27+
"data": data,
28+
"onClick": set_last_event,
29+
"style": {"parent": {"width": "500px"}},
30+
},
31+
),
32+
idom.html.div(
33+
{"class": "highlight"},
34+
idom.html.pre(json.dumps(last_event, indent=2)),
35+
),
4836
)
4937

5038

docs/source/examples/primary_secondary_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def pre_seperated(*args):
1818

1919

2020
@idom.element
21-
async def PrimarySecondaryButtons(self):
21+
async def PrimarySecondaryButtons():
2222
state, set_state = idom.hooks.use_state(
2323
{"message": None, "event": None, "info": None}
2424
)

docs/source/examples/snake_game.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def on_direction_change(event):
8282
assign_grid_block_color(grid, snake[-1], "yellow")
8383
set_game_state(GameState.won)
8484

85-
interval = use_interval(0.4)
85+
interval = use_interval(0.5)
8686

8787
@use_async_effect
8888
async def animate():

docs/source/getting-started.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Let's look at the example that you may have seen
1313
async def Slideshow():
1414
index, set_index = idom.hooks.use_state(0)
1515
16-
async def next_image(event):
16+
def next_image(event):
1717
set_index(index + 1)
1818
1919
return idom.html.img(
@@ -36,7 +36,7 @@ Since it's likely a lot to take in at once, we'll break it down piece by piece:
3636
@idom.element
3737
async def Slideshow():
3838
39-
The ``idom.element`` decorator creates an :ref:`Element <Stateful Element>` constructor
39+
The ``idom.element`` decorator creates an :ref:`Element <Stateful Elements>` constructor
4040
whose render function is defined by the `asynchronous function`_ below it. To create
4141
an :class:`~idom.core.element.Element` instance we call ``Slideshow()`` with the same
4242
arguments as its render function. The render function of an Element returns a data
@@ -68,7 +68,7 @@ function allow us to change it. The one required argument of ``use_state`` is th
6868

6969
.. code-block::
7070
71-
async def next_image(event):
71+
def next_image(event):
7272
set_index(index + 1)
7373
7474
The coroutine above will get added as an event handler to the resulting view. When it

docs/source/glossary.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/source/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ Libraries for defining and controlling interactive webpages with Python
1515
core-concepts
1616
life-cycle-hooks
1717
javascript-modules
18-
how-it-works
1918
specifications
2019
extra-features
2120
examples
22-
glossary
2321
known-issues
2422
api
2523

@@ -53,7 +51,7 @@ user clicks an image:
5351
async def Slideshow():
5452
index, set_index = idom.hooks.use_state(0)
5553
56-
async def next_image(event):
54+
def next_image(event):
5755
set_index(index + 1)
5856
5957
return idom.html.img(

docs/source/life-cycle-hooks.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ one state to the next is especially complex or involves nested data structures.
187187
may be slightly more performant as well as being preferable since there is only one
188188
``dispatch_action`` callback versus the many ``set_state`` callbacks.
189189

190-
We can rework the :ref:`Function Updates` counter example to use ``use_reducer``:
190+
We can rework the :ref:`Functional Updates` counter example to use ``use_reducer``:
191191

192192
.. literalinclude:: examples/use_reducer_counter.py
193193

docs/source/specifications.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Specifications
22
==============
33

44
Describes various data structures and protocols used to define and communicate virtual
5-
document object models (:term:`VDOM`). The definitions to below follow in the footsteps
6-
of `a specification <https://github.com/nteract/vdom/blob/master/docs/mimetype-spec.md>`_
5+
document object models (:ref:`VDOM <VDOM Mimetype>`). The definitions to below follow in
6+
the footsteps of
7+
`a specification <https://github.com/nteract/vdom/blob/master/docs/mimetype-spec.md>`_
78
created by `Nteract <https://nteract.io>`_ and which was built into
89
`JupyterLab <https://jupyterlab.readthedocs.io/en/stable/>`_. While IDOM's specification
910
for VDOM is fairly well established, it should not be relied until it's been fully
@@ -167,4 +168,6 @@ Updates to VDOM modules are sent using the `JSON Patch`_ specification.
167168
... this section is still under construction :)
168169

169170

170-
.. _JSON Patch:: http://jsonpatch.com/
171+
.. Links
172+
.. =====
173+
.. _JSON Patch: http://jsonpatch.com/

idom/client/manage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def _package_json() -> Dict[str, Any]:
147147
"snowpack": {
148148
"installOptions": {
149149
"dest": str(WEB_MODULES),
150-
"include": str(CORE_MODULES / "**" / "*.js"),
151150
},
152151
"webDependencies": [],
153152
},

idom/core/element.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def element(function: ElementRenderFunction) -> Callable[..., "Element"]:
1818
1919
Parameters:
2020
function:
21-
The function that will render a :term:`VDOM` model.
21+
The function that will render a :ref:`VDOM <VDOM Mimetype>` model.
2222
"""
2323
if not inspect.iscoroutinefunction(function):
2424
raise TypeError(f"Expected a coroutine function, not {function}")
@@ -49,7 +49,7 @@ def id(self) -> str:
4949

5050
@abc.abstractmethod
5151
async def render(self) -> "VdomDict":
52-
"""Render the element's :term:`VDOM` model."""
52+
"""Render the element's :ref:`VDOM <VDOM Mimetype>` model."""
5353

5454

5555
class Element(AbstractElement):

idom/core/vdom.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def constructor(
123123
constructor.__name__ = tag
124124
qualname_prefix = constructor.__qualname__.rsplit(".", 1)[0]
125125
constructor.__qualname__ = qualname_prefix + f".{tag}"
126-
constructor.__doc__ = f"""Create a new ``<{tag}/>`` - returns :term:`VDOM`."""
126+
constructor.__doc__ = (
127+
f"""Create a new ``<{tag}/>`` - returns :ref:`VDOM <VDOM Mimetype>`."""
128+
)
127129

128130
return constructor
129131

0 commit comments

Comments
 (0)