Skip to content

Commit b56a7ff

Browse files
Improve LayoutItem documentation (#375)
1 parent faa3706 commit b56a7ff

22 files changed

Lines changed: 2 additions & 66 deletions

Sources/Layout/LayoutItem.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,10 @@ public typealias SuperviewConstraints = (LayoutItem) -> [NSLayoutConstraint]
2020
* Each subview and its constraints are stored as a `LayoutItem` instance within a ``Layout``. A `LayoutItem` extension
2121
* is provided that defines the declarative methods used to create constraints for the subviews within a layout.
2222
*
23-
* A layout item must be added to a `Layout` in order to activate its constraints, as the following code demonstrates:
23+
* A layout item must be added to a `Layout` in order to activate its constraints, as shown in the following code:
2424
*
2525
* ```swift
26-
* // Creating a layout with a single item
27-
* let item: LayoutItem = subview.toEdges()
28-
* view.layout(item).activate()
29-
*
30-
* // Creating a layout with multiple items
31-
* let item1: LayoutItem = subview1.toEdges()
32-
* let item2: LayoutItem = subview2.square().center()
33-
* view.layout(item1).addItem(item2).activate()
26+
* view.layout(subview.toEdges()).activate()
3427
* ```
3528
*
3629
* The following code demonstrates the preferred way of constructing and activating a layout with multiple items

Tests/LayoutTests/LayoutExampleTests.swift

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -175,38 +175,6 @@ final class LayoutExampleTests: XCTestCase {
175175

176176
// MARK: - LayoutItem
177177

178-
@MainActor
179-
func testSingleLayoutItemDocumentationExample() {
180-
181-
// GIVEN
182-
183-
let subview: UIView = .blue()
184-
185-
// THEN
186-
187-
assertLayout { view in
188-
let item: LayoutItem = subview.toEdges()
189-
view.layout(item).activate()
190-
}
191-
}
192-
193-
@MainActor
194-
func testMultipleLayoutItemsDocumentationExample() {
195-
196-
// GIVEN
197-
198-
let subview1: UIView = .orange()
199-
let subview2: UIImageView = .init(image: .checkmark)
200-
201-
// THEN
202-
203-
assertLayout { view in
204-
let item1: LayoutItem = subview1.toEdges()
205-
let item2: LayoutItem = subview2.square().center()
206-
view.layout(item1).addItem(item2).activate()
207-
}
208-
}
209-
210178
@MainActor
211179
func testHorizontallyCenteringLayoutItemDocumentationExample() {
212180

Tests/LayoutTests/__Snapshots__/LayoutExampleTests/testMultipleLayoutItemsDocumentationExample.iPhone-13-mini-portrait.txt

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

Tests/LayoutTests/__Snapshots__/LayoutExampleTests/testMultipleLayoutItemsDocumentationExample.iPhone-13-portrait.txt

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

Tests/LayoutTests/__Snapshots__/LayoutExampleTests/testMultipleLayoutItemsDocumentationExample.iPhone-8-portrait.txt

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

Tests/LayoutTests/__Snapshots__/LayoutExampleTests/testMultipleLayoutItemsDocumentationExample.iPhone-SE-portrait.txt

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

0 commit comments

Comments
 (0)