Skip to content

Add documentation to init methods #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/SwiftSyntaxBuilder/Buildables.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
let ${"%s: %s" % (child.swift_name, param_type)}
% end

/// Creates a `${node.syntax_kind}` using the provided parameters.
/// - Parameters:
% for child in node.children:
% description = ""
% if child.description:
% for line in dedented_lines(child.description):
% description += line
% end
% end
% description = description.replace("\n", " ").strip()
/// - ${lowercase_first_word(child.name)}: ${description}
% end
public init(
% init_parameters = []
% for child in node.children:
Expand Down Expand Up @@ -191,6 +203,9 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
public struct ${node.syntax_kind}: SyntaxBuildable {
let elements: [${element_type}]

/// Creates a `${node.syntax_kind}` with the provided list of elements.
/// - Parameters:
/// - elements: A list of `ExpressibleAs${element_type}`
public init(_ elements: [ExpressibleAs${element_type}]) {
self.elements = elements.map { $0.create${element_type}() }
}
Expand Down
Loading