Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

[Feature] Add docs #63

Closed
localhuman opened this issue Nov 6, 2017 · 7 comments
Closed

[Feature] Add docs #63

localhuman opened this issue Nov 6, 2017 · 7 comments

Comments

@localhuman
Copy link
Collaborator

Add actual documentation to the project.

@localhuman
Copy link
Collaborator Author

  • Add in docstrings to all methods/modules etc
  • Fill in docstrings with more than boilerplate
  • Create sphinx documentation
  • Publish to readthedocs.io

@ixje
Copy link
Member

ixje commented Nov 6, 2017

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.

@ixje
Copy link
Member

ixje commented Nov 9, 2017

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:
        """

@localhuman
Copy link
Collaborator Author

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

@ixje
Copy link
Member

ixje commented Nov 13, 2017

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

@localhuman
Copy link
Collaborator Author

This is complete, though further documentation would never hurt.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants