OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
450 stars 118 forks source link

How to create typescript helpers #418

Closed nksazonov closed 2 years ago

nksazonov commented 2 years 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 2 years ago

What version of solidity-docgen do you have installed?

nksazonov commented 2 years ago

latest, 0.5.16

frangio commented 2 years 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.