Updated docs, updated theme, added doctest rst

api-breakage
Morty Space 6 years ago
parent 2cb4831a51
commit 92c52c7d86
  1. 3
      .travis.yml
  2. 0
      docs/source/_static/.gitkeep
  3. 5
      docs/source/api.rst
  4. 16
      docs/source/conf.py
  5. 2
      docs/source/guide.rst
  6. 38
      docs/source/index.rst
  7. 2
      docs/source/install.rst
  8. 2
      pytest.ini
  9. 14
      setup.py
  10. 2
      src/cryptocom/exchange/__init__.py
  11. 2
      src/cryptocom/exchange/base.py

@ -5,7 +5,8 @@ python:
install: install:
- pip install -e ".[dev]" - pip install -e ".[dev]"
script: script:
- py.test --cov . --cov-report xml:coverage.xml - cd docs && make doctest
- pytest --cov . --cov-report xml:coverage.xml
env: env:
global: global:

@ -0,0 +1,5 @@
API reference
=============
.. automodule:: cryptocom.exchange
:members:

@ -13,16 +13,18 @@
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
# #
from cryptocom.exchange import VERSION
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = 'cryptocom-exchange' project = 'cryptocom-exchange'
copyright = '2019, change' copyright = '2020, goincrypto.com'
author = 'change' author = 'Yaroslav Rudenok [MortySpace]'
# The short X.Y version # The short X.Y version
version = '' version = VERSION
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = '0.1' release = VERSION
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
@ -79,7 +81,7 @@ pygments_style = None
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
html_theme = 'alabaster' html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
@ -133,7 +135,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'cryptocom-exchange.tex', 'unv\\_template Documentation', (master_doc, 'cryptocom-exchange.tex', 'cryptocom-exchange\\_template Documentation',
'change', 'manual'), 'change', 'manual'),
] ]
@ -154,7 +156,7 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'cryptocom-exchange', 'cryptocom-exchange Documentation', (master_doc, 'cryptocom-exchange', 'cryptocom-exchange Documentati',
author, 'cryptocom-exchange', 'One line description of project.', author, 'cryptocom-exchange', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]

@ -0,0 +1,2 @@
User's Guide
============

@ -2,15 +2,43 @@
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
.. toctree::
:hidden:
:maxdepth: 3
:caption: Contents:
Home <self>
install
guide
api
Welcome to cryptocom-exchange documentation! Welcome to cryptocom-exchange documentation!
============================================ ============================================
Get started with "Installation" and then get an overview with the User's guide with helpful examples. Also you can find tests with examples of trading and exchange data usage.
Full reference you can find in the API section. cryptocom-exchange depends on the aiohttp the documentation for this library can be found at: "link".
.. toctree:: Quick-start
:maxdepth: 2 ===========
:caption: Contents:
- python3 -m venv venv (create virutalenv)
- source venv/bin/activate
- pip3 install cryptocom-exchange
- create simple file hello_crypto.py with contents
.. testcode::
import asyncio
import cryptocom.exchange as cro
async def main():
exchange = cro.Exchange()
candles = [
candle async for candle in exchange.get_candles(cro.Symbol.CROUSDT)
]
assert len(candles) > 30
.. automodule:: cryptocom.exchange asyncio.run(main())
:members:
Indices and tables Indices and tables
================== ==================

@ -0,0 +1,2 @@
Installation
============

@ -1,3 +1,3 @@
[pytest] [pytest]
addopts = --doctest-modules addopts = --doctest-plus --doctest-rst
python_paths = tests python_paths = tests

@ -1,8 +1,18 @@
from pathlib import Path
from setuptools import setup, find_packages from setuptools import setup, find_packages
def get_version():
module_file = Path(
Path(__file__).parent, 'src',
*find_packages('src')[-1].split('.'), '__init__.py'
)
return module_file.read_text().split("VERSION = '")[1].split("'")[0]
setup( setup(
name='cryptocom-exchange', name='cryptocom-exchange',
version='0.1', version=get_version(),
description="""Provide description""", description="""Provide description""",
url='https://github.com/goincrypto/cryptocom-exchange', url='https://github.com/goincrypto/cryptocom-exchange',
author='Yaroslav Rudenok [Morty Space]', author='Yaroslav Rudenok [Morty Space]',
@ -35,9 +45,11 @@ setup(
'pytest-asyncio', 'pytest-asyncio',
'pytest-cov', 'pytest-cov',
'pytest-env', 'pytest-env',
'pytest-doctestplus',
'pytest-pythonpath', 'pytest-pythonpath',
'autopep8', 'autopep8',
'sphinx', 'sphinx',
'sphinx_rtd_theme',
'setuptools', 'setuptools',
'wheel', 'wheel',
'twine' 'twine'

@ -7,3 +7,5 @@ __all__ = [
'Exchange', 'Account', 'Candle', 'Exchange', 'Account', 'Candle',
'ApiError', 'ApiProvider' 'ApiError', 'ApiProvider'
] ]
VERSION = '0.1'

@ -35,7 +35,7 @@ class Exchange:
async def get_ticker(self, symbol: Symbol): async def get_ticker(self, symbol: Symbol):
return (await self.get_tickers()).get(symbol.value) return (await self.get_tickers()).get(symbol.value)
async def get_candles(self, symbol: Symbol, period: Period): async def get_candles(self, symbol: Symbol, period: Period = Period.D1):
"""Get k-line data over a specified period.""" """Get k-line data over a specified period."""
data = await self.api.get( data = await self.api.get(
'klines', {'symbol': symbol.value, 'period': period.value}) 'klines', {'symbol': symbol.value, 'period': period.value})

Loading…
Cancel
Save