From d2ba262c5307aa14c325ef53d8e4e56a5ece0376 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 5 Jul 2020 12:22:36 -0400 Subject: Initial Commit --- funcsignature.etlua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 funcsignature.etlua (limited to 'funcsignature.etlua') diff --git a/funcsignature.etlua b/funcsignature.etlua new file mode 100644 index 0000000..48d92ba --- /dev/null +++ b/funcsignature.etlua @@ -0,0 +1,22 @@ +<% assert(func, "Requires function to render a function signature") %> +<% assert(funcname, "Requires a function name to render a function signature") %> +<%- funcname %>( + <% if func.params and #func.params > 0 then %> + <% local optchain = false %> + <% for paramid, param in pairs(func.params) do %> + <% if paramid == 1 and param.optional then %> + [ + <% elseif param.optional then %> + [, + <% elseif paramid > 1 then %> + , + <% end %> + <%- param.name %> + <% if paramid == 1 and param.optional then %> + ] + <% elseif param.optional then %> + ] + <% end %> + <% end %> + <% end %> +) -- cgit v1.2.3-70-g09d2