File: ListItemExtractor.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (712 lines) | stat: -rw-r--r-- 24,915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/*
 This source file is part of the Swift.org open source project

 Copyright (c) 2021 Apple Inc. and the Swift project authors
 Licensed under Apache License v2.0 with Runtime Library Exception

 See https://swift.org/LICENSE.txt for license information
 See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import Markdown
import Foundation

/// The list of tags that can appear at the start of a list item to indicate
/// some meaning in the markup, taken from Swift documentation comments. These
/// are maintained for backward compatibility but their use should be
/// discouraged.
let simpleListItemTags = [
    "attention",
    "author",
    "authors",
    "bug",
    "complexity",
    "copyright",
    "date",
    "experiment",
    "important",
    "invariant",
    "localizationkey",
    "mutatingvariant",
    "nonmutatingvariant",
    "note",
    "postcondition",
    "precondition",
    "remark",
    "remarks",
    "returns",
    "throws",
    "requires",
    "seealso",
    "since",
    "tag",
    "todo",
    "version",
    "warning",
    "keyword",
    "recommended",
    "recommendedover",
]

extension Sequence<InlineMarkup> {
    private func splitNameAndContent() -> (name: String, nameRange: SourceRange?, content: [Markup], range: SourceRange?)? {
        var iterator = makeIterator()
        guard let initialTextNode = iterator.next() as? Text else {
            return nil
        }

        let initialText = initialTextNode.string
        guard let colonIndex = initialText.firstIndex(of: ":") else {
            return nil
        }

        let nameStartIndex = initialText[...colonIndex].lastIndex(of: " ").map { initialText.index(after: $0) } ?? initialText.startIndex
        let parameterName = initialText[nameStartIndex..<colonIndex]
        guard !parameterName.isEmpty else {
            return nil
        }
        let remainingInitialText = initialText.suffix(from: initialText.index(after: colonIndex)).drop { $0 == " " }

        var newInlineContent: [InlineMarkup] = [Text(String(remainingInitialText))]
        while let more = iterator.next() {
            newInlineContent.append(more)
        }
        let newContent: [Markup] = [Paragraph(newInlineContent)]
        
        let nameRange: SourceRange? = initialTextNode.range.map { fullRange in
            var start = fullRange.lowerBound
            start.column += initialText.utf8.distance(from: initialText.startIndex, to: nameStartIndex)
            var end = start
            end.column += parameterName.utf8.count
            return start ..< end
        }
        
        let itemRange: SourceRange? = sequence(first: initialTextNode as Markup, next: { $0.parent })
            .mapFirst(where: { $0 as? ListItem })?.range
        
        return (
            String(parameterName),
            nameRange,
            newContent,
            itemRange
        )
    }
    
    func extractParameter(standalone: Bool) -> Parameter? {
        if let (name, nameRange, content, itemRange) = splitNameAndContent() {
            return Parameter(name: name, nameRange: nameRange, contents: content, range: itemRange, isStandalone: standalone)
        }
        return nil
    }
    
    func extractDictionaryKey() -> DictionaryKey? {
        if let (name, _, content, _) = splitNameAndContent() {
            return DictionaryKey(name: name, contents: content)
        }
        return nil
    }
    
    func extractHTTPParameter() -> HTTPParameter? {
        if let (name, _, content, _) = splitNameAndContent() {
            return HTTPParameter(name: name, source: nil, contents: content)
        }
        return nil
    }
    
    func extractHTTPBodyParameter() -> HTTPParameter? {
        if let (name, _, content, _) = splitNameAndContent() {
            return HTTPParameter(name: name, source: "body", contents: content)
        }
        return nil
    }
    
    func extractHTTPResponse() -> HTTPResponse? {
        if let (name, _, content, _) = splitNameAndContent() {
            let statusCode = UInt(name) ?? 0
            return HTTPResponse(statusCode: statusCode, reason: nil, mediaType: nil, contents: content)
        }
        return nil
    }
}

extension ListItem {

    /**
     Try to extract a tag start from this list item.

     - returns: If the tag was matched, return the remaining content after the match. Otherwise, return `nil`.
     */
    func extractTag(_ tag: String, dropTag: Bool = true) -> [InlineMarkup]? {
        guard let firstParagraph = child(at: 0) as? Paragraph,
              let text = firstParagraph.child(at: 0) as? Text else {
            return nil
        }

        let trimmedText = text.string.drop { char -> Bool in
            guard let scalar = char.unicodeScalars.first else { return false }
            return CharacterSet.whitespaces.contains(scalar)
        }.lowercased()

        if trimmedText.starts(with: tag.lowercased()) {
            var newText = text.string
            if dropTag {
                newText = String(text.string.dropFirst(text.string.count - trimmedText.count + tag.count).drop(while: { $0 == " " }))
            }
            return [Text(newText)] + Array(firstParagraph.inlineChildren.dropFirst(1))
        }

        return nil
    }

    /**
     Extract a "simple tag" from the list of known list item tags.

     Expected form:

     ```markdown
     - todo: ...
     - seeAlso: ...
     ```
     ...etc.
     */
    func extractSimpleTag() -> SimpleTag? {
        for tag in simpleListItemTags {
            if let contents = extractTag(tag + ":") {
                return SimpleTag(tag: tag, contents: contents)
            }
        }
        return nil
    }

    /**
     Extract a standalone dictionary key description from this list item.

     Expected form:

     ```markdown
     - dictionaryKey x: A number.
     ```
     */
    func extractStandaloneDictionaryKey() -> DictionaryKey? {
        guard let remainder = extractTag(TaggedListItemExtractor.dictionaryKeyTag) else {
            return nil
        }
        return remainder.extractDictionaryKey()
    }

    /**
     Extracts an outline of dictionary keys from a sublist underneath this list item.

     Expected form:

     ```markdown
     - DictionaryKeys:
       - x: a number
       - y: a number
     ```

     > Warning: Content underneath `- DictionaryKeys` that doesn't match this form will be dropped.
     */
    func extractDictionaryKeyOutline() -> [DictionaryKey]? {
        guard extractTag(TaggedListItemExtractor.dictionaryKeysTag + ":") != nil else {
            return nil
        }

        var dictionaryKeys = [DictionaryKey]()

        for child in children {
            // The list `- DictionaryKeys:` should have one child, a list of dictionary keys.
            guard let dictionaryKeysList = child as? UnorderedList else {
                // If it's not, that content is dropped.
                continue
            }

            // Those sublist items are assumed to be a valid `- ___: ...` dictionary key form or else they are dropped.
            for child in dictionaryKeysList.children {
                guard let listItem = child as? ListItem,
                      let firstParagraph = listItem.child(at: 0) as? Paragraph,
                      let dictionaryKey = Array(firstParagraph.inlineChildren).extractDictionaryKey() else {
                    continue
                }
                // Don't forget the rest of the content under this dictionary key list item.
                let contents = dictionaryKey.contents + Array(listItem.children.dropFirst(1))

                dictionaryKeys.append(DictionaryKey(name: dictionaryKey.name, contents: contents))
            }
        }
        return dictionaryKeys
    }

    /**
     Extract a standalone HTTP parameter description from this list item.

     Expected form:

     ```markdown
     - httpParameter x: A number.
     ```
     */
    func extractStandaloneHTTPParameter() -> HTTPParameter? {
        guard let remainder = extractTag(TaggedListItemExtractor.httpParameterTag) else {
            return nil
        }
        return remainder.extractHTTPParameter()
    }

    /**
     Extracts an outline of HTTP parameters from a sublist underneath this list item.

     Expected form:

     ```markdown
     - HTTPParameters:
       - x: a number
       - y: another
     ```

     > Warning: Content underneath `- HTTPParameters` that doesn't match this form will be dropped.
     */
    func extractHTTPParameterOutline() -> [HTTPParameter]? {
        guard extractTag(TaggedListItemExtractor.httpParametersTag + ":") != nil else {
            return nil
        }

        var parameters = [HTTPParameter]()

        for child in children {
            // The list `- HTTPParameters:` should have one child, a list of parameters.
            guard let parametersList = child as? UnorderedList else {
                // If it's not, that content is dropped.
                continue
            }

            // Those sublist items are assumed to be a valid `- ___: ...` parameter form or else they are dropped.
            for child in parametersList.children {
                guard let listItem = child as? ListItem,
                      let firstParagraph = listItem.child(at: 0) as? Paragraph,
                      let parameter = Array(firstParagraph.inlineChildren).extractHTTPParameter() else {
                    continue
                }
                // Don't forget the rest of the content under this list item.
                let contents = parameter.contents + Array(listItem.children.dropFirst(1))

                parameters.append(HTTPParameter(name: parameter.name, source:parameter.source, contents: contents))
            }
        }
        return parameters
    }

    /**
     Extract a standalone HTTP body parameter description from this list item.

     Expected form:

     ```markdown
     - HTTPBodyParameter x: A number.
     ```
     */
    func extractStandaloneHTTPBodyParameter() -> HTTPParameter? {
        guard let remainder = extractTag(TaggedListItemExtractor.httpBodyParameterTag) else {
            return nil
        }
        return remainder.extractHTTPBodyParameter()
    }
    
    /**
     Extracts an outline of HTTP parameters from a sublist underneath this list item.

     Expected form:

     ```markdown
     - HTTPBodyParameters:
       - x: a number
       - y: another
     ```

     > Warning: Content underneath `- HTTPBodyParameters` that doesn't match this form will be dropped.
     */
    func extractHTTPBodyParameterOutline() -> [HTTPParameter]? {
        guard extractTag(TaggedListItemExtractor.httpBodyParametersTag + ":") != nil else {
            return nil
        }

        var parameters = [HTTPParameter]()

        for child in children {
            // The list `- HTTPBodyParameters:` should have one child, a list of parameters.
            guard let parametersList = child as? UnorderedList else {
                // If it's not, that content is dropped.
                continue
            }

            // Those sublist items are assumed to be a valid `- ___: ...` parameter form or else they are dropped.
            for child in parametersList.children {
                guard let listItem = child as? ListItem,
                      let firstParagraph = listItem.child(at: 0) as? Paragraph,
                      let parameter = Array(firstParagraph.inlineChildren).extractHTTPParameter() else {
                    continue
                }
                // Don't forget the rest of the content under this list item.
                let contents = parameter.contents + Array(listItem.children.dropFirst(1))

                parameters.append(HTTPParameter(name: parameter.name, source:"body", contents: contents))
            }
        }
        return parameters
    }
    
    /**
     Extract a standalone HTTP response description from this list item.

     Expected form:

     ```markdown
     - httpResponse 200: A number.
     ```
     */
    func extractStandaloneHTTPResponse() -> HTTPResponse? {
        guard let remainder = extractTag(TaggedListItemExtractor.httpResponseTag) else {
            return nil
        }
        return remainder.extractHTTPResponse()
    }

    /**
     Extracts an outline of dictionary keys from a sublist underneath this list item.

     Expected form:

     ```markdown
     - HTTPResponses:
       - 200: a status code
       - 204: another status code
     ```

     > Warning: Content underneath `- HTTPResponses` that doesn't match this form will be dropped.
     */
    func extractHTTPResponseOutline() -> [HTTPResponse]? {
        guard extractTag(TaggedListItemExtractor.httpResponsesTag + ":") != nil else {
            return nil
        }

        var responses = [HTTPResponse]()

        for child in children {
            // The list `- HTTPResponses:` should have one child, a list of responses.
            guard let responseList = child as? UnorderedList else {
                // If it's not, that content is dropped.
                continue
            }

            // Those sublist items are assumed to be a valid `- ___: ...` response form or else they are dropped.
            for child in responseList.children {
                guard let listItem = child as? ListItem,
                      let firstParagraph = listItem.child(at: 0) as? Paragraph,
                      let response = Array(firstParagraph.inlineChildren).extractHTTPResponse() else {
                    continue
                }
                // Don't forget the rest of the content under this dictionary key list item.
                let contents = response.contents + Array(listItem.children.dropFirst(1))

                responses.append(HTTPResponse(statusCode: response.statusCode, reason: response.reason, mediaType: response.mediaType, contents: contents))
            }
        }
        return responses
    }

    /**
     Extract a standalone parameter description from this list item.

     Expected form:

     ```markdown
     - parameter x: A number.
     ```
     */
    func extractStandaloneParameter() -> Parameter? {
        guard extractTag(TaggedListItemExtractor.parameterTag) != nil else {
            return nil
        }
        // Don't use the return value from `extractTag` here. It drops the range and source information from the markup which means that we can't present diagnostics about the parameter.
        return (child(at: 0) as? Paragraph)?.inlineChildren.extractParameter(standalone: true)
    }

    /**
     Extracts an outline of parameters from a sublist underneath this list item.

     Expected form:

     ```markdown
     - Parameters:
       - x: a number
       - y: a number
     ```

     > Warning: Content underneath `- Parameters` that doesn't match this form will be dropped.
     */
    func extractParameterOutline() -> [Parameter]? {
        guard extractTag(TaggedListItemExtractor.parametersTag + ":") != nil else {
            return nil
        }

        var parameters = [Parameter]()

        for child in children {
            // The list `- Parameters:` should have one child, a list of parameters.
            guard let parameterList = child as? UnorderedList else {
                // If it's not, that content is dropped.
                continue
            }

            // Those sublist items are assumed to be a valid `- ___: ...` parameter form or else they are dropped.
            for child in parameterList.children {
                guard let listItem = child as? ListItem,
                      let firstParagraph = listItem.child(at: 0) as? Paragraph,
                      var parameter = Array(firstParagraph.inlineChildren).extractParameter(standalone: false) else {
                    continue
                }
                // Don't forget the rest of the content under this parameter list item.
                parameter.contents += Array(listItem.children.dropFirst(1))

                parameters.append(parameter)
            }
        }
        return parameters
    }

    /**
     Extract an HTTP body description from a list item.

     Expected form:

     ```markdown
     - httpBody: ...
     ```
     */
    func extractHTTPBody() -> HTTPBody? {
        guard let remainder = extractTag(TaggedListItemExtractor.httpBodyTag + ":") else {
            return nil
        }
        return HTTPBody(mediaType: nil, contents: [Paragraph(remainder)])
    }

    /**
     Extract a return description from a list item.

     Expected form:

     ```markdown
     - returns: ...
     ```
     */
    func extractReturnDescription() -> Return? {
        guard let remainder = extractTag(TaggedListItemExtractor.returnsTag + ":") else {
            return nil
        }
        return Return(contents: [Paragraph(remainder)], range: range)
    }

    /**
     Extract a throw description from a list item.

     Expected form:

     ```markdown
     - throws: ...
     ```
     */
    func extractThrowsDescription() -> Throw? {
        guard let remainder = extractTag(TaggedListItemExtractor.throwsTag + ":") else {
            return nil
        }
        return Throw(contents: remainder)
    }
}

