@@ -15,6 +15,65 @@ import Markdown
15
15
16
16
class ListItemExtractorTests : XCTestCase {
17
17
18
+ func testSupportsSpacesInTaggedElementNames( ) throws {
19
+ let testSource = URL ( fileURLWithPath: " /path/to/test-source- \( ProcessInfo . processInfo. globallyUniqueString) " )
20
+ func extractedTags( _ markup: String ) -> TaggedListItemExtractor {
21
+ let document = Document ( parsing: markup, source: testSource, options: . parseSymbolLinks)
22
+
23
+ var extractor = TaggedListItemExtractor ( )
24
+ _ = extractor. visit ( document)
25
+ return extractor
26
+ }
27
+
28
+ for whitespace in [ " " , " " , " \t " ] {
29
+ let parameters = extractedTags ( """
30
+ - Parameter \( whitespace) some parameter with spaces: Some description of this parameter.
31
+ """ ) . parameters
32
+ XCTAssertEqual ( parameters. count, 1 )
33
+ let parameter = try XCTUnwrap ( parameters. first)
34
+ XCTAssertEqual ( parameter. name, " some parameter with spaces " )
35
+ XCTAssertEqual ( parameter. contents. map { $0. format ( ) } , [ " Some description of this parameter. " ] )
36
+ XCTAssertEqual ( parameter. nameRange? . source? . path, testSource. path)
37
+ XCTAssertEqual ( parameter. range? . source? . path, testSource. path)
38
+ }
39
+
40
+ let parameters = extractedTags ( """
41
+ - Parameters:
42
+ - some parameter with spaces: Some description of this parameter.
43
+ """ ) . parameters
44
+ XCTAssertEqual ( parameters. count, 1 )
45
+ let parameter = try XCTUnwrap ( parameters. first)
46
+ XCTAssertEqual ( parameter. name, " some parameter with spaces " )
47
+ XCTAssertEqual ( parameter. contents. map { $0. format ( ) } , [ " Some description of this parameter. " ] )
48
+ XCTAssertEqual ( parameter. nameRange? . source? . path, testSource. path)
49
+ XCTAssertEqual ( parameter. range? . source? . path, testSource. path)
50
+
51
+ let dictionaryKeys = extractedTags ( """
52
+ - DictionaryKeys:
53
+ - some key with spaces: Some description of this key.
54
+ """ ) . dictionaryKeys
55
+ XCTAssertEqual ( dictionaryKeys. count, 1 )
56
+ let dictionaryKey = try XCTUnwrap ( dictionaryKeys. first)
57
+ XCTAssertEqual ( dictionaryKey. name, " some key with spaces " )
58
+ XCTAssertEqual ( dictionaryKey. contents. map { $0. format ( ) } , [ " Some description of this key. " ] )
59
+
60
+ let possibleValues = extractedTags ( """
61
+ - PossibleValue some value with spaces: Some description of this value.
62
+ """ ) . possiblePropertyListValues
63
+ XCTAssertEqual ( possibleValues. count, 1 )
64
+ let possibleValue = try XCTUnwrap ( possibleValues. first)
65
+ XCTAssertEqual ( possibleValue. value, " some value with spaces " )
66
+ XCTAssertEqual ( possibleValue. contents. map { $0. format ( ) } , [ " Some description of this value. " ] )
67
+ XCTAssertEqual ( possibleValue. nameRange? . source? . path, testSource. path)
68
+ XCTAssertEqual ( possibleValue. range? . source? . path, testSource. path)
69
+
70
+ XCTAssert ( extractedTags ( " - Parameter: Missing parameter name. " ) . parameters. isEmpty)
71
+ XCTAssert ( extractedTags ( " - Parameter : Missing parameter name. " ) . parameters. isEmpty)
72
+
73
+ XCTAssert ( extractedTags ( " - DictionaryKey: Missing key name. " ) . dictionaryKeys. isEmpty)
74
+ XCTAssert ( extractedTags ( " - PossibleValue: Missing value name. " ) . possiblePropertyListValues. isEmpty)
75
+ }
76
+
18
77
func testExtractingTags( ) throws {
19
78
try assertExtractsRichContentFor (
20
79
tagName: " Returns " ,
0 commit comments