Skip to content

Commit cc5c9b8

Browse files
committed
Adopt swift-markdown's adjacentDoxygenCommandsSpacing for doc comments
1 parent 0ae683a commit cc5c9b8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/SwiftLanguageService/ExtractParametersDocumentation.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ private struct Parameter {
1818
let documentation: String
1919
}
2020

21+
/// Default markdown formatter options that output all Doxygen commands as separate paragraphs
22+
/// so they get rendered properly in markdown renderers that don't understand Doxygen.
23+
private let formatterOptions = MarkupFormatter.Options(adjacentDoxygenCommandsSpacing: .separateParagraphs)
24+
2125
/// Extracts parameter documentation from a Doxygen parameter command.
2226
private func extractParameter(from doxygenParameter: DoxygenParameter) -> Parameter {
2327
return Parameter(
2428
name: doxygenParameter.name,
25-
documentation: Document(doxygenParameter.blockChildren).format(),
29+
documentation: Document(doxygenParameter.blockChildren).format(formatterOptions),
2630
)
2731
}
2832

@@ -160,7 +164,7 @@ private func extractParameter(listItem: ListItem) -> Parameter? {
160164
let remainingFirstTextContent = String(components[1]).trimmingCharacters(in: .whitespaces)
161165
let remainingParagraphChildren = [Text(remainingFirstTextContent)] + paragraph.inlineChildren.dropFirst()
162166
let remainingChildren = [Paragraph(remainingParagraphChildren)] + listItem.blockChildren.dropFirst()
163-
let documentation = Document(remainingChildren).format()
167+
let documentation = Document(remainingChildren).format(formatterOptions)
164168

165169
return Parameter(name: name, documentation: documentation)
166170
}
@@ -194,7 +198,7 @@ private func extractParameterWithRawIdentifier(from listItem: ListItem) -> Param
194198
let remainingParagraphChildren =
195199
[Text(remainingTextContent)] + paragraph.inlineChildren.dropFirst(2)
196200
let remainingChildren = [Paragraph(remainingParagraphChildren)] + listItem.blockChildren.dropFirst(1)
197-
let documentation = Document(remainingChildren).format()
201+
let documentation = Document(remainingChildren).format(formatterOptions)
198202

199203
return Parameter(name: rawIdentifier.code, documentation: documentation)
200204
}
@@ -253,7 +257,7 @@ package func extractParametersDocumentation(
253257
}
254258
}
255259

256-
let remaining = Document(remainingBlocks).format()
260+
let remaining = Document(remainingBlocks).format(formatterOptions)
257261

258262
return (parameters: parameters, remaining: remaining)
259263
}

0 commit comments

Comments
 (0)