struct TaggedListItemExtractor: MarkupRewriter {
    static let returnsTag = "returns"
    static let throwsTag = "throws"
    static let parameterTag = "parameter"
    static let parametersTag = "parameters"
    static let dictionaryKeyTag = "dictionarykey"
    static let dictionaryKeysTag = "dictionarykeys"
    
    static let httpBodyTag = "httpbody"
    static let httpResponseTag = "httpresponse"
    static let httpResponsesTag = "httpresponses"
    static let httpParameterTag = "httpparameter"
    static let httpParametersTag = "httpparameters"
    static let httpBodyParameterTag = "httpbodyparameter"
    static let httpBodyParametersTag = "httpbodyparameters"

    var parameters = [Parameter]()
    var dictionaryKeys = [DictionaryKey]()
    var httpResponses = [HTTPResponse]()
    var httpParameters = [HTTPParameter]()
    var httpBody: HTTPBody? = nil
    var returns = [Return]()
    var `throws` = [Throw]()
    var otherTags = [SimpleTag]()

    init() {}
    
    mutating func visitDocument(_ document: Document) -> Markup? {
        // Rewrite top level "- Note:" list elements to Note Aside elements. This happens during a Document level visit because the document is
        // the parent of the top level UnorderedList and is where the Aside elements should be added to become a sibling to the UnorderedList.
        var result = [Markup]()

        for child in document.children {
            // Only rewrite top-level unordered lists. Anything else is unmodified.
            guard let unorderedList = child as? UnorderedList else {
                result.append(child)
                continue
            }

            // Separate all the "- Note:" elements from the other list items.
            let (noteItems, otherListItems) = unorderedList.listItems.categorize(where: { item in
                return Aside.Kind.allCases.mapFirst {
                    item.extractTag($0.rawValue + ": ", dropTag: false)
                }
            })

            // Add the unordered list with the filtered children first.
            result.append(UnorderedList(otherListItems))

            // Then, add the Note asides as siblings after the list they belonged to
            for noteDescription in noteItems {
                result.append(BlockQuote(Paragraph(noteDescription)))
            }
        }

        // After extracting the "- Note:" list elements, proceed to visit all markup to do local rewrites.
        return Document(result.compactMap { visit($0) as? BlockMarkup })
    }
    
