@@ -53,6 +53,33 @@ private func findHeadings(in string: String) -> [String] {
53
53
. map { String ( $0. dropFirst ( 3 ) ) }
54
54
}
55
55
56
+ private let geometryLinks = [
57
+ ( " Primitives " , " primitives.md " ) ,
58
+ ( " Options " , " options.md " ) ,
59
+ ( " Materials " , " materials.md " ) ,
60
+ ( " Transforms " , " transforms.md " ) ,
61
+ ( " Bounds " , " bounds.md " ) ,
62
+ ( " Groups " , " groups.md " ) ,
63
+ ( " Paths " , " paths.md " ) ,
64
+ ( " Text " , " text.md " ) ,
65
+ ( " Builders " , " builders.md " ) ,
66
+ ( " Constructive Solid Geometry " , " csg.md " ) ,
67
+ ]
68
+
69
+ private let syntaxLinks = [
70
+ ( " Comments " , " comments.md " ) ,
71
+ ( " Literals " , " literals.md " ) ,
72
+ ( " Symbols " , " symbols.md " ) ,
73
+ ( " Expressions " , " expressions.md " ) ,
74
+ ( " Functions " , " functions.md " ) ,
75
+ ( " Commands " , " commands.md " ) ,
76
+ ( " Control Flow " , " control-flow.md " ) ,
77
+ ( " Blocks " , " blocks.md " ) ,
78
+ ( " Scope " , " scope.md " ) ,
79
+ ( " Debugging " , " debugging.md " ) ,
80
+ ( " Import " , " import.md " ) ,
81
+ ]
82
+
56
83
class MetadataTests : XCTestCase {
57
84
// MARK: Releases
58
85
@@ -80,33 +107,6 @@ class MetadataTests: XCTestCase {
80
107
// MARK: Help
81
108
82
109
func testUpdateIndex( ) throws {
83
- let geometryLinks = [
84
- ( " Primitives " , " primitives.md " ) ,
85
- ( " Options " , " options.md " ) ,
86
- ( " Materials " , " materials.md " ) ,
87
- ( " Transforms " , " transforms.md " ) ,
88
- ( " Bounds " , " bounds.md " ) ,
89
- ( " Groups " , " groups.md " ) ,
90
- ( " Paths " , " paths.md " ) ,
91
- ( " Text " , " text.md " ) ,
92
- ( " Builders " , " builders.md " ) ,
93
- ( " Constructive Solid Geometry " , " csg.md " ) ,
94
- ]
95
-
96
- let syntaxLinks = [
97
- ( " Comments " , " comments.md " ) ,
98
- ( " Literals " , " literals.md " ) ,
99
- ( " Symbols " , " symbols.md " ) ,
100
- ( " Expressions " , " expressions.md " ) ,
101
- ( " Functions " , " functions.md " ) ,
102
- ( " Commands " , " commands.md " ) ,
103
- ( " Control Flow " , " control-flow.md " ) ,
104
- ( " Blocks " , " blocks.md " ) ,
105
- ( " Scope " , " scope.md " ) ,
106
- ( " Debugging " , " debugging.md " ) ,
107
- ( " Import " , " import.md " ) ,
108
- ]
109
-
110
110
func findSections( in string: String ) -> [ ( String , String ) ] {
111
111
findHeadings ( in: string) . compactMap { heading in
112
112
let fragment = heading. lowercased ( )
@@ -153,6 +153,36 @@ class MetadataTests: XCTestCase {
153
153
try index. write ( to: helpIndexURL, atomically: true , encoding: . utf8)
154
154
}
155
155
156
+ func testHelpFooterLinks( ) throws {
157
+ let indexLinks = [
158
+ ( " Overview " , " overview.md " ) ,
159
+ ( " Getting Started " , " getting-started.md " ) ,
160
+ ( " Camera Control " , " camera-control.md " ) ,
161
+ ] + geometryLinks + syntaxLinks + [
162
+ ( " Export " , " export.md " ) ,
163
+ ( " Examples " , " examples.md " ) ,
164
+ ( " Glossary " , " glossary.md " ) ,
165
+ ]
166
+
167
+ let urlRegex = try ! NSRegularExpression ( pattern: " Next: \\ [([^ \\ ]]+) \\ ] \\ (([^ \\ )]+) \\ ) " , options: [ ] )
168
+
169
+ for (i, ( _, path) ) in indexLinks. dropLast ( ) . enumerated ( ) {
170
+ let fileURL = helpDirectory. appendingPathComponent ( path)
171
+ let text = try XCTUnwrap ( String ( contentsOf: fileURL) )
172
+ let nsText = text as NSString
173
+ let range = NSRange ( location: 0 , length: nsText. length)
174
+ guard let match = urlRegex. firstMatch ( in: text, options: [ ] , range: range) else {
175
+ XCTFail ( " No Next: link found in \( path) " )
176
+ continue
177
+ }
178
+ let next : ( name: String , path: String ) = indexLinks [ i + 1 ]
179
+ let name = nsText. substring ( with: match. range ( at: 1 ) )
180
+ XCTAssertEqual ( name, next. name, " Next link name in \( path) should be \( next. name) " )
181
+ let path = nsText. substring ( with: match. range ( at: 2 ) )
182
+ XCTAssertEqual ( path, next. path, " Next link url in \( path) should be \( next. path) " )
183
+ }
184
+ }
185
+
156
186
func testHelpLinks( ) throws {
157
187
let enumerator =
158
188
try XCTUnwrap ( FileManager . default. enumerator ( atPath: helpDirectory. path) )
@@ -162,11 +192,12 @@ class MetadataTests: XCTestCase {
162
192
var referencedImages = Set < String > ( )
163
193
for case let file as String in enumerator where file. hasSuffix ( " .md " ) {
164
194
let fileURL = helpDirectory. appendingPathComponent ( file)
165
- let text = try XCTUnwrap ( String ( contentsOf: fileURL) ) as NSString
166
- var range = NSRange ( location: 0 , length: text. length)
167
- for match in urlRegex. matches ( in: text as String , options: [ ] , range: range) {
195
+ let text = try XCTUnwrap ( String ( contentsOf: fileURL) )
196
+ let nsText = text as NSString
197
+ var range = NSRange ( location: 0 , length: nsText. length)
198
+ for match in urlRegex. matches ( in: text, options: [ ] , range: range) {
168
199
range = NSRange ( location: match. range. upperBound, length: range. length - match. range. upperBound)
169
- var url = text . substring ( with: match. range ( at: 1 ) )
200
+ var url = nsText . substring ( with: match. range ( at: 1 ) )
170
201
var fragment = " "
171
202
let parts = url. components ( separatedBy: " # " )
172
203
guard !url. hasPrefix ( " http " ) else {
0 commit comments