Skip to content

Commit e452243

Browse files
committed
Fix doc typos
Thanks Dana :)
1 parent 58cf0c6 commit e452243

File tree

6 files changed

+60
-61
lines changed

6 files changed

+60
-61
lines changed

docs/source/core-concepts.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pure Elements
1313
-------------
1414

1515
As in most programming paradigms, so many of the problems come down to how we manage
16-
state, and the first tool in encouraging its proper curation is the usage of
16+
state. The first tool in encouraging its proper curation is the usage of
1717
`pure functions`_. The benefit of a pure function is that there's no state. Similar to
1818
the addage "the best code is no code at all," we make the related claim that "the best
1919
way to manage state is to have no state at all."
@@ -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 lifecycle hooks
36+
A Stateful Element is one which uses a :ref:`Life Cycle Hook`. 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
@@ -70,11 +70,11 @@ ever be removed from the model. Then you'll just need to call and await a
7070
async with idom.Layout(ClickCount()) as layout:
7171
patch = await layout.render()
7272

73-
The layout also handles the triggering event handlers. Normally this is done
74-
automatically by a :ref:`Renderer <Layout Renderer>`, but for now we'll to it manually.
75-
To do use we can use a trick to hard-code the ``event_handler_id`` so we can pass it,
76-
and a fake event, to the layout's :meth:`~idom.core.layout.Layout.dispatch` method. Then
77-
we just have to re-render the layout and see what changed:
73+
The layout also handles the triggering of event handlers. Normally this is done
74+
automatically by a :ref:`Renderer <Layout Renderer>`, but for now we'll do it manually.
75+
We can use a trick to hard-code the ``event_handler_id`` so we can pass it, and a fake
76+
event, to the layout's :meth:`~idom.core.layout.Layout.dispatch` method. Then we just
77+
have to re-render the layout and see what changed:
7878

7979
.. testcode::
8080

@@ -118,8 +118,8 @@ Layout Renderer
118118
An :class:`~idom.core.render.AbstractRenderer` implementation is a relatively thin layer
119119
of logic around a :class:`~idom.core.layout.Layout` which drives the triggering of
120120
events and layout updates by scheduling an asynchronous loop that will run forever -
121-
effectively animating the model. To run the loop the renderer's
122-
:meth:`~idom.core.render.AbstractRenderer.run` method accepts two callbacks, one is a
121+
effectively animating the model. To execute the loop, the renderer's
122+
:meth:`~idom.core.render.AbstractRenderer.run` method accepts two callbacks. One is a
123123
"send" callback to which the renderer passes updates, while the other is "receive"
124124
callback that's called by the renderer to events it should execute.
125125

@@ -172,10 +172,10 @@ Layout Server
172172
-------------
173173

174174
The :ref:`Renderer <Layout Renderer>` allows you to animate the layout, but we still
175-
need to get the models on the screen, and one of the last steps in that journey is to
176-
send them over the wire. To do that you need an
175+
need to get the models on the screen. One of the last steps in that journey is to send
176+
them over the wire. To do that you need an
177177
:class:`~idom.server.base.AbstractRenderServer` implementation. Right now we have a
178-
builtin subclass that relies on :mod:`sanic`, an async enabled web server. In principle
178+
built in subclass that relies on :mod:`sanic`, an async enabled web server. In principle
179179
though, the base server class is capable of working with any other async enabled server
180180
framework. Potential candidates range from newer frameworks like
181181
`vibora <https://vibora.io/>`__, `starlette <https://www.starlette.io/>`__, and
@@ -188,7 +188,7 @@ starting to add support for asyncio like
188188
an `issue <https://github.com/rmorshea/idom/issues>`__.
189189

190190
In the case of our :class:`~idom.server.sanic.SanicRenderServer` types we have one
191-
implementation per builtin :ref:`Renderer <Layout Renderer>`:
191+
implementation per built in :ref:`Renderer <Layout Renderer>`:
192192

193193
- :class:`idom.server.sanic.PerClientStateServer`
194194

@@ -201,7 +201,7 @@ two ways - as a standalone application or as an extension to an existing applica
201201
Standalone Server Usage
202202
.......................
203203

