Code Monkey home page Code Monkey logo

vyper-doc's Introduction

VYPER-DOC

A python script to turn your docstring inside contract into json userdoc and devdoc like solidity compiler

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You need argparse python3 version, run this command on your terminal to install it:

pip3 install argparse

Installing

To install it just clone it into your folder, run this command:

git clone https://github.com/acheron2302/vyper-doc.git ~/opt/vyper-doc

Then for your terminal to run it just by typing vyper-doc, you need to run setup.sh with root privilege:

sudo ./setup.sh

notice: The run on terminal is only work with linux and haven't support mac

Usage example

This script use the vyper document natspec to turn your contract into json doc.

Example

The example contract:

x: uint256


@public
def store(_value: uint256):
  """
    @author acheron2302
    @notice store the value to this contract
    @dev store the value to this contract
    @param _value The value to store in this contract
  """
  x = _value


@public
@constant
def get() -> uint256:
  """
    @author acheron2302
    @notice get back the value store in this contract
    @dev get back the value for 
    this contract
    @return the value that is store in this contract
  """
  return x

To get back the user document run this command:

$ vyper-doc --userdoc file_path

The result on the above contract:

{
    "methods": {
        "get()": {
            "notice": "get back the value store in this contract"
        },
        "store(uint256)": {
            "notice": "store the value to this contract"
        }
    }
}

And to get back the dev doc run this command:

$ vyper-doc --devdoc file_path

The result on the above contract:

{
    "methods": {
        "get()": {
            "author": "acheron2302",
            "dev": "get back the value for this contract",
            "return": "the value that is store in this contract"
        },
        "store(uint256)": {
            "author": "acheron2302",
            "dev": "store the value to this contract"
        }
    }
}

Notice

You MUST follow this rule for the script to work:

  • YOU MUST RUN THIS SCRIPT WITH VYPER COMPILER ALREADY OPEN AND RUN ON YOUR TERMINAL. If you haven't install vyper compiler then you can follow this instruction on their document
  • This script only work if you write the natspec inside the function
  • You can only have 1 dev, 1 notice and 1 author in each function. But if you need more than 1 then you can write in multiple line like in the example
  • The setup.sh is only support linux for now

Contact

email: [email protected]

vyper-doc's People

Contributors

acheron2302 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.