Skip to content

Commit 7d9e99b

Browse files
committed
Grammar and consistency fixes, added some TODO items
1 parent e02465d commit 7d9e99b

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

contingent/chapter.rst

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ does not change any of the information in the table of contents.
109109
But it turns out that Sphinx is not quite as clever
110110
as it might have at first appeared!
111111
It goes ahead and does the redundant work of rebuilding
112-
``index.html`` even though it will come out exactly the same. ::
112+
``index.html`` even though the resulting contents
113+
will be exactly the same. ::
113114

114115
writing output... [ 50%] index
115116
writing output... [100%] tutorial
@@ -202,7 +203,7 @@ The problem outlined above is not specific to Sphinx.
202203
Not only does it haunt other document systems, like LaTeX,
203204
but it can even plague projects
204205
that are simply trying to direct compilation steps
205-
with the venerable make utility,
206+
with the venerable ``make`` utility,
206207
if their assets happen to cross-reference in interesting ways.
207208

208209
As the problem is ancient and universal,
@@ -255,7 +256,7 @@ each produce a corresponding HTML output file.
255256
The most natural way to express these relationships
256257
is as a collection of boxes and arrows —
257258
or, in mathematician terminology, *nodes* and *edges*
258-
to form a graph:
259+
to form a *graph*:
259260

260261
.. figure:: figure1.png
261262

@@ -272,6 +273,12 @@ by giving them direct support in the language syntax.
272273
You can create new instances of the big-four data structures
273274
by simply typing them into your source code.
274275

276+
.. TODO: Only two of these four bullets describe the data structure's
277+
.. syntax. I suggest that we remove the description of the syntax since
278+
.. we immediately *demonstrate* it with examples. But if we want to keep
279+
.. the descriptions, we should probably be consistent and describe the
280+
.. syntax for all four.
281+
275282
* The **tuple** is a read-only sequence
276283
whose syntax is parentheses around comma-separated items.
277284
Tuples are used to hold heterogeneous data —
@@ -347,6 +354,8 @@ This would allow quick iteration across all of our edges,
347354
fast insert and delete operations for a single edge,
348355
and a quick way to check whether a particular edge was present.
349356

357+
.. TODO: Perhaps demonstrate these operations here?
358+
350359
Unfortunately, those are not the only operations we need.
351360

352361
A build system like Contingent
@@ -410,13 +419,15 @@ it supports the fast lookup that Contingent needs.
410419
The Proper Use of Classes
411420
=========================
412421

422+
.. TODO: rework this and following
423+
413424
You may have been surprised
414425
by the absence of classes in the above discussion
415426
of Python data structures.
416427
After all, they are a frequent mechanism for organizing data
417428
and get defined through a dedicated Python syntax.
418429

419-
But it turns out that classes are often
430+
But it turns out that classes are often orthogonal
420431
to the question of data structure design.
421432
Classes simply repeat data structures that we have already seen:
422433

@@ -480,7 +491,7 @@ as a concise and fairly consistent indicator
480491
to other programmers,
481492
including our future selves,
482493
that the attribute is best treated
483-
as part of the internal invisible machinery of the class.
494+
as part of the invisible internal machinery of the class.
484495

485496
Why are we using a “defaultdict” instead of a standard dict?
486497
It automatically handles the special case of a missing key.
@@ -565,7 +576,7 @@ without having to learn how to traverse our data structure:
565576

566577
.. include:: contingent/graphlib.py
567578
:code: python
568-
:start-line: 65
579+
:start-line: 64
569580
:end-line: 69
570581

571582
The ``Graph.sorted()`` method, if you want to examine it later,
@@ -822,6 +833,9 @@ might involve a few basic tasks.
822833
... title, body = parse(filename)
823834
... return title
824835

836+
.. TODO: something is wrong with the next paragraph; looks like a bad
837+
.. edit
838+
825839
This task nicely illustrates the
826840
separation of responsibilities between
827841
the parts of a document processing system:
@@ -840,9 +854,9 @@ might involve a few basic tasks.
840854
In an OO solution,
841855
``parse()`` would return some sort of ``Document`` object
842856
that has ``title_of()`` as a method or property.
843-
In fact, Sphinx works exactly this way.
844-
Its ``Parser`` subsystem producing a “Docutils document tree” object
845-
for the other parts of the system.
857+
In fact, Sphinx works exactly this way:
858+
its ``Parser`` subsystem produces a “Docutils document tree” object
859+
for the other parts of the system to use.
846860

847861
Contingent is not opinionated
848862
with regard to these differing design paradigms
@@ -920,12 +934,12 @@ surround the invocation of a task T:
920934
4. Return its result.
921935

922936
To intercept task calls,
923-
the ``Project`` leverages a key Python: *function decorators*.
937+
the ``Project`` leverages a key Python feature: *function decorators*.
924938
A decorator is allowed to process or transform a function
925939
at the moment that it is being defined.
926940
The ``Project.task`` decorator uses this opportunity
927941
to package every task inside another function, a *wrapper*,
928-
allowing a quite clean separation of responsibilities.
942+
allowing a clean separation of responsibilities.
929943
The wrapper worries about graph and stack management —
930944
of which the task function remains blissfully ignorant —
931945
while each task function can focus on
@@ -1114,7 +1128,7 @@ Contingent needs to monitor the input files for changes.
11141128
When the user finishes a new edit and runs “Save,”
11151129
both the ``read()`` method and its consequences need to be invoked.
11161130

1117-
This will requires us to walk the graph in the opposite order
1131+
This will require us to walk the graph in the opposite order
11181132
from the one in which it was created.
11191133
It was built, you will recall, by calling
11201134
``render()`` for the API Reference and having that call ``parse()``
@@ -1149,7 +1163,7 @@ under the name ``_`` for use in the subsequent expression.
11491163

11501164
This recursive task of looking repeatedly for immediate consequences
11511165
and only stopping when we arrive at tasks with no further consequences
1152-
a basic enough graph operation that it is supported directly
1166+
is a basic enough graph operation that it is supported directly
11531167
by a method on the ``Graph`` class:
11541168

11551169
>>> project._graph.recursive_consequences_of([task])
@@ -1175,7 +1189,8 @@ Our second challenge, however,
11751189
was to avoid rebuilding too much.
11761190
We want to avoid rebuilding all three documents
11771191
every time that ``tutorial.txt`` is changed,
1178-
since most edits will probably not affect its title but only its body?
1192+
since most edits will probably not affect its title but only its body.
1193+
How can this be accomplished?
11791194

11801195
The solution is to make graph recomputation dependent on caching.
11811196
When stepping forward through the recursive consequences of a change,
@@ -1230,7 +1245,7 @@ The ``Project`` class supports a simple tracing facility
12301245
that will tell us which tasks are executed in the course
12311246
of a rebuild.
12321247
Since the above change to ``tutorial.txt``
1233-
affect both its body and its title,
1248+
affects both its body and its title,
12341249
everything downstream will need to be re-computed:
12351250

12361251
>>> project.start_tracing()

0 commit comments

Comments
 (0)