204-
The implementation constructs a default application that's used to server the renders of
204+
The implementation constructs a default application that's used to serve the renders of
205205
the model:
206206

207207
.. code-block:: python
@@ -220,7 +220,7 @@ the model:
220220
Server Extension Usage
221221
......................
222222

223-
The implementation registers hooks into the application to server the model once run:
223+
The implementation registers hooks into the application to serve the model once run:
224224

225225
.. code-block:: python
226226

docs/source/getting-started.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Let's look at the example that you may have seen
2929
server = idom.server.sanic.PerClientStateServer(Slideshow)
3030
server.run(host, port)
3131
32-
Since it's likely a lot to take in at once we'll break it down piece by piece:
32+
Since it's likely a lot to take in at once, we'll break it down piece by piece:
3333

3434
.. code-block::
3535
@@ -58,9 +58,9 @@ to the Element's render function.
5858

5959
The ``use_state`` hook returns two values - the *current* state value and a function
6060
that let's you update that value. In the case of ``Slideshow`` the value of the
61-
``use_state`` hook determines which image is show to the user, while its update function
62-
allow us to change it.The one required argument of ``use_state`` is the *initial* state
63-
value.
61+
``use_state`` hook determines which image is showm to the user, while its update
62+
function allow us to change it. The one required argument of ``use_state`` is the
63+
*initial* state value.
6464

6565
.. note::
6666

@@ -71,7 +71,7 @@ value.
7171
async def next_image(event):
7272
set_index(index + 1)
7373
74-
The coroutine above will get added as an event handler to the resulting view. Whe it
74+
The coroutine above will get added as an event handler to the resulting view. When it
7575
responds to an event it will use the update function returned by the ``use_state`` Hook
7676
to change which image is shown to the user. Calling the update function will schedule
7777
the Element to be re-rendered. That is, the Element's render function will be called
@@ -80,8 +80,8 @@ again, and its new result will be displayed.
8080
.. note::
8181

8282
Even handlers like ``next_image`` which respond to user interactions recieve an
83-
``event`` dictionary that contains different information depending on they type
84-
of event that occured. All supported events and the data they contain is listed
83+
``event`` dictionary that contains different information depending on the type of
84+
event that occured. All supported events and the data they contain is listed
8585
`here`__.
8686

8787
__ https://reactjs.org/docs/events.html
@@ -96,12 +96,12 @@ __ https://reactjs.org/docs/events.html
9696
}
9797
)
9898
99-
Finally we come the end the ``Slideshow`` body where we return a model for an ``<img/>``
100-
element that draws its image from https://picsum.photos. Our ``next_image`` event
101-
handler has been added to the image so that when an ``onClick`` event occurs we can
102-
respond to it. We've also added a little bit of CSS styling to the image so that when
103-
the cursor hoverse over the image it will become a pointer so it appears clickable. The
104-
returned model conforms to the `VDOM mimetype specification`_.
99+
Finally we come to the end of the ``Slideshow`` body where we return a model for an
100+
``<img/>`` element that draws its image from https://picsum.photos. Our ``next_image``
101+
event handler has been added to the image so that when an ``onClick`` event occurs we
102+
can respond to it. We've also added a little bit of CSS styling to the image so that
103+
when the cursor hoverse over the image it will become a pointer so it appears clickable.
104+
The returned model conforms to the `VDOM mimetype specification`_.
105105

106106
.. code-block::
107107
@@ -113,7 +113,7 @@ These last steps prepare a simple web server that will send the layout of elemen
113113
defined in our ``Slideshow`` to the browser and receive any incoming events from the
114114
browser via a websocket. The server has "per client state" because each client that
115115
connects to it will see a fresh view of the layout. If clients should see views with a
116-
common state you can use the ``SharedClientState`` server instead.
116+
common state you can use the ``SharedClientStateServer`` instead.
117117

118118
To display the layout we can navigate to http://localhost:8765/client/index.html or
119119
use ``idom.display()`` to show it in a Jupyter Notebook via a widget.

docs/source/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Try it Now!
2929

3030
- In a Jupyter Notebook - |launch-binder|
3131

32-
- With an online editor - `IDOM Sandbox`_
32+
- Using working :ref:`examples <Examples>`
3333

3434

