Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@primitivefi/hardhat-dodoc
Advanced tools
Zero-config Hardhat plugin to generate documentation for all your Solidity contracts
Zero-config Hardhat plugin to generate documentation for all your Solidity contracts.
Want to see a live example? Check out Primitive documentation!
First thing to do is to install the plugin in your Hardhat project:
# Using yarn
yarn add @primitivefi/hardhat-dodoc
# Or using npm
npm i @primitivefi/hardhat-dodoc
Next step is simply to include the plugin into your hardhat.config.js
or hardhat.config.ts
file:
// Using JavaScript
require('@primitivefi/hardhat-dodoc');
// Using ES6 or TypeScript
import '@primitivefi/hardhat-dodoc';
And you're done! Documentation will be automatically generated on the next compilation and saved into the docs
folder at the root of your project.
The only requirement to use Dodoc is to comment your Solidity contracts using NatSpec format. For example, given the following function:
/// @notice Does another thing when the function is called.
/// @dev More info about doing another thing when the function is called.
/// @param num A random number
/// @return A random variable
function anotherThing(uint256 num) external pure returns (uint256);
Dodoc will take care of everything and will generate the following output:
Methods
anotherThing
function anotherThing(uint256 num) external pure returns (uint256)
Does another thing when the function is called.
More info about doing another thing when the function is called.
Parameters
Name Type Description num uint256 A random number Returns
Name Type Description _0 uint256 A random variable
Dodoc is compatible with all the NatSpec tags (except custom ones for now), and can generate documentation for events, custom errors and external / public functions.
By default Dodoc generates new documentation after each compilation, but you can also trigger the task with the following command:
# Using yarn
yarn hardhat dodoc
# Or using npx
npx hardhat dodoc
Dodoc comes with a default configuration but you can still tweak some parameters. To do it, change your Hardhat config file like this:
import { HardhatUserConfig } from 'hardhat/config';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-ethers';
import '@primitivefi/hardhat-dodoc';
const config: HardhatUserConfig = {
// Your Hardhat config...
dodoc: {
runOnCompile: true,
debugMode: true,
// More options...
},
};
export default config;
Here are all the configuration parameters that are currently available, but as said above, all of them are entirely optional:
Parameter | Description | Default value |
---|---|---|
runOnCompile | True if the plugin should generate the documentation on every compilation | true |
include | List of all the contract / interface / library / folder names to include in the documentation generation. An empty array will generate documentation for everything | [] |
exclude | List of all the contract / interface / library / folder names to exclude from the documentation generation | [] |
outputDir | Output directory of the documentation | docs |
templatePath | Path to the documentation template | ./template.sqrl |
debugMode | Test mode generating additional JSON files used for debugging | false |
keepFileStructure | True if you want to preserve your contracts file structure in the output directory | true |
freshOutput | True if you want to clean the output directory before generating new documentation | true |
Dodoc integrates a super cool template engine called SquirrellyJS, allowing anyone to create new output formats easily.
You can checkout the default Markdown template to get some inspiration, as well as SquirrellyJS documentation to learn more about it. Feel free to be creative, any kind of output such as Markdown, MDX, HTML or even JSON is supported!
Once you're satisfied, simply refer to your template using the templatePath
parameter in your configuration and Dodoc will use it to output the documentation!
Feel free to open an issue if you need help or if you encounter a problem! Here are some already known problems though:
private
and internal
functions is not rendered. Hence, the documentation of libraries might be close to empty!_0
, _1
, ... format.constructor
, fallback
and receive
might not be rendered.@custom:...
are not rendered (yet).FAQs
Zero-config Hardhat plugin to generate documentation for all your Solidity contracts
We found that @primitivefi/hardhat-dodoc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.