All Projects β†’ clemlak β†’ leafleth

clemlak / leafleth

Licence: MIT license
πŸ“‘ Documentation generator for Solidity

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to leafleth

bloqly
Bloqly: JavaScript Smart Contracts Engine + SQL database
Stars: ✭ 29 (+20.83%)
Mutual labels:  smart-contracts
rgb-core
RGB Core Library: consensus validation for private & scalable client-validated smart contracts on Bitcoin & Lightning
Stars: ✭ 99 (+312.5%)
Mutual labels:  smart-contracts
koinos-gui-miner
The Koinos Miner (GUI) provides a sleek and functional user interface that allows users to mine the KOIN ERC-20 which will be used to deliver an equitable initial token distribution on the Koinos blockchain.
Stars: ✭ 26 (+8.33%)
Mutual labels:  smart-contracts
ethereum-solidity-course-updated-code
Up-to-date Solidity/web3.js/React/Next.js code for the udemy.com course Ethereum and Solidity: The Complete Developer's Guide.
Stars: ✭ 161 (+570.83%)
Mutual labels:  smart-contracts
fcl-js
FCL (Flow Client Library) - The best tool for building JavaScript (browser & NodeJS) applications on Flow 🌊
Stars: ✭ 302 (+1158.33%)
Mutual labels:  smart-contracts
awesome-solidity-patterns
πŸš€Awesome Solidity patterns to make life easier ✌️
Stars: ✭ 73 (+204.17%)
Mutual labels:  smart-contracts
TZComet
Contract Metadata Viewer on Tezos
Stars: ✭ 24 (+0%)
Mutual labels:  smart-contracts
akropolis
πŸ’₯ Akropolis+Yearn
Stars: ✭ 0 (-100%)
Mutual labels:  smart-contracts
flow-protocol-ethereum
Flow Protocols powering synthetic asset and margin trading
Stars: ✭ 18 (-25%)
Mutual labels:  smart-contracts
ether-swr
Ether-SWR is a React hook that fetches Ethereum data. It streamlines the chores to keep the internal state of the Decentralized App (DApp), batches the RPC calls to an Ethereum node and cache the responses
Stars: ✭ 125 (+420.83%)
Mutual labels:  smart-contracts
web3j-example
Android web3j example
Stars: ✭ 27 (+12.5%)
Mutual labels:  smart-contracts
flow-ft
The Fungible Token standard on the Flow Blockchain
Stars: ✭ 120 (+400%)
Mutual labels:  smart-contracts
clarinet
Clarinet is a simple, modern and opinionated runtime for testing, integrating and deploying Clarity smart contracts.
Stars: ✭ 209 (+770.83%)
Mutual labels:  smart-contracts
framework
Lightweight, open source and magic-free framework for testing solidity smart contracts.
Stars: ✭ 36 (+50%)
Mutual labels:  smart-contracts
tinlake
Smart contracts for Tinlake, the on-chain securitization protocol for real-world assets
Stars: ✭ 85 (+254.17%)
Mutual labels:  smart-contracts
pact-todomvc
Demo of integrating a JS webapp with the Pact smart contract langauge
Stars: ✭ 20 (-16.67%)
Mutual labels:  smart-contracts
ipfs-eth-database
An example of usage IPFS in Ethereum Smart Contracts
Stars: ✭ 55 (+129.17%)
Mutual labels:  smart-contracts
vandal
Static program analysis framework for Ethereum smart contract bytecode.
Stars: ✭ 121 (+404.17%)
Mutual labels:  smart-contracts
prb-math
Solidity library for advanced fixed-point math
Stars: ✭ 404 (+1583.33%)
Mutual labels:  smart-contracts
solidity-diagram-gen
UML class diagram generator for solidity contracts
Stars: ✭ 33 (+37.5%)
Mutual labels:  smart-contracts

πŸ“‘ Leafleth

Leafleth is a documentation generator for your Solidity smart-contracts. It also integrates a template engine to allow anyone to create customized documentation in a snap.

Note: This tool is still in development and new fixes are pushed almost daily, I highly recommend you to update it every time you use it!

πŸŽ‰ Example

This example was generated using the default template provided by Leafleth.

πŸ“¦ Installation

You can install Leafleth as a global package:

Using npm:

npm i -g leafleth

Or using yarn:

yarn add global leafleth

Additionally, Leafleth can be installed as a local package in your project.

πŸš€ Usage

First of all, be sure to comment your smart-contracts according to the NatSpec format. Once you're done, compile your contracts and let Leafleth handle the rest!

Use the following command to generate your documentation:

leafleth -s <source>

The source is the only required option, and it must refer to the path of a .json file (a compiled contract) or to an entire directory (for example, the build/contracts directory if you are using Truffle).

