Skip to content

Commit

Permalink
added sphinx documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
shyal committed Dec 1, 2016
1 parent 9905366 commit 1a81476
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 249 deletions.
113 changes: 0 additions & 113 deletions README.rst

This file was deleted.

45 changes: 45 additions & 0 deletions docs/source/basic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. basic
Basic Example
********


Import hoverpy's main class: HoverPy

.. code:: python
from hoverpy import HoverPy
Import requests and random for http

.. code:: python
import requests
Create our HoverPy object in capture mode

.. code:: python
hp = HoverPy(capture=True)
Print the json from our get request. Hoverpy acted as a proxy: it made
the request on our behalf, captured it, and returned it to us.

.. code:: python
print(requests.get("http://ip.jsontest.com/myip").json())
Switch HoverPy to simulate mode. HoverPy no longer acts as a proxy; all
it does from now on is replay the captured data.

.. code:: python
hp.simulate()
Print the json from our get request. This time the data comes from the
store.

.. code:: python
print(requests.get("http://ip.jsontest.com/myip").json())
87 changes: 3 additions & 84 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import sys
import os
import shlex
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../../'))

# -- General configuration ------------------------------------------------

Expand All @@ -32,7 +33,6 @@
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -176,7 +176,7 @@
#html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
html_show_sphinx = False

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
Expand Down Expand Up @@ -205,84 +205,3 @@

# Output file base name for HTML help builder.
htmlhelp_basename = 'hoverpydoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',

# Latex figure (float) alignment
#'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'hoverpy.tex', u'hoverpy Documentation',
u'SpectoLabs', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'hoverpy', u'hoverpy Documentation',
[author], 1)
]

# If true, show URL addresses after external links.
#man_show_urls = False


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'hoverpy', u'hoverpy Documentation',
author, 'hoverpy', 'One line description of project.',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
85 changes: 85 additions & 0 deletions docs/source/delays.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.. delays
delays Example
********


Import hoverpy's main class: HoverPy

.. code:: python
from hoverpy import HoverPy
Import requests and random for http and testing

.. code:: python
import requests
import random
Create our HoverPy object in capture mode

.. code:: python
hp = HoverPy(capture=True)
This function either generates a echo server url, or a md5 url it is
seeded so that we get the exact same requests on capture as we do on
simulate

.. code:: python
def getServiceData():
for i in range(10):
random.seed(i)
print(
requests.get(
random.choice(
[
"http://echo.jsontest.com/i/%i" %
i,
"http://md5.jsontest.com/?text=%i" %
i])).json())
Make the requests to the desired host dependencies

.. code:: python
print("capturing responses from echo server\n")
getServiceData()
There are two ways to add delays. One is to call the delays method with
the desired delay rules passed in as a json document

.. code:: python
print(hp.delays({"data": [
{
"urlPattern": "md5.jsontest.com",
"delay": 1000
}
]
}
))
The other more pythonic way is to call addDelay(...)

.. code:: python
print(hp.addDelay(urlPattern="echo.jsontest.com", delay=3000))
Now let's switch over to simulate mode

.. code:: python
print(hp.simulate())
Make the requests. This time HoverFly adds the simulated delays. these
requests would normally be run asynchronously, and we could deal
gracefully with the dependency taking too long to respond

.. code:: python
print("\nreplaying delayed responses from echo server\n")
getServiceData()
30 changes: 30 additions & 0 deletions docs/source/hoverpy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
hoverpy package
===============

Submodules
----------

hoverpy.config module
---------------------

.. automodule:: hoverpy.config
:members:
:undoc-members:
:show-inheritance:

hoverpy.generateDocs module
---------------------------

.. automodule:: hoverpy.generateDocs
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: hoverpy
:members:
:undoc-members:
:show-inheritance:

0 comments on commit 1a81476

Please sign in to comment.