    mutating func visitUnorderedList(_ unorderedList: UnorderedList) -> Markup? {
        var newItems = [ListItem]()
        for item in unorderedList.listItems {
            guard let newItem = visit(item) as? ListItem else {
                continue
            }
            newItems.append(newItem)
        }
        guard !newItems.isEmpty else {
            return nil
        }
        return UnorderedList(newItems)
    }
    
    mutating func visitListItem(_ listItem: ListItem) -> Markup? {
        /*
         This rewriter only extracts list items that are at the "top level", i.e.:

         Document
         List
         ListItem <- These and no deeper

         Any further nesting is left alone and treated as a normal list item.
         */
        do {
            guard let parent = listItem.parent,
                  parent.parent == nil || parent.parent is Document else {
                return listItem
            }
        }

        //Try to extract one of the several specially interpreted list items.

        if let returnDescription = listItem.extractReturnDescription() {
            // - returns: ...
            returns.append(returnDescription)
            return nil
        // "Throws" asides are currently parsed as blockquote-style asides
        // } else if let throwsDescription = listItem.extractThrowsDescription() {
        //     `throws`.append(throwsDescription)
        //     return nil
        } else if let parameterDescriptions = listItem.extractParameterOutline() {
            // - Parameters:
            //   - x: ...
            //   - y: ...
            parameters.append(contentsOf: parameterDescriptions)
            return nil
        } else if let parameterDescription = listItem.extractStandaloneParameter() {
            // - parameter x: ...
            parameters.append(parameterDescription)
            return nil
        } else if let dictionaryKeyDescription = listItem.extractDictionaryKeyOutline() {
            // - DictionaryKeys:
            //   - x: ...
            //   - y: ...
            dictionaryKeys.append(contentsOf: dictionaryKeyDescription)
            return nil
        } else if let dictionaryKeyDescription = listItem.extractStandaloneDictionaryKey() {
            // - dictionaryKey x: ...
            dictionaryKeys.append(dictionaryKeyDescription)
            return nil
        } else if let httpParameterDescription = listItem.extractHTTPParameterOutline() {
            // - HTTPParameters:
            //   - x: ...
            //   - y: ...
            httpParameters.append(contentsOf: httpParameterDescription)
            return nil
        } else if let httpParameterDescription = listItem.extractStandaloneHTTPParameter() {
            // - HTTPParameter x: ...
            httpParameters.append(httpParameterDescription)
            return nil
        } else if let httpBodyDescription = listItem.extractHTTPBody() {
            // - httpBody: ...
            if httpBody == nil {
                httpBody = httpBodyDescription
            } else {
                httpBody?.contents = httpBodyDescription.contents
            }
            return nil
        } else if let httpBodyParameterDescription = listItem.extractHTTPBodyParameterOutline() {
            // - HTTPBodyParameters:
            //   - x: ...
            //   - y: ...
            if httpBody == nil {
                httpBody = HTTPBody(mediaType: nil, contents: [], parameters: httpBodyParameterDescription, symbol: nil)
            } else {
                httpBody?.parameters.append(contentsOf: httpBodyParameterDescription)
            }
            return nil
        } else if let httpBodyParameterDescription = listItem.extractStandaloneHTTPBodyParameter() {
            // - HTTPBodyParameter x: ...
            if httpBody == nil {
                httpBody = HTTPBody(mediaType: nil, contents: [], parameters: [httpBodyParameterDescription], symbol: nil)
            } else {
                httpBody?.parameters.append(httpBodyParameterDescription)
            }
            return nil
        } else if let httpResponseDescription = listItem.extractHTTPResponseOutline() {
            // - HTTPResponses:
            //   - x: ...
            //   - y: ...
            httpResponses.append(contentsOf: httpResponseDescription)
            return nil
        } else if let httpResponseDescription = listItem.extractStandaloneHTTPResponse() {
            // - HTTPResponse x: ...
            httpResponses.append(httpResponseDescription)
            return nil
        } else if let simpleTag = listItem.extractSimpleTag() {
            // - todo: ...
            // etc.
            otherTags.append(simpleTag)
            return nil
        }

        // No match; leave this list item alone.
        return listItem
    }

    mutating func visitDoxygenParameter(_ doxygenParam: DoxygenParameter) -> Markup? {
        parameters.append(Parameter(doxygenParam))
        return nil
    }

    mutating func visitDoxygenReturns(_ doxygenReturns: DoxygenReturns) -> Markup? {
        returns.append(Return(doxygenReturns))
        return nil
    }
}