GithubHelp home page GithubHelp logo

[Feature] Add docs about neo-python HOT 7 CLOSED

cityofzion avatar cityofzion commented on June 2, 2024
[Feature] Add docs

from neo-python.

Comments (7)

localhuman avatar localhuman commented on June 2, 2024 2

This is by no means finished, but a WIP here: http://neo-python.readthedocs.io/en/latest/index.html

Currently working out of the feature-docs branch

from neo-python.

localhuman avatar localhuman commented on June 2, 2024
  • Add in docstrings to all methods/modules etc
  • Fill in docstrings with more than boilerplate
  • Create sphinx documentation
  • Publish to readthedocs.io

from neo-python.

ixje avatar ixje commented on June 2, 2024

Any good document that shows how the docstrings should look for sphinx compatibility? I find there website a bit messy. Perhaps some samples how to document function parameters, return type would be nice.

from neo-python.

metachris avatar metachris commented on June 2, 2024

I personally like the Google style docstrings:

This is how it's done in neo-boa:

Here is another example with:

from neo-python.

ixje avatar ixje commented on June 2, 2024

I started converting #74 to rST format as requested by @localhuman here. Unfortunately also that standard leaves room for interpretation / free will. Before having to edit everything a 3rd time I'd like to get to an agreement on how to document the following:

  • multiple return types
  • exceptions
  • notes

multiple return types

Example with current Sphinx Napoleon format:

"""
Change the password used to protect the private key.

    Args:
        password_old (str): the current password used to encrypt the private key.
        password_new (str): the new to be used password to encrypt the private key.

    Returns:
        bool: False, if the old password does not match the current saved password.
        None: If successfully changed the password.

"""

Attempt 1:

        :return: False, if the old password does not match the current saved password. None, If succesfully changed the password.
        :rtype: bool, None

Attempt 2 (suggested here):
Note: this drops the :rtype:

    :return: 
        bool False if the old password does not match the current saved password. 
        None None If successfully changed the password.

Exception documentation

Example:

        """
        Retrieve the script_hash from an address.

        Args:
            address (str): a base58 encoded address.

        Raises:
            ValuesError: if an invalid address is supplied or the coin version is incorrect.
            Exception: if the address checksum fails.

        Returns:
            UInt160: script hash

        """

PyCharm format:

:raises: :exc:ExceptionType

   :raises: :exc: `ValueError` if an invalid address is supplied or the coin version is incorrect.
   :raises: :exc: `Exception` if the address checksum fails.

Note that I'm uncertain here if I should repeat :raises: and if it's ok to add the description behind it.

Sphynx doc example

   :raises ValueError: if an invalid address is supplied or the coin version is incorrect.
   :raises Exception: if the address checksum fails.

Notes

Current:

"""
Add a watch only address to the wallet.
  
Args:
    script_hash (UInt160): a bytearray (len 20) representing the public key.

Returns:
    None
 
Note:
    Prints a warning to the console if the address already exists in the wallet.
 
"""

Attempt (ok?)

        """
        Add a watch only address to the wallet.

        :param script_hash: a bytearray (len 20) representing the public key.
        :type script_hash: UInt160
        .. note:: Prints a warning to the console if the address already exists in the wallet.
        :return:
        """

from neo-python.

ixje avatar ixje commented on June 2, 2024

It's probably good to say we settled on using Google's docstring notation and no longer the rST format discussed just above.

from neo-python.

localhuman avatar localhuman commented on June 2, 2024

This is complete, though further documentation would never hurt.

from neo-python.

Related Issues (20)

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.