Skip to content

Commit

Permalink
cleanup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
billbsing committed Feb 11, 2021
1 parent 9b97911 commit c342cea
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
65 changes: 34 additions & 31 deletions convex_api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,60 @@


class Account:
"""

The Convex account class, contains the public/private keys and possibly an address.
def __init__(self, private_key, address=None):
"""
You can create a new account object, it will only have it's public/private keys but does not have a valid account address.
To obtain a new account address, you need to call the :py:meth:`.ConvexAPI.create_account` with the new account object.
Create a new account with a private key as a Ed25519PrivateKey. It is better to use
one of the following static methods to create an Account object:
This is so that you can use the same public/private keys for multiple convex accounts.
* :meth:`.create`
* :meth:`import_from_bytes`
* :meth:`import_from_file`
* :meth:`import_from_mnemonic`
* :meth:`import_from_text`
Once you have your new account you need to save the public/private keys using the `export..` methods and also you
need to save the account address.
:param Ed25519PrivateKey private_key: The public/private key as an Ed25519PrivateKey object
To re-use the account again, you can import the keys and set the account address using one of the `import..` methods.
:param int address: address of the account
**Note**
For security reasons all of the keys, and text returned by the accounts are only truncated ending with a **`...`**
.. code-block:: python
The Convex account class, contains the public/private keys and possibly an address.
>>> # import convex-api
>>> from convex_api import ConvexAPI
You can create a new account object, it will only have it's public/private keys but does not have a valid account address.
To obtain a new account address, you need to call the :py:meth:`.ConvexAPI.create_account` with the new account object.
>>> # setup the network connection
>>> convex_api = ConvexAPI('https://convex.world')
This is so that you can use the same public/private keys for multiple convex accounts.
>>> # create a new account and address
>>> account = convex_api.create_account()
Once you have your new account you need to save the public/private keys using the `export..` methods and also you
need to save the account address.
>>> # export the private key to a file
>>> account.export_to_file('/tmp/my_account.pem', 'my secret password')
To re-use the account again, you can import the keys and set the account address using one of the `import..` methods.
>>> # save the address for later
>>> my_address = account.address
**Note**
For security reasons all of the keys, and text returned by the accounts are only truncated ending with a **`...`**
>>> # ----
.. code-block:: python
>>> # now import the account and address for later use
>>> reload_account = Account.import_from_file('/tmp/my_account.pem', 'my secret password', my_address)
>>> # import convex-api
>>> from convex_api import ConvexAPI
"""
def __init__(self, private_key, address=None):
"""
>>> # setup the network connection
>>> convex_api = ConvexAPI('https://convex.world')
Create a new account with a private key as a Ed25519PrivateKey. It is better to use
one of the `create` or `import` methods instead of creating this object directly.
>>> # create a new account and address
>>> account = convex_api.create_account()
:param Ed25519PrivateKey private_key: The public/private key as an Ed25519PrivateKey object
>>> # export the private key to a file
>>> account.export_to_file('/tmp/my_account.pem', 'my secret password')
:param int address: address of the account
>>> # save the address for later
>>> my_address = account.address
>>> # ----
>>> # now import the account and address for later use
>>> reload_account = Account.import_from_file('/tmp/my_account.pem', 'my secret password', my_address)
"""
self._private_key = private_key
Expand Down
4 changes: 3 additions & 1 deletion docs/source/classes/account.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Account class
=============

.. autoclass:: convex_api.account.Account
.. autoclass:: convex_api.Account
:members:
:undoc-members:
:show-inheritance:


2 changes: 1 addition & 1 deletion docs/source/classes/convex_api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ConvexAPI class
===============

.. autoclass:: convex_api.convex_api.ConvexAPI
.. autoclass:: convex_api.ConvexAPI
:members:
:undoc-members:
:show-inheritance:
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import shutil
from sphinx.domains.python import PythonDomain

print(os.path.abspath('../../'))
# print(os.path.abspath('../../'))
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------
Expand Down Expand Up @@ -52,6 +52,7 @@
apidoc_module_dir = '../../convex_api'
# apidoc_output_dir = 'api' by default, and leave it that way!
apidoc_separate_modules = True

# See https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html
apidoc_extra_args = []
apidoc_excluded_paths = [
Expand All @@ -71,6 +72,7 @@
# 'special-members': None,
# 'inherited-members': None,
# }
autoclass_content = 'both'

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down

0 comments on commit c342cea

Please sign in to comment.