3535
Early Days
@@ -69,8 +69,8 @@ user clicks an image:
6969
server.run(host, port)
7070
7171
Running this will serve our slideshow to ``"https://localhost:8765"``. You can try out
72-
a working example by enabling the widget below - clicking the image should cause it to
73-
change 🖱️
72+
a working example by enabling the widget below. Once enabled clicking the image will
73+
cause the widget to change 🖱️
7474

7575
.. interactive-widget:: slideshow
7676

docs/source/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ In order to work with IDOM's source code you'll need to install:
4949

5050
- npm_
5151

52-
You'll begin by copy the source from GitHub onto your computer using Git:
52+
You'll begin by copying the source from GitHub onto your computer using Git:
5353

5454
.. code-block:: bash
5555
5656
git clone https://github.com/rmorshea/idom.git
5757
cd idom
5858
59-
At this point you should be able to run this install command to:
59+
At this point you should be able to run the command below to:
6060

6161
- Install an editable version of the Python code
6262

@@ -78,8 +78,8 @@ simply run the following to re-evaluate the ``package.json``:
7878
pip install -e .
7979
8080
81-
Running The Test
82-
----------------
81+
Running The Tests
82+
-----------------
8383

8484
The test suite for IDOM is executed using Tox_ and covers:
8585

@@ -122,7 +122,7 @@ If you prefer to run the tests using a headless browser:
122122
Building The Documentation
123123
--------------------------
124124

125-
Building the documentation as it's is deployed in production requires Docker_. Once you've
125+
Building the documentation as it's deployed in production requires Docker_. Once you've
126126
installed ``docker`` you'll need to build and then run a container with the service:
127127

128128
.. code-block:: bash

docs/source/life-cycle-hooks.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use_state
3232
Returns a stateful value and a function to update it.
3333

3434
During the first render the ``state`` will be identical to the ``initial_state`` passed
35-
as the first argument. However in subsiquent renders ``state`` will take on the value
35+
as the first argument. However in subsequent renders ``state`` will take on the value
3636
passed to ``set_state``.
3737

3838
.. code-block::
@@ -41,7 +41,7 @@ passed to ``set_state``.
4141
4242
The ``set_state`` function accepts a ``new_state`` as its only argument and schedules a
4343
re-render of the element where ``use_state`` was initially called. During these
44-
subsiquent re-renders the ``state`` returned by ``use_state`` will take on the value
44+
subsequent re-renders the ``state`` returned by ``use_state`` will take on the value
4545
of ``new_state``.
4646

4747
.. note::
@@ -56,7 +56,7 @@ Functional Updates
5656

5757
If the new state is computed from the previous state, you can pass a function which
5858
accepts a single argument (the previous state) and returns the next state. Consider this
59-
simple use case of a counter where we've pulled out logic for incrementing and
59+
simply use case of a counter where we've pulled out logic for incrementing and
6060
decrementing the count:
6161

6262
.. literalinclude:: examples/use_state_counter.py
@@ -65,7 +65,7 @@ decrementing the count:
6565

6666
We use the functional form for the "+" and "-" buttons since the next ``count`` depends
6767
on the previous value, while for the "Reset" button we simple assign the
68-
``initial_count`` since it's independent of the prior ``count``. This is a trivial
68+
``initial_count`` since it is independent of the prior ``count``. This is a trivial
6969
example, but it demonstrates how complex state logic can be factored out into well
7070
defined and potentially reuseable functions.
7171

@@ -103,19 +103,17 @@ use_effect
103103
104104
use_effect(did_render)
105105
106-
The ``use_effect`` hook accepts a function which is may be imperative, or mutate state.
107-
The function will be called once the element has rendered, that is, when the
108-
element's render function and those of any child elements it produces have rendered
109-
successfully.
106+
The ``use_effect`` hook accepts a function which may be imperative, or mutate state. The
107+
function will be called immediately after the layout has fully updated.
110108

111-
Mutations, subscriptsion, delayed actions, and other `side effects`_ can cause
109+
Mutations, subscriptions, delayed actions, and other `side effects`_ can cause
112110
unexpected bugs if placed in the main body of an element's render function. Thus the
113111
``use_effect`` hook provides a way to safely escape the purely functional world of
114112
element render functions.
115113

