Skip to content

Commit 88d995d

Browse files
authored
Fix tutorial diffs (#2642)
While tutorials appear to compile just fine when files are referenced as strings and omitting the file suffix, it mysteriously breaks the diffing between each step. This PR fixes things.
1 parent 897cf6a commit 88d995d

File tree

4 files changed

+102
-102
lines changed

4 files changed

+102
-102
lines changed

Sources/ComposableArchitecture/Documentation.docc/Tutorials/MeetTheComposableArchitecture/02-Navigation/01-YourFirstPresentation/02-01-YourFirstPresentation.tutorial

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@
2525
> Note: We conform `State` and `Action` to the `Equatable` protocol in order to test this
2626
> feature later.
2727

28-
@Code(name: "ContactsFeature.swift", file: "02-01-01-code-0000")
28+
@Code(name: "ContactsFeature.swift", file: 02-01-01-code-0000.swift)
2929
}
3030

3131
@Step {
3232
Add a view that holds onto a ``ComposableArchitecture/Store`` of the `ContactsFeature`
3333
and observes the store in order to show a list of contacts and send actions.
3434

35-
@Code(name: "ContactsFeature.swift", file: "02-01-01-code-0001", reset: true)
35+
@Code(name: "ContactsFeature.swift", file: 02-01-01-code-0001.swift, reset: true)
3636
}
3737

3838
@Step {
3939
Add a preview with a few stubbed contacts already in the state so that we can see what
4040
the feature looks like.
4141

42-
@Code(name: "ContactsFeature.swift", file: "02-01-01-code-0002", reset: true) {
42+
@Code(name: "ContactsFeature.swift", file: 02-01-01-code-0002.swift, reset: true) {
4343
@Image(source: "ch02-sub01-sec01-image-0001")
4444
}
4545
}
@@ -50,20 +50,20 @@
5050
button for dismissing, and a "Save" button that when tapped should dismiss the feature
5151
_and_ add the contact to the list of contacts in the parent.
5252

53-
@Code(name: "AddContactFeature.swift", file: "02-01-01-code-0003", reset: true)
53+
@Code(name: "AddContactFeature.swift", file: 02-01-01-code-0003.swift, reset: true)
5454
}
5555

5656
@Step {
5757
Add a view that holds onto a ``ComposableArchitecture/Store`` of the `AddContactFeature`
5858
and observes the state in order to show a text field for the contact name and send actions.
5959

60-
@Code(name: "AddContactFeature.swift", file: "02-01-01-code-0004", reset: true)
60+
@Code(name: "AddContactFeature.swift", file: 02-01-01-code-0004.swift, reset: true)
6161
}
6262

6363
@Step {
6464
Add a preview so that we can see what the feature looks like.
6565

66-
@Code(name: "AddContactFeature.swift", file: "02-01-01-code-0005", reset: true) {
66+
@Code(name: "AddContactFeature.swift", file: 02-01-01-code-0005.swift, reset: true) {
6767
@Image(source: "ch02-sub01-sec01-image-0002")
6868
}
6969
}
@@ -87,7 +87,7 @@
8787
few steps. Go back to the ContactsFeature.swift file where we built the `ContactsFeature`
8888
reducer for handling the logic and behavior of the list of contacts.
8989

90-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0000")
90+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0000.swift)
9191
}
9292

9393
@Step {
@@ -98,7 +98,7 @@
9898
A `nil` value represents that the "Add Contacts" feature is not presented, and a non-`nil`
9999
value represents that it is presented.
100100

101-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0001")
101+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0001.swift)
102102
}
103103

104104
@Step {
@@ -107,15 +107,15 @@
107107

108108
This allows the parent to observe every action sent from the child feature.
109109

110-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0002")
110+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0002.swift)
111111
}
112112

113113
@Step {
114114
Since a new case has been added to the action enum we must now handle it in the main
115115
reducer. For now we will do nothing for this case and return `.none`, but soon we will do
116116
more here.
117117

118-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0003")
118+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0003.swift)
119119
}
120120

121121
@Step {
@@ -128,7 +128,7 @@
128128
automatically handles effect cancellation when the child feature is dismissed, and a lot
129129
more. See the documentation for more information.
130130

131-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0004")
131+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0004.swift)
132132
}
133133

134134
That is all it takes to integrate the two features' domains together. Before moving onto the
@@ -140,7 +140,7 @@
140140
When the "+" button is tapped in the contacts list feature we can now populate the
141141
`addContact` state to represent that the feature should be presented.
142142

143-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0005")
143+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0005.swift)
144144
}
145145

