Skip to content

Commit 3c7c50c

Browse files
authored
Merge pull request ggrammar#25 from gamagori/feature/documentation
Feature/documentation
2 parents 89d4475 + aa3f84f commit 3c7c50c

File tree

15 files changed

+344
-2
lines changed

15 files changed

+344
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ instance/
6565

6666
# Sphinx documentation
6767
docs/_build/
68+
docs/source
6869

6970
# PyBuilder
7071
target/

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = pizzapi
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# pizzapi documentation build configuration file, created by
4+
# sphinx-quickstart on Sun Feb 4 22:05:18 2018.
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
# If extensions (or modules to document with autodoc) are in another directory,
16+
# add these directories to sys.path here. If the directory is relative to the
17+
# documentation root, use os.path.abspath to make it absolute, like shown here.
18+
#
19+
# import os
20+
# import sys
21+
# sys.path.insert(0, os.path.abspath('.'))
22+
23+
24+
# -- General configuration ------------------------------------------------
25+
26+
# If your documentation needs a minimal Sphinx version, state it here.
27+
#
28+
# needs_sphinx = '1.0'
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = ['sphinx.ext.autodoc',
34+
'sphinx.ext.doctest',
35+
'sphinx.ext.coverage']
36+
37+
# Add any paths that contain templates here, relative to this directory.
38+
templates_path = ['_templates']
39+
40+
# The suffix(es) of source filenames.
41+
# You can specify multiple suffix as a list of string:
42+
#
43+
# source_suffix = ['.rst', '.md']
44+
source_suffix = '.rst'
45+
46+
# The master toctree document.
47+
master_doc = 'index'
48+
49+
# General information about the project.
50+
project = u'pizzapi'
51+
copyright = u'2018, Arie van Luttikhuizen, Grant Gordon'
52+
author = u'Arie van Luttikhuizen, Grant Gordon'
53+
54+
# The version info for the project you're documenting, acts as replacement for
55+
# |version| and |release|, also used in various other places throughout the
56+
# built documents.
57+
#
58+
# The short X.Y version.
59+
version = u'0.0.2'
60+
# The full version, including alpha/beta/rc tags.
61+
release = u'0.0.2'
62+
63+
# The language for content autogenerated by Sphinx. Refer to documentation
64+
# for a list of supported languages.
65+
#
66+
# This is also used if you do content translation via gettext catalogs.
67+
# Usually you set "language" from the command line for these cases.
68+
language = None
69+
70+
# List of patterns, relative to source directory, that match files and
71+
# directories to ignore when looking for source files.
72+
# This patterns also effect to html_static_path and html_extra_path
73+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
74+
75+
# The name of the Pygments (syntax highlighting) style to use.
76+
pygments_style = 'sphinx'
77+
78+
# If true, `todo` and `todoList` produce output, else they produce nothing.
79+
todo_include_todos = False
80+
81+
82+
# -- Options for HTML output ----------------------------------------------
83+
84+
# The theme to use for HTML and HTML Help pages. See the documentation for
85+
# a list of builtin themes.
86+
#
87+
html_theme = 'alabaster'
88+
89+
# Theme options are theme-specific and customize the look and feel of a theme
90+
# further. For a list of options available for each theme, see the
91+
# documentation.
92+
#
93+
# html_theme_options = {}
94+
95+
# Add any paths that contain custom static files (such as style sheets) here,
96+
# relative to this directory. They are copied after the builtin static files,
97+
# so a file named "default.css" will overwrite the builtin "default.css".
98+
html_static_path = ['_static']
99+
100+
# Custom sidebar templates, must be a dictionary that maps document names
101+
# to template names.
102+
#
103+
# This is required for the alabaster theme
104+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
105+
html_sidebars = {
106+
'**': [
107+
'relations.html', # needs 'show_related': True theme option to display
108+
'searchbox.html',
109+
]
110+
}
111+
112+
113+
# -- Options for HTMLHelp output ------------------------------------------
114+
115+
# Output file base name for HTML help builder.
116+
htmlhelp_basename = 'pizzapidoc'
117+
118+
119+
# -- Options for LaTeX output ---------------------------------------------
120+
121+
latex_elements = {
122+
# The paper size ('letterpaper' or 'a4paper').
123+
#
124+
# 'papersize': 'letterpaper',
125+
126+
# The font size ('10pt', '11pt' or '12pt').
127+
#
128+
# 'pointsize': '10pt',
129+
130+
# Additional stuff for the LaTeX preamble.
131+
#
132+
# 'preamble': '',
133+
134+
# Latex figure (float) alignment
135+
#
136+
# 'figure_align': 'htbp',
137+
}
138+
139+
# Grouping the document tree into LaTeX files. List of tuples
140+
# (source start file, target name, title,
141+
# author, documentclass [howto, manual, or own class]).
142+
latex_documents = [
143+
(master_doc, 'pizzapi.tex', u'pizzapi Documentation',
144+
u'Arie van Luttikhuizen, Grant Gordon', 'manual'),
145+
]
146+
147+
148+
# -- Options for manual page output ---------------------------------------
149+
150+
# One entry per manual page. List of tuples
151+
# (source start file, name, description, authors, manual section).
152+
man_pages = [
153+
(master_doc, 'pizzapi', u'pizzapi Documentation',
154+
[author], 1)
155+
]
156+
157+
158+
# -- Options for Texinfo output -------------------------------------------
159+
160+
# Grouping the document tree into Texinfo files. List of tuples
161+
# (source start file, target name, title, author,
162+
# dir menu entry, description, category)
163+
texinfo_documents = [
164+
(master_doc, 'pizzapi', u'pizzapi Documentation',
165+
author, 'pizzapi', 'One line description of project.',
166+
'Miscellaneous'),
167+
]
168+
169+
170+

