@@ -109,7 +109,8 @@ does not change any of the information in the table of contents.
109
109
But it turns out that Sphinx is not quite as clever
110
110
as it might have at first appeared!
111
111
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. ::
113
114
114
115
writing output... [ 50%] index
115
116
writing output... [100%] tutorial
@@ -202,7 +203,7 @@ The problem outlined above is not specific to Sphinx.
202
203
Not only does it haunt other document systems, like LaTeX,
203
204
but it can even plague projects
204
205
that are simply trying to direct compilation steps
205
- with the venerable “ make” utility,
206
+ with the venerable `` make `` utility,
206
207
if their assets happen to cross-reference in interesting ways.
207
208
208
209
As the problem is ancient and universal,
@@ -255,7 +256,7 @@ each produce a corresponding HTML output file.
255
256
The most natural way to express these relationships
256
257
is as a collection of boxes and arrows —
257
258
or, in mathematician terminology, *nodes * and *edges *
258
- to form a graph:
259
+ to form a * graph * :
259
260
260
261
.. figure :: figure1.png
261
262
@@ -272,6 +273,12 @@ by giving them direct support in the language syntax.
272
273
You can create new instances of the big-four data structures
273
274
by simply typing them into your source code.
274
275
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
+
275
282
* The **tuple ** is a read-only sequence
276
283
whose syntax is parentheses around comma-separated items.
277
284
Tuples are used to hold heterogeneous data —
@@ -347,6 +354,8 @@ This would allow quick iteration across all of our edges,
347
354
fast insert and delete operations for a single edge,
348
355
and a quick way to check whether a particular edge was present.
349
356
357
+ .. TODO: Perhaps demonstrate these operations here?
358
+
350
359
Unfortunately, those are not the only operations we need.
351
360
352
361
A build system like Contingent
@@ -410,13 +419,15 @@ it supports the fast lookup that Contingent needs.
410
419
The Proper Use of Classes
411
420
=========================
412
421
422
+ .. TODO: rework this and following
423
+
413
424
You may have been surprised
414
425
by the absence of classes in the above discussion
415
426
of Python data structures.
416
427
After all, they are a frequent mechanism for organizing data
417
428
and get defined through a dedicated Python syntax.
418
429
419
- But it turns out that classes are often
430
+ But it turns out that classes are often orthogonal
420
431
to the question of data structure design.
421
432
Classes simply repeat data structures that we have already seen:
422
433
@@ -480,7 +491,7 @@ as a concise and fairly consistent indicator
480
491
to other programmers,
481
492
including our future selves,
482
493
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.
484
495
485
496
Why are we using a “defaultdict” instead of a standard dict?
486
497
It automatically handles the special case of a missing key.
@@ -565,7 +576,7 @@ without having to learn how to traverse our data structure:
565
576
566
577
.. include :: contingent/graphlib.py
567
578
:code: python
568
- :start-line: 65
579
+ :start-line: 64
569
580
:end-line: 69
570
581
571
582
The ``Graph.sorted() `` method, if you want to examine it later,
@@ -822,6 +833,9 @@ might involve a few basic tasks.
822
833
... title, body = parse(filename)
823
834
... return title
824
835
836
+ .. TODO: something is wrong with the next paragraph; looks like a bad
837
+ .. edit
838
+
825
839
This task nicely illustrates the
826
840
separation of responsibilities between
827
841
the parts of a document processing system:
@@ -840,9 +854,9 @@ might involve a few basic tasks.
840
854
In an OO solution,
841
855
``parse() `` would return some sort of ``Document `` object
842
856
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 .
846
860
847
861
Contingent is not opinionated
848
862
with regard to these differing design paradigms
@@ -920,12 +934,12 @@ surround the invocation of a task T:
920
934
4. Return its result.
921
935
922
936
To intercept task calls,
923
- the ``Project `` leverages a key Python: *function decorators *.
937
+ the ``Project `` leverages a key Python feature : *function decorators *.
924
938
A decorator is allowed to process or transform a function
925
939
at the moment that it is being defined.
926
940
The ``Project.task `` decorator uses this opportunity
927
941
to package every task inside another function, a *wrapper *,
928
- allowing a quite clean separation of responsibilities.
942
+ allowing a clean separation of responsibilities.
929
943
The wrapper worries about graph and stack management —
930
944
of which the task function remains blissfully ignorant —
931
945
while each task function can focus on
@@ -1114,7 +1128,7 @@ Contingent needs to monitor the input files for changes.
1114
1128
When the user finishes a new edit and runs “Save,”
1115
1129
both the ``read() `` method and its consequences need to be invoked.
1116
1130
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
1118
1132
from the one in which it was created.
1119
1133
It was built, you will recall, by calling
1120
1134
``render() `` for the API Reference and having that call ``parse() ``
@@ -1149,7 +1163,7 @@ under the name ``_`` for use in the subsequent expression.
1149
1163
1150
1164
This recursive task of looking repeatedly for immediate consequences
1151
1165
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
1153
1167
by a method on the ``Graph `` class:
1154
1168
1155
1169
>>> project._graph.recursive_consequences_of([task])
@@ -1175,7 +1189,8 @@ Our second challenge, however,
1175
1189
was to avoid rebuilding too much.
1176
1190
We want to avoid rebuilding all three documents
1177
1191
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?
1179
1194
1180
1195
The solution is to make graph recomputation dependent on caching.
1181
1196
When stepping forward through the recursive consequences of a change,
@@ -1230,7 +1245,7 @@ The ``Project`` class supports a simple tracing facility
1230
1245
that will tell us which tasks are executed in the course
1231
1246
of a rebuild.
1232
1247
Since the above change to ``tutorial.txt ``
1233
- affect both its body and its title,
1248
+ affects both its body and its title,
1234
1249
everything downstream will need to be re-computed:
1235
1250
1236
1251
>>> project.start_tracing()
0 commit comments