Hardhat 3 plugin to generate customizable smart contracts documentation.
This plugin generates markdown documentation of the contracts present in the project. Leveraging the natspec and solc capabilities, it is able to output beautiful uniswap-like .md files.
npm install --save-dev @solarity/hardhat-markupIn your hardhat.config.ts, import the plugin and add it to the plugins array:
import hardhatMarkup from "@solarity/hardhat-markup";
const config: HardhatUserConfig = {
    plugins: [hardhatMarkup],
    // ... your config
};The documentation generation can be run either with built-in compile or the provided markup task.
To view the available options, run these help commands:
npx hardhat help compile
npx hardhat help markupThis plugin does not extend the environment.
The npx hardhat markup command will compile and generate documentation for all the contracts used in the project into the default folder.
Clean old artifacts via npx hardhat clean command.
The default configuration looks as follows. You may customize all fields in your hardhat config file.
export default {
  markup: {
    outdir: "./generated-markups",
    onlyFiles: [],
    skipFiles: [],
    noCompile: false,
    verbose: false,
  },
};- outdir: The directory where to store the generated documentation
- onlyFiles: If specified, documentation will be generated only for matching sources, other will be ignored
- skipFiles: Documentation will not be generated for any matching sources, also if those match- onlyFiles
- noCompile: Skips project recompilation before the documentation generation
- verbose: Detailed logging on generation
When invoked, markup compiles the project (unless noCompile is set) using the production build profile and ensures userdoc and devdoc are included in the compiler output.
- Path stands for relative path from project root to either .solfile or directory.
- If path is a directory, all its files and sub-directories are considered matching.
- If source is a node module, node_modulesmust not be present in the path.
| Generated markdown | Example Solidity code | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| contract ExampleAuthor: Solidity lover The example contract This contract is meant to work as the example of how  In a nutshell, the plugin parses natspec documentation and presents it in a beautiful, Uniswap-like style, leveraging MD format. You can also have code blocks inside the comments! contract Example {
    function foo() external {
        . . .
    }
}event Random(uint256 value)The event that emits a random value Parameters: 
 error Oops(string reason)The error, occurs from time to time Parameters: 
 function foo(address user, uint256 entropy) external returns (uint256)The very important function that computes the answer to the Universe Parameters: 
 Return values: 
 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
 * @author Solidity lover
 * @notice The example contract
 *
 * This contract is meant to work as the example of how `hardhat-markup` plugin works.
 *
 * In a nutshell, the plugin parses natspec documentation and presents it in a beautiful,
 * Uniswap-like style, leveraging MD format.
 *
 * You can also have code blocks inside the comments!
 *
 * ```solidity
 * contract Example {
 *     function foo() external {
 *         . . .
 *     }
 * }
 * ```
 */
contract Example {
    /**
     * @notice The event that emits a random value
     * @param value the random value
     */
    event Random(uint256 value);
    /**
     * @notice The error, occurs from time to time
     * @param reason the reason
     */
    error Oops(string reason);
    /**
     * @notice The very important function that computes the answer to the Universe
     * @param user the user who created the Universe
     * @param entropy the entropy
     * @return the answer (42)
     */
    function foo(address user, uint256 entropy) external returns (uint256) {
        emit Random(uint256(uint160(user)) + entropy);
        return 42;
    }
} | 
- Vyperis currently not supported.
- inheritdocparsing is ignored for state variable declarations.