116114
.. note::
117115

118-
Normally in react the ``did_render`` function is called once an update has been
116+
Normally in React the ``did_render`` function is called once an update has been
119117
commited to the screen. Since no such action is performed by IDOM, and the time
120118
at which the update is displayed cannot be known we are unable to achieve parity
121119
with this behavior.
@@ -124,15 +122,16 @@ element render functions.
124122
Cleaning Up Effects
125123
...................
126124

127-
If the effect you wish to enact creates resources you'll probably need to clean them up.
128-
In such cases you may simply return a function the addresses this from the function
129-
which created the resource. Consider the case of opening and then closing a connection:
125+
If the effect you wish to enact creates resources, you'll probably need to clean them
126+
up. In such cases you may simply return a function that addresses this from the
127+
``did_render`` function which created the resource. Consider the case of opening and
128+
then closing a connection:
130129

131130
.. code-block::
132131
133132
def establish_connection():
134133
connection = open_connection(url)
135-
return connection.close
134+
return lambda: close_connection(connection)
136135
137136
use_effect(establish_connection)
138137
@@ -145,7 +144,7 @@ time an element renders.
145144
Conditional Effects
146145
...................
147146

148-
By default effects are triggered after ever successful render to ensure that all state
147+
By default, effects are triggered after every successful render to ensure that all state
149148
referenced by the effect is up to date. However you can limit the number of times an
150149
effect is fired by specifying exactly what state the effect depends on. In doing so
151150
the effect will only occur when the given state changes:
@@ -154,7 +153,7 @@ the effect will only occur when the given state changes:
154153
155154
def establish_connection():
156155
connection = open_connection(url)
157-
return connection.close
156+
return lambda: close_connection(connection)
158157
159158
use_effect(establish_connection, [url])
160159
@@ -210,12 +209,12 @@ use_callback
210209
211210
A derivative of :ref:`use_memo`, the ``use_callback`` hook teturns a
212211
`memoized <memoization>`_ callback. This is useful when passing callbacks to child
213-
elements which check reference equality to prevent unnecessary renders. The of the
212+
elements which check reference equality to prevent unnecessary renders. The of
214213
``memoized_callback`` will only change when the given depdencies do.
215214

216215
.. note::
217216

218-
The list of "dependencies" are not passed as arguments to the function ostensibly
217+
The list of "dependencies" are not passed as arguments to the function. Ostensibly
219218
though, that is what they represent. Thus any variable referenced by the function
220219
must be listed as dependencies. We're working on a linter to help enforce this
221220
[GH202]_.
@@ -243,9 +242,9 @@ after) and should not incur side effects.
243242

244243
.. warning::
245244

246-
Remember that you shouldn't optimize something else you know it's a performance
247-
bottleneck. Write your code without ``use_memo`` first and then add it to later
248-
to targeted sections that need a speed-up.
245+
Remember that you shouldn't optimize something unless you know it's a performance
246+
bottleneck. Write your code without ``use_memo`` first and then add it to targeted
247+
sections that need a speed-up.
249248

250249
.. note::
251250

@@ -267,9 +266,9 @@ Returns a mutable :class:`~idom.core.hooks.Ref` object that has a single
267266
``initial_state``. The identity of the ``Ref`` object will be preserved for the lifetime
268267
of the element.
269268

270-
A ``Ref`` is most useful if you need to incur side effect since updating its
269+
A ``Ref`` is most useful if you need to incur side effects since updating its
271270
``.current`` attribute doesn't trigger a re-render of the element. You'll often use this
272-
hook alongside :ref:`use_effect` or in response to element event handlers. The
271+
hook alongside :ref:`use_effect` or in response to element event handlers.
273272
:ref:`The Game Snake` provides a good use case for ``use_ref``.
274273

275274

idom/core/element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Element(AbstractElement):
6060
From there an element instance will communicate its needs to the layout. For example
6161
when an element wants to re-render it will call :meth:`idom.core.layout.Layout.element_updated`.
6262
63-
The lifecycle of an element typically goes in this order:
63+
The life cycle of an element typically goes in this order:
6464
6565
1. The element instance is instantiated.
6666

0 commit comments

Comments
 (0)