πŸŽ› Options

  • -s or --source (required): The path to a file or a directory, which will be used to generate the documentation.
  • -o or --output: The directory used to output the documentation. If no value is provided, Leafleth will output the documentation into the source directory.
  • -t or --template: The template used to generate the documentation. If no value is provided, the default template will be used.
  • -d or --debug: Enable debug mode.
  • -V or --version: Display the version number.
  • -h or --help: Display usage information.

🎨 Create your own themes

Internally, Leafleth uses Squirrelly for its template engine. This means that any type of documentation (Markdown, HTML, ...) can be generated if you provide the right template.

To create a new template, you can use the default one as a base or start a new .sqrl file from scratch. The content of the templates is totally free, and the only requirement is that they must be a valid Squirrelly template.

While generating the documentation, Leafleth will send the following object to your template:

{
  "contract": {
    "name": "BasicExample",
    "notice": "A notice for the basic contract",
    "title": "A basic contract",
    "details": "Some dev stuff for the basic contract",
    "author": "Clemlak",
    "networks": {
      "1575142431303": {
        "events": {
          "0x34fc9a8d030d354e59e2bf2e5d0f37f63355b58fdbef38546a8af45588c1c0c1": {
            "anonymous": false,
            "inputs": [
              {
                "indexed": true,
                "internalType": "address",
                "name": "sender",
                "type": "address"
              },
              {
                "indexed": false,
                "internalType": "uint256",
                "name": "newValue",
                "type": "uint256"
              }
            ],
            "name": "NumberUpdated",
            "type": "event",
            "signature": "0x34fc9a8d030d354e59e2bf2e5d0f37f63355b58fdbef38546a8af45588c1c0c1"
          },
          "0x1e4f1784ac7a8562d6607d2a924880d7c77218e7da91e5c71705ba914a85582f": {
            "anonymous": false,
            "inputs": [
              {
                "indexed": false,
                "internalType": "uint256",
                "name": "someValue",
                "type": "uint256"
              }
            ],
            "name": "RandomEvent",
            "type": "event",
            "signature": "0x1e4f1784ac7a8562d6607d2a924880d7c77218e7da91e5c71705ba914a85582f"
          }
        },
        "links": {},
        "address": "0x37dd0087B5c9ea6921a248FF1f69e22b3b4E9E5E",
        "transactionHash": "0x0a6eea50c8ce5db352490659ca42e9c434ef132f58903f9a0eb03f2a792321e6"
      }
    }
  },
  "methods": {
    "isContractReady": {
      "constant": true,
      "payable": false,
      "stateMutability": "view",
      "outputs": [
        {
          "internalType": "bool",
          "name": "",
          "type": "bool"
        }
      ]
    },
    "aRandomNumber": {
      "constant": true,
      "payable": false,
      "stateMutability": "view",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ]
    },
    "setNumber": {
      "constant": false,
      "payable": true,
      "stateMutability": "payable",
      "outputs": [],
      "notice": "Sets a number",
      "details": "This is an external function",
      "author": "ClemLak",
      "params": {
        "newNumber": {
          "description": "The new value of the number",
          "type": "uint256"
        }
      }
    },
    "setNumberIfContractIsReady": {
      "constant": false,
      "payable": false,
      "stateMutability": "nonpayable",
      "outputs": [],
      "notice": "Sets a number if the contract is ready",
      "details": "This is an external function",
      "params": {
        "newNumber": {
          "description": "The new value of the number",
          "type": "uint256"
        }
      }
    },
    "getNumber": {
      "constant": true,
      "payable": false,
      "stateMutability": "view",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "notice": "Gets the number",
      "details": "This is an external view function",
      "return": "The value of the number"
    },
    "getTwoNumbers": {
      "constant": true,
      "payable": false,
      "stateMutability": "pure",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "notice": "Gets two numbers",
      "details": "This function looks complex",
      "return": "A cool numberAnother cool number"
    },
    "add": {
      "constant": true,
      "payable": false,
      "stateMutability": "pure",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "notice": "Add two numbers",
      "details": "This function looks complex",
      "return": "The sum of a + b",
      "params": {
        "b": {
          "description": "Another number",
          "type": "uint256"
        }
      }
    }
  },
  "events": {
    "NumberUpdated": {
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "sender",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "newValue",
          "type": "uint256"
        }
      ],
      "anonymous": false
    },
    "RandomEvent": {
      "inputs": [
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "someValue",
          "type": "uint256"
        }
      ],
      "anonymous": false
    }
  }
}

To display a value, you'll simply have to use its global reference. For example:

<h1>{{contract.title}}</h1>

Methods or other objects can be listed using loops.

When you're ready, simply run the following command to generate your documentation using your own template:

leafleth -s <source> -t <yourTemplate>

πŸ›  Contributing

Feel free to open an issue or create a PR if you want to contribute. Also, submitting new templates will be really appreciated!

❌ Known issues

The following issues have been found and will be resolved soon:

  • Private or internal functions are not displayed
  • Modifiers are not displayed
  • Functions from an inherited contract may not be displayed correctly
  • Overloaded functions may not be displayed correctly

πŸ“„ License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].