146146
@Step {
@@ -152,15 +152,15 @@
152152
> ``ComposableArchitecture/PresentationAction/presented(_:)`` case in order to listen for
153153
> actions inside the "Add Contact" feature.
154154

155-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0006")
155+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0006.swift)
156156
}
157157

158158
@Step {
159159
When the "Save" button is tapped _inside_ the "Add Contacts" feature we want to not only
160160
dismiss the feature, but we also want to add the new contact to the collection of contacts
161161
held in `ContactsFeature.State`.
162162

163-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0007")
163+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0007.swift)
164164
}
165165

166166
That is all it takes to implement communication between parent and child features. The parent
@@ -182,7 +182,7 @@
182182
and we have a navigation title and toolbar. We need to figure out how to present a sheet
183183
in this view whenever the `addContact` state flips to non-`nil`.
184184

185-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0008", reset: true)
185+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0008.swift, reset: true)
186186
}
187187

188188
The library comes with a variety of tools that mimic SwiftUI's native navigation tools (such
@@ -195,7 +195,7 @@
195195
store will be derived focused only on the `AddContactFeature` domain, which is what you can
196196
pass to the `AddContactView`.
197197

198-
@Code(name: "ContactsFeature.swift", file: "02-01-02-code-0009")
198+
@Code(name: "ContactsFeature.swift", file: 02-01-02-code-0009.swift)
199199
}
200200

201201
@Step {
@@ -225,29 +225,29 @@
225225
`AddContactFeature`. This enum will describe all the actions that the parent can listen for
226226
and interpret. It allows the child feature to directly tell the parent what it wants done.
227227

228-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0000, previousFile: 02-01-04-code-0000-previous)
228+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0000.swift, previousFile: 02-01-04-code-0000-previous.swift)
229229
}
230230

231231
@Step {
232232
Handle the new case in the reducer, but we should never actually perform any logic in this
233233
case. Only the parent should listen for `delegate` actions and respond accordingly.
234234

235-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0001)
235+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0001.swift)
236236
}
237237

238238
@Step {
239239
Anytime we want the child feature to communicate to the parent we will return an effect that
240240
immediately and synchronously sends a delegate action. For example, when the "Save" button
241241
is tapped, we will send the `saveContact` action.
242242

243-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0002)
243+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0002.swift)
244244
}
245245

246246
@Step {
247247
Go back to ContactsFeature.swift and update the reducer to listen for delegate actions to
248248
figure out when it is time to dismiss or save the contact.
249249

250-
@Code(name: "ContactsFeature.swift", file: 02-01-04-code-0003, previousFile: 02-01-04-code-0003-previous)
250+
@Code(name: "ContactsFeature.swift", file: 02-01-04-code-0003.swift, previousFile: 02-01-04-code-0003-previous.swift)
251251
}
252252

253253
The application should work exactly as it did before the "delegate action" refactor, but now
@@ -262,7 +262,7 @@
262262
``ComposableArchitecture/DismissEffect``. This is a value that allows child features to
263263
dismiss themselves without any direct contact with the parent feature.
264264

265-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0004, previousFile: 02-01-04-code-0004-previous)
265+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0004.swift, previousFile: 02-01-04-code-0004-previous.swift)
266266
}
267267

268268
@Step {
@@ -273,23 +273,23 @@
273273
> Note: The `dismiss` dependency is asynchronous which means it is only appropriate to
274274
> invoke from an effect.
275275

276-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0005)
276+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0005.swift)
277277
}
278278

279279
@Step {
280280
Remove the `cancel` action from the `Delegate` enum because it is no longer needed. We do
281281
not need to explicitly communicate to the parent that it should dismiss the child. That is
282282
all handled by the ``ComposableArchitecture/DismissEffect``.
283283

284-
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0006)
284+
@Code(name: "AddContactFeature.swift", file: 02-01-04-code-0006.swift)
285285
}
286286

287287
@Step {
288288
Go back to ContactsFeature.swift. We can also remove the `cancel` logic from the
289289
`ContactsFeature` reducer and it is no longer necessary to explicitly `nil` out the
290290
`addContact` state. That is already taken care of.
291291

292-
@Code(name: "ContactsFeature.swift", file: 02-01-04-code-0007, previousFile: 02-01-04-code-0007-previous)
292+
@Code(name: "ContactsFeature.swift", file: 02-01-04-code-0007.swift, previousFile: 02-01-04-code-0007-previous.swift)
293293
}
294294
}
295295
}

0 commit comments

Comments
 (0)