diff --git a/src/index.ts b/src/index.ts index 061c031..dcbcc61 100644 --- a/src/index.ts +++ b/src/index.ts @@ -85,7 +85,7 @@ function capitalize(s: string) { } function camelToSnakeCase(s: string) { - return s.split(/(?=[A-Z])/).join('_').toLowerCase() + return s.split(/(?=[A-Z])/).join("_").toLowerCase(); } export function render() { @@ -97,7 +97,7 @@ export function render() { makePublic, jsonWrappedRustType, capitalize, - camelToSnakeCase + camelToSnakeCase, }; const output = ejs.render(tmpl, ctx); diff --git a/template/src/lib.rs.ejs b/template/src/lib.rs.ejs index 0c480ca..5f2c941 100644 --- a/template/src/lib.rs.ejs +++ b/template/src/lib.rs.ejs @@ -1,10 +1,12 @@ mod pdk; -use pdk::*; +use pdk::*; use extism_pdk::*; <% schema.exports.forEach(ex => { -%> - +<% if (hasComment(ex)) { -%> +// <%- formatCommentBlock(ex.description, "// ") %> +<% } -%> pub(crate) fn <%= camelToSnakeCase(ex.name) %>(<%if (ex.input) { %>_input: <%- toRustType(ex.input) %> <% } %>) -> Result<<%if (ex.output) { %> <%- toRustType(ex.output) %> <% } else { %> () <% } %>, Error> { <% if (featureFlags['stub-with-code-samples'] && codeSamples(ex, 'rust').length > 0) { -%> <%- codeSamples(ex, 'rust')[0].source %>