OpenZeppelin / solidity-docgen

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

`@title` and multiline `@dev` doc issues #424

Closed vrde closed 1 year ago

vrde commented 1 year ago

:wave: hey I'm quite new to this library. I have a couple of issues, one with @title and the other one with @dev, they are both summarized by the following example:

Input:

/**
 * @title The FooBar Contract
 *
 * @dev The contract foos and bars.
 *
 *  More specifically:
 *
 *  - When it foos, it doesn't bar
 *  - When it bars, it doesn't foo
 */
contract FooBar { }

Output:

# Solidity API

## FooBar

_The contract foos and bars.

 More specifically:

 - When it foos, it doesn't bar
 - When it bars, it doesn't foo_

First: where is @title rendered?

Second: how do I create a @dev comment that spreads across multiple lines without using _? The @dev tag works correctly (multilines are maintained, great!) but the parser adds _ at the beginning and at the end of the multiline string. Am I using @dev incorrectly?

frangio commented 1 year ago

Both questions relate to the default template:

  1. It doesn't show the NatSpec title.
  2. It prints @dev tag contents in italics (therefore the underscores).

You can change both of these by creating a directory docgen-templates and adding to your Hardhat config: docgen: { templates: 'docgen-templates' }, then copying the default common.hbs into that directory and making some changes to it. For example, you can change {{h}} {{name}} (the title) into:

{{#if natspec.title}}
{{h}} {{natspec.title}}
{{#else}}
{{h}} {{name}}
{{/if}}

And you can remove the underscores around {{{natspec.dev}}} if you want to get rid of them.

Let me know how this goes.