Skip to content

Commit

Permalink
Expanding documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
zmasek committed Apr 24, 2019
1 parent c6348f0 commit fdc25e6
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/source/configuration.rst
@@ -0,0 +1,7 @@
Configuration
=============

So far, only page size returned is configurable on the initial set-up. ::

from shamrock import Shamrock
api = Shamrock('my_secret_token', page_size=5)
1 change: 1 addition & 0 deletions docs/source/contributing.rst
@@ -0,0 +1 @@
.. include:: ../../CONTRIBUTING.rst
1 change: 1 addition & 0 deletions docs/source/history.rst
@@ -0,0 +1 @@
.. include:: ../../HISTORY.rst
9 changes: 9 additions & 0 deletions docs/source/index.rst
Expand Up @@ -10,6 +10,15 @@ Welcome to Shamrock's documentation!
:maxdepth: 2
:caption: Contents:

introduction
setting_up
usage
configuration
modules
contributing
history
resources



Indices and tables
Expand Down
10 changes: 10 additions & 0 deletions docs/source/introduction.rst
@@ -0,0 +1,10 @@
Introduction
============

☘ **Shamrock** is a Python shallow API library for `Trefle <https://trefle.io/>`_ integration. It
enables interacting with the Trefle plants API in Python to get the information needed for various
things you might want to use the API with such as research, gardening software, automation, etc. It
is made for use with Python 3.6 and above.

For more information what the Trefle service provides, refer to their documentation. It is also
useful for checking out how to use the API with Shamrock library.
4 changes: 2 additions & 2 deletions docs/source/modules.rst
@@ -1,5 +1,5 @@
shamrock
========
Modules
=======

.. toctree::
:maxdepth: 4
Expand Down
6 changes: 6 additions & 0 deletions docs/source/resources.rst
@@ -0,0 +1,6 @@
Resources
=========

* `Trefle API <https://trefle.io/>`_
* `Shamrock repository <https://github.com/zmasek/shamrock/>`_
* `Shamrock PyPI <https://example.com/>`_
32 changes: 32 additions & 0 deletions docs/source/setting_up.rst
@@ -0,0 +1,32 @@
Setting up
==========

Prerequisites
-------------

Shamrock relies on Python 3.6 and above and `Requests III <https://3.python-requests.org/>`_
library. Requests will get installed automatically, but you need to make sure to meet the other
requirement.

To start interacting with the API, you'll need a token from them. Obtaining it is not a big deal.
Make sure to sign up on the Trefle page and obtain token there. You'll need it when using the
library.

Installation
------------

It is highly recommended to start using `pipenv <https://pipenv.readthedocs.io/en/latest/>`_ for
managing your dependencies::

$ pipenv install shamrock

but you can use pip also::

$ pip install shamrock

Basic Usage
-----------
::

from shamrock import Shamrock
api = Shamrock('my_secret_token')
83 changes: 83 additions & 0 deletions docs/source/usage.rst
@@ -0,0 +1,83 @@
Usage
=====

Basic
-----
::

from shamrock import Shamrock
api = Shamrock('my_secret_token')
plants = api.plants()
print(plants)

Advanced
--------

Setting Up
~~~~~~~~~~
::

from shamrock import Shamrock
api = Shamrock('my_secret_token')

or with a configuration::

from shamrock import Shamrock
api = Shamrock('my_secret_token', page_size=5)

Methods
~~~~~~~

Methods that can be run with the API are::

api.kingdoms()
api.subkingdoms()
api.divisions()
api.families()
api.genuses()
api.plants()
api.species()

They correspond to the Trefle API endpoints.

Single item
~~~~~~~~~~~

You can also query a specific item from the database::

api.plants(103505)

Search
~~~~~~

Searching is covered with a separate method::

api.search("tomato")

Navigation
~~~~~~~~~~

Navigating the API is covered with these methods::

api.next()
api.prev()
api.first()
api.last()

It will work only if you previously made a request. For example::

api.species()
api.next()

Specific Options
~~~~~~~~~~~~~~~~

By default, the API responds with the list of whatever number is set in the Trefle. You can
manipulate it with previously mentioned page_size::

api.species(page_size=5)

You can also use the varoius query string options described on Trefle API documentation as keyword
arguments in methods::

api.species(common_name="blackwood")

0 comments on commit fdc25e6

Please sign in to comment.