OpenZeppelin / solidity-docgen

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

What's the easiest way to replace # Solidity API with the actual filename #421

Closed mwawrusch closed 2 years ago

mwawrusch commented 2 years ago

We use docusaurus and that takes by default the title of the markdown as the sidebar header for that item.

frangio commented 2 years ago

Create a directory docgen-templates and configure the plugin with docgen: { templates: 'docgen-templates' } in the Hardhat config.

Create a file in this directory called page.hbs with the following contents:

# {{id}}

{{#each items}}
{{#hsection}}
{{>item}}
{{/hsection}}

{{/each}}

(Note: This is just the default with a different title.)

{{id}} will render the filename of the page. I don't know if this is what you're asking for. Notably, it will include the .md extension, so you may want to remove that using a helper. You can do that by adding helpers.js in docgen-templates:

module.exports['without-ext'] = function (str) {
  return str.replace('.md', '');
}

Then using {{without-ext id}} as the title.

Closing as resolved, let me know if you run into any issues.

mwawrusch commented 2 years ago

awesome, thank you