Skip to content

Commit b20fd94

Browse files
authored
Merge pull request #342 from kimdv/kimdv/add-documentation
Add documentation to init methods
2 parents d13d06a + ee9e96d commit b20fd94

File tree

2 files changed

+1167
-0
lines changed

2 files changed

+1167
-0
lines changed

Sources/SwiftSyntaxBuilder/Buildables.swift.gyb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
122122
let ${"%s: %s" % (child.swift_name, param_type)}
123123
% end
124124

125+
/// Creates a `${node.syntax_kind}` using the provided parameters.
126+
/// - Parameters:
127+
% for child in node.children:
128+
% description = ""
129+
% if child.description:
130+
% for line in dedented_lines(child.description):
131+
% description += line
132+
% end
133+
% end
134+
% description = description.replace("\n", " ").strip()
135+
/// - ${lowercase_first_word(child.name)}: ${description}
136+
% end
125137
public init(
126138
% init_parameters = []
127139
% for child in node.children:
@@ -192,6 +204,9 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
192204
public struct ${node.syntax_kind}: SyntaxBuildable {
193205
let elements: [${element_type}]
194206

207+
/// Creates a `${node.syntax_kind}` with the provided list of elements.
208+
/// - Parameters:
209+
/// - elements: A list of `ExpressibleAs${element_type}`
195210
public init(_ elements: [ExpressibleAs${element_type}]) {
196211
self.elements = elements.map { $0.create${element_type}() }
197212
}

0 commit comments

Comments
 (0)