OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
441 stars 116 forks source link

How to create typescript helpers #418

Closed nksazonov closed 1 year ago

nksazonov commented 1 year ago

Afternoon!

I have stumbled upon some difficulties creating helpers in typescript for handlebars. Hope you will be able to help.

Why: I need to create some typescript handlebars helper to use inside contract.hbs.

Error: When running solidity-docgen I get this error: SyntaxError: Unexpected token 'export'.

Expected: working helper.

helpers.ts:

export function test(): string {
    return 'test helper';
}

solidity-docgen invokation: npx solidity-docgen --solc-module solc -t templates -H templates/helper.ts -i contracts

Nevertheless, if I write that helper in js file using commonjs modules, everything works fine.

frangio commented 1 year ago

What version of solidity-docgen do you have installed?

nksazonov commented 1 year ago

latest, 0.5.16

frangio commented 1 year ago

0.5 doesn't support TypeScript helpers and is no longer actively maintained. You can use 0.6. Keep in mind that it's used differently (it's a Hardhat plugin) see the readme.