docs/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. pizzapi documentation master file, created by
2+
sphinx-quickstart on Sun Feb 4 22:05:18 2018.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to pizzapi's documentation!
7+
===================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

docs/make.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
set SPHINXPROJ=pizzapi
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd

pizzapi/address.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
from .urls import Urls, COUNTRY_USA
44

55
class Address(object):
6+
"""Create an address, for finding stores and placing orders.
7+
8+
The Address object describes a street address in North America (USA or
9+
Canada, for now). Callers can use the Address object's methods to find
10+
the closest or nearby stores from the API.
11+
12+
Attributes:
13+
street (String): Street address
14+
city (String): North American city
15+
region (String): North American region (state, province, territory)
16+
zip (String): North American ZIP code
17+
urls (String): Country-specific URLs
18+
country (String): Country
19+
"""
20+
621
def __init__(self, street, city, region='', zip='', country=COUNTRY_USA, *args):
722
self.street = street.strip()
823
self.city = city.strip()
@@ -25,6 +40,12 @@ def line2(self):
2540
return '{City}, {Region}, {PostalCode}'.format(**self.data)
2641

2742
def nearby_stores(self, service='Delivery'):
43+
"""Query the API to find nearby stores.
44+
45+
nearby_stores will filter the information we receive from the API
46+
to exclude stores that are not currently online (!['IsOnlineNow']),
47+
and stores that are not currently in service (!['ServiceIsOpen']).
48+
"""
2849
data = request_json(self.urls.find_url(), line1=self.line1, line2=self.line2, type=service)
2950
return [Store(x, self.country) for x in data['Stores']
3051
if x['IsOnlineNow'] and x['ServiceIsOpen'][service]]

pizzapi/coupon.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
class Coupon(object):
2+
"""Loose representation of a coupon - no logic.
3+
4+
This is a coupon - you can add it to an Order (order.add_item) and,
5+
if it fits, get some money off your purchase. I think.
6+
7+
This is another thing that's worth exploring - there are some sweet
8+
coupons that would be awful without the coupon.
9+
"""
210
def __init__(self, code, quantity=1):
311
self.code = code
412
self.quantity = quantity

pizzapi/customer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
class Customer(object):
2+
"""The Customer orders a pizza.
3+
4+
You need a Customer to create an Order. The proprietors of the API
5+
use this information, presumably for nefarious Pizza Purposes.
6+
"""
7+
28
def __init__(self, fname='', lname='', email='', phone='', address=None):
39
self.first_name = fname.strip()
410
self.last_name = lname.strip()

pizzapi/menu.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def __init__(self, data={}):
2828

2929

3030
class Menu(object):
31+
"""The Menu is our primary interface with the API.
32+
33+
This is far and away the most complicated class - it wraps up most of
34+
the logic that parses the information we get from the API.
35+
36+
Next time I get pizza, there is a lot of work to be done in
37+
documenting this class.
38+
"""
3139
def __init__(self, data={}, country=COUNTRY_USA):
3240
self.variants = data.get('Variants', {})
3341
self.menu_by_code = {}

pizzapi/order.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
# TODO: Add add_coupon and remove_coupon methods
88
class Order(object):
9+
"""Core interface to the payments API.
10+
11+
The Order is perhaps the second most complicated class - it wraps
12+
up all the logic for actually placing the order, after we've
13+
determined what we want from the Menu.
14+
"""
915
def __init__(self, store, customer, address, country=COUNTRY_USA):
1016
self.store = store
1117
self.menu = Menu.from_store(store_id=store.id, country=country)

pizzapi/payment.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33

44
class PaymentObject(object):
5+
"""A PaymentObject represents a credit card.
6+
7+
There's some sweet logic in here to make sure that the type of card
8+
you passed is valid.
9+
"""
510
def __init__(self, number='', expiration='', cvv='', zip=''):
611
self.name = ''
712
self.number = str(number).strip()

pizzapi/store.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55

66
class Store(object):
7+
"""The interface to the Store API
8+
9+
You can use this to find store information about stores near an
10+
address, or to find the closest store to an address.
11+
"""
712
def __init__(self, data={}, country=COUNTRY_USA):
813
self.id = str(data.get('StoreID', -1))
914
self.country = country

pizzapi/track.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@
33

44

55
def track_by_phone(phone, country=COUNTRY_USA):
6+
"""Query the API to get tracking information.
7+
8+
Not quite sure what this gets you - problem to solve for next time I get pizza.
9+
"""
610
phone = str(phone).strip()
7-
data = request_xml(Urls(country).track_by_phone(), phone=phone)['soap:Envelope']['soap:Body']
11+
data = request_xml(
12+
Urls(country).track_by_phone(),
13+
phone=phone
14+
)['soap:Envelope']['soap:Body']
15+
816
response = data['GetTrackerDataResponse']['OrderStatuses']['OrderStatus']
17+
918
return response
1019

1120

1221
def track_by_order(store_id, order_key, country=COUNTRY_USA):
13-
return request_json(Urls(country).track_by_order(), store_id=store_id, order_key=order_key)
22+
"""Query the API to get tracking information.
23+
"""
24+
return request_json(
25+
Urls(country).track_by_order(),
26+
store_id=store_id,
27+
order_key=order_key
28+
)
29+

0 commit comments

Comments
 (0)