@@ -304,50 +304,6 @@ final class MetadataTests: XCTestCase {
304304
305305 // MARK: Help
306306
307- func testUpdateIndex() throws {
308- func findSections(in string: String) -> [(String, String)] {
309- findHeadings(in: string).compactMap { heading in
310- let fragment = heading.lowercased()
311- .replacingOccurrences(of: " ' " , with: " " )
312- .replacingOccurrences(of: " " , with: " - " )
313- XCTAssert(!fragment.contains(where: {
314- ! " abcdefghijklmnopqrstuvwxyz0123456789_-/ " .contains($0)
315- }))
316- return (heading, fragment)
317- }
318- }
319-
320- func buildLinks(_ links: [(String, String)], indent: Int) throws -> String {
321- try links.map { heading, path in
322- let file = helpSourceDirectory.appendingPathComponent(path)
323- let text = try String(contentsOf: file)
324- let indent = String(repeating: " " , count: indent * 4)
325- let links = findSections(in: text).map { subheading, fragment in
326- " \n \( indent) - [ \( subheading) ]( \( path) # \( fragment) ) "
327- }.joined()
328- return " \( indent) - [ \( heading) ]( \( path) ) " + links
329- }.joined(separator: " \n " )
330- }
331-
332- let index = try """
333- ShapeScript Help
334- ---
335-
336- \( buildLinks ( headerLinks, indent: 0 ) )
337- - Geometry
338- \( buildLinks ( geometryLinks, indent: 1 ) )
339- - Syntax
340- \( buildLinks ( syntaxLinks, indent: 1 ) )
341- \( buildLinks ( [ ( " Export " , " export.md " ) ] , indent: 0 ) )
342- \( buildLinks ( footerLinks, indent: 0 ) )
343-
344- """
345-
346- let existing = try String(contentsOf: helpIndexURL)
347- XCTAssertEqual(existing, index)
348- try index.write(to: helpIndexURL, atomically: true, encoding: .utf8)
349- }
350-
351307 func testHelpFooterLinks() throws {
352308 let indexLinks = headerLinks + geometryLinks + syntaxLinks + [
353309 ( " Export " , " export.md " ),
@@ -463,7 +419,58 @@ final class MetadataTests: XCTestCase {
463419 }
464420 }
465421
466- func testExportMacHelp() throws {
422+ func testExportHelp() throws {
423+ try updateHelpIndex()
424+ try exportIOSHelp()
425+ try exportMacHelp()
426+ try exportVersionedHelp()
427+ }
428+
429+ func updateHelpIndex() throws {
430+ func findSections(in string: String) -> [(String, String)] {
431+ findHeadings(in: string).compactMap { heading in
432+ let fragment = heading.lowercased()
433+ .replacingOccurrences(of: " ' " , with: " " )
434+ .replacingOccurrences(of: " " , with: " - " )
435+ XCTAssert(!fragment.contains(where: {
436+ ! " abcdefghijklmnopqrstuvwxyz0123456789_-/ " .contains($0)
437+ }))
438+ return (heading, fragment)
439+ }
440+ }
441+
442+ func buildLinks(_ links: [(String, String)], indent: Int) throws -> String {
443+ try links.map { heading, path in
444+ let file = helpSourceDirectory.appendingPathComponent(path)
445+ let text = try String(contentsOf: file)
446+ let indent = String(repeating: " " , count: indent * 4)
447+ let links = findSections(in: text).map { subheading, fragment in
448+ " \n \( indent) - [ \( subheading) ]( \( path) # \( fragment) ) "
449+ }.joined()
450+ return " \( indent) - [ \( heading) ]( \( path) ) " + links
451+ }.joined(separator: " \n " )
452+ }
453+
454+ let index = try """
455+ ShapeScript Help
456+ ---
457+
458+ \( buildLinks ( headerLinks, indent: 0 ) )
459+ - Geometry
460+ \( buildLinks ( geometryLinks, indent: 1 ) )
461+ - Syntax
462+ \( buildLinks ( syntaxLinks, indent: 1 ) )
463+ \( buildLinks ( [ ( " Export " , " export.md " ) ] , indent: 0 ) )
464+ \( buildLinks ( footerLinks, indent: 0 ) )
465+
466+ """
467+
468+ let existing = try String(contentsOf: helpIndexURL)
469+ XCTAssertEqual(existing, index)
470+ try index.write(to: helpIndexURL, atomically: true, encoding: .utf8)
471+ }
472+
473+ func exportMacHelp() throws {
467474 let fm = FileManager.default
468475
469476 let outputDirectory = helpDirectory.appendingPathComponent( " mac " )
@@ -482,7 +489,7 @@ final class MetadataTests: XCTestCase {
482489 }
483490 }
484491
485- func testExportIOSHelp () throws {
492+ func exportIOSHelp () throws {
486493 let fm = FileManager.default
487494
488495 let outputDirectory = helpDirectory.appendingPathComponent( " ios " )
@@ -555,7 +562,7 @@ final class MetadataTests: XCTestCase {
555562 }
556563 }
557564
558- func testExportVersionedHelp () throws {
565+ func exportVersionedHelp () throws {
559566 let fm = FileManager.default
560567 let outputDirectory = helpDirectory.appendingPathComponent(projectVersion)
561568 guard fm.fileExists(atPath: outputDirectory.path) else {
0 commit comments