From c342cea7bb09ebbf0894d298e8867ab975cfd92f Mon Sep 17 00:00:00 2001 From: bill Date: Thu, 11 Feb 2021 17:44:32 +0800 Subject: [PATCH] cleanup docs --- convex_api/account.py | 65 ++++++++++++++++-------------- docs/source/classes/account.rst | 4 +- docs/source/classes/convex_api.rst | 2 +- docs/source/conf.py | 4 +- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/convex_api/account.py b/convex_api/account.py index 22c5641..c28f038 100644 --- a/convex_api/account.py +++ b/convex_api/account.py @@ -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 diff --git a/docs/source/classes/account.rst b/docs/source/classes/account.rst index dd56c81..0cb63f5 100644 --- a/docs/source/classes/account.rst +++ b/docs/source/classes/account.rst @@ -1,7 +1,9 @@ Account class ============= -.. autoclass:: convex_api.account.Account +.. autoclass:: convex_api.Account :members: :undoc-members: :show-inheritance: + + diff --git a/docs/source/classes/convex_api.rst b/docs/source/classes/convex_api.rst index ed2265f..2db2ae2 100644 --- a/docs/source/classes/convex_api.rst +++ b/docs/source/classes/convex_api.rst @@ -1,7 +1,7 @@ ConvexAPI class =============== -.. autoclass:: convex_api.convex_api.ConvexAPI +.. autoclass:: convex_api.ConvexAPI :members: :undoc-members: :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py index 206149e..6701d26 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -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 ----------------------------------------------------- @@ -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 = [ @@ -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']