npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@float-capital/hardhat-source-descriptor

v0.0.15-rc

Published

A hardhat plugin to generate richer documentation for your solidity contracts

Downloads

2

Readme

hardhat-source-descriptor

Quickstart

npm install hardhat-source-descriptor

Add this to your hardhat.config.js:

const { usePlugin } = require("@nomiclabs/hardhat/config");

usePlugin("hardhat-source-descriptor");

module.exports = {
  // All fields are optional,
  // path defaults to cache path
  // file defaults to ast-doc.json
  // ignores nothing by default
  astdocs: {
    path: "./ast-docs",
    file: "ast-doc.json",
    ignores: "test",
  },
  // ...
};
npx hardhat compile

What does it do

Parses the AST to generate (richer) documentation.

Data is serialized in a JSON blob, e.g.

{
  "contracts/Child.sol": {
    "imports": ["contracts/Parent.sol"],
    "contracts": {
      "Child": {
        "functions": [
          {
            "name": "myFunction",
            "signature": "myFunction() external",
            "returns": "()",
            "events": ["OwnerNominated"],
            "modifiers": ["onlyOwner"],
            "visibility": "external",
            "lineNumber": 6
          }
        ],
        "events": [],
        "variables": [],
        "modifiers": [],
        "structs": [],
        "inherits": ["Parent"]
      }
    }
  },
  "contracts/ERC20.sol": {
    "imports": ["contracts/IERC20.sol"],
    "contracts": {
      "SafeMath": {
        "functions": [
          {
            "name": "add",
            "signature": "add(uint256 a, uint256 b) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 8
          },
          {
            "name": "sub",
            "signature": "sub(uint256 a, uint256 b) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 15
          },
          {
            "name": "sub",
            "signature": "sub(uint256 a, uint256 b, string errorMessage) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 19
          },
          {
            "name": "mul",
            "signature": "mul(uint256 a, uint256 b) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 30
          },
          {
            "name": "div",
            "signature": "div(uint256 a, uint256 b) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 44
          },
          {
            "name": "div",
            "signature": "div(uint256 a, uint256 b, string errorMessage) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 48
          },
          {
            "name": "mod",
            "signature": "mod(uint256 a, uint256 b) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 60
          },
          {
            "name": "mod",
            "signature": "mod(uint256 a, uint256 b, string errorMessage) internal",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 64
          }
        ],
        "events": [],
        "modifiers": [],
        "structs": [],
        "inherits": []
      },
      "ERC20": {
        "functions": [
          {
            "name": "totalSupply",
            "signature": "totalSupply() public",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 96
          },
          {
            "name": "balanceOf",
            "signature": "balanceOf(address account) public",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 103
          },
          {
            "name": "transfer",
            "signature": "transfer(address recipient, uint256 amount) public",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 115
          },
          {
            "name": "allowance",
            "signature": "allowance(address owner, address spender) public",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 123
          },
          {
            "name": "approve",
            "signature": "approve(address spender, uint256 amount) public",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 138
          },
          {
            "name": "transferFrom",
            "signature": "transferFrom(address sender, address recipient, uint256 amount) public",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 155
          },
          {
            "name": "increaseAllowance",
            "signature": "increaseAllowance(address spender, uint256 addedValue) public",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 183
          },
          {
            "name": "decreaseAllowance",
            "signature": "decreaseAllowance(address spender, uint256 subtractedValue) public",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 209
          },
          {
            "name": "_transfer",
            "signature": "_transfer(address sender, address recipient, uint256 amount) internal",
            "returns": "()",
            "events": ["Transfer"],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 238
          },
          {
            "name": "_mint",
            "signature": "_mint(address account, uint256 amount) internal",
            "returns": "()",
            "events": ["Transfer"],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 261
          },
          {
            "name": "_burn",
            "signature": "_burn(address account, uint256 amount) internal",
            "returns": "()",
            "events": ["Transfer"],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 280
          },
          {
            "name": "_approve",
            "signature": "_approve(address owner, address spender, uint256 amount) internal",
            "returns": "()",
            "events": ["Approval"],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 304
          },
          {
            "name": "_burnFrom",
            "signature": "_burnFrom(address account, uint256 amount) internal",
            "returns": "()",
            "events": [],
            "modifiers": [],
            "visibility": "internal",
            "lineNumber": 318
          }
        ],
        "events": [],
        "variables": [
          {
            "name": "_balances",
            "type": "mapping(address => uint256)",
            "lineNumber": 87,
            "visibility": "private"
          },
          {
            "name": "_allowances",
            "type": "mapping(address => mapping(address => uint256))",
            "lineNumber": 89,
            "visibility": "private"
          },
          {
            "name": "_totalSupply",
            "type": "uint256",
            "lineNumber": 91,
            "visibility": "private"
          }
        ],
        "modifiers": [],
        "structs": [],
        "inherits": ["IERC20"]
      }
    }
  },
  "contracts/IERC20.sol": {
    "imports": [],
    "contracts": {
      "IERC20": {
        "functions": [
          {
            "name": "totalSupply",
            "signature": "totalSupply() external",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 5
          },
          {
            "name": "balanceOf",
            "signature": "balanceOf(address account) external",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 10
          },
          {
            "name": "transfer",
            "signature": "transfer(address recipient, uint256 amount) external",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 19
          },
          {
            "name": "allowance",
            "signature": "allowance(address owner, address spender) external",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 30
          },
          {
            "name": "approve",
            "signature": "approve(address spender, uint256 amount) external",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 49
          },
          {
            "name": "transferFrom",
            "signature": "transferFrom(address sender, address recipient, uint256 amount) external",
            "returns": "(bool)",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 60
          }
        ],
        "events": [
          {
            "name": "Transfer",
            "parameters": "(address from, address to, uint256 value)",
            "lineNumber": 70
          },
          {
            "name": "Approval",
            "parameters": "(address owner, address spender, uint256 value)",
            "lineNumber": 76
          }
        ],
        "variables": [],
        "modifiers": [],
        "structs": [],
        "inherits": []
      }
    }
  },
  "contracts/Multiple.sol": {
    "imports": [],
    "contracts": {
      "One": {
        "functions": [
          {
            "name": "functionOne",
            "signature": "functionOne() public",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 5
          }
        ],
        "events": [],
        "variables": [],
        "modifiers": [],
        "structs": [],
        "inherits": []
      },
      "Two": {
        "functions": [
          {
            "name": "functionTwo",
            "signature": "functionTwo() public",
            "returns": "(uint256)",
            "events": [],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 12
          }
        ],
        "events": [],
        "variables": [],
        "modifiers": [],
        "structs": [],
        "inherits": []
      }
    }
  },
  "contracts/Parent.sol": {
    "imports": [],
    "contracts": {
      "Parent": {
        "functions": [
          {
            "name": "fallback",
            "signature": "() external",
            "returns": "()",
            "events": [],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 16
          },
          {
            "name": "constructor",
            "signature": "(address _owner) public",
            "returns": "()",
            "events": ["OwnerChanged"],
            "modifiers": [],
            "visibility": "public",
            "lineNumber": 18
          },
          {
            "name": "nominateNewOwner",
            "signature": "nominateNewOwner(address _owner) external",
            "returns": "()",
            "events": ["OwnerNominated"],
            "modifiers": ["onlyOwner"],
            "visibility": "external",
            "lineNumber": 24
          },
          {
            "name": "acceptOwnership",
            "signature": "acceptOwnership() external",
            "returns": "()",
            "events": ["OwnerChanged"],
            "modifiers": [],
            "visibility": "external",
            "lineNumber": 29
          }
        ],
        "events": [
          {
            "name": "OwnerNominated",
            "parameters": "(address newOwner)",
            "lineNumber": 55
          },
          {
            "name": "OwnerChanged",
            "parameters": "(address oldOwner, address newOwner)",
            "lineNumber": 56
          }
        ],
        "variables": [
          {
            "name": "owner",
            "type": "address",
            "lineNumber": 8,
            "visibility": "public"
          },
          {
            "name": "nominatedOwner",
            "type": "address",
            "lineNumber": 9,
            "visibility": "public"
          }
        ],
        "modifiers": [
          {
            "name": "onlyOwner",
            "parameters": "()",
            "visibility": "internal",
            "lineNumber": 39
          },
          {
            "name": "onlySpecificAddress",
            "parameters": "(address user)",
            "visibility": "internal",
            "lineNumber": 47
          }
        ],
        "structs": [
          {
            "name": "MyCustomStruct",
            "members": [
              {
                "name": "aVariable",
                "type": "uint256"
              },
              {
                "name": "bVarible",
                "type": "address"
              }
            ],
            "lineNumber": 11
          }
        ],
        "inherits": []
      }
    }
  }
}