diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_static/collapsible_container.css | 26 | ||||
| -rw-r--r-- | docs/_templates/page.html | 15 | ||||
| -rw-r--r-- | docs/conf.py | 5 | ||||
| -rw-r--r-- | docs/examples.rst | 73 | ||||
| -rw-r--r-- | docs/index.rst | 1 | ||||
| -rw-r--r-- | docs/related_projects.rst | 2 |
6 files changed, 122 insertions, 0 deletions
diff --git a/docs/_static/collapsible_container.css b/docs/_static/collapsible_container.css new file mode 100644 index 0000000..65542e2 --- /dev/null +++ b/docs/_static/collapsible_container.css @@ -0,0 +1,26 @@ +/* Taken from: https://github.com/plone/training/blob/master/_static/custom.css */ + +.toggle { + background: none repeat scroll 0 0 #e7f2fa; + padding: 12px; + line-height: 24px; + margin-bottom: 24px; +} + +.toggle .admonition-title { + display: block; + clear: both; + cursor: pointer; +} + +.toggle .admonition-title:after { + content: " ▶"; +} + +.toggle .admonition-title.open:after { + content: " ▼"; +} + +.toggle p:last-child { + margin-bottom: 0; +} diff --git a/docs/_templates/page.html b/docs/_templates/page.html new file mode 100644 index 0000000..724739b --- /dev/null +++ b/docs/_templates/page.html @@ -0,0 +1,15 @@ +{# Taken from: https://github.com/plone/training/blob/master/_templates/page.html #} +{% extends "!page.html" %} + +{% block footer %} + <script type="text/javascript"> + $(document).ready(function() { + $(".toggle > *").hide(); + $(".toggle .admonition-title").show(); + $(".toggle .admonition-title").click(function() { + $(this).parent().children().not(".admonition-title").toggle(400); + $(this).parent().children(".admonition-title").toggleClass("open"); + }) + }); +</script> +{% endblock %} diff --git a/docs/conf.py b/docs/conf.py index cd7df64..6d92cad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -65,3 +65,8 @@ autosectionlabel_prefix_document = True # HTML theme settings pygments_style = 'sphinx' html_theme = 'sphinx_rtd_theme' + + +def setup(app): + """Run some additional steps after the Sphinx builder is initialized""" + app.add_css_file('collapsible_container.css') diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..daf2ee4 --- /dev/null +++ b/docs/examples.rst @@ -0,0 +1,73 @@ +Examples +-------- +This section contains some complete examples that demonstrate the main features of requests-cache. + +These can also be found in the +`examples/ <https://github.com/reclosedev/requests-cache/tree/master/examples>`_ folder on GitHub. + + +Basic usage (with sessions) +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. include:: ../examples/log_requests.py + :start-line: 2 + :end-line: 3 + +.. admonition:: Example code + :class: toggle + + .. literalinclude:: ../examples/basic_usage.py + :lines: 1,6- + + +Basic usage (with patching) +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. include:: ../examples/session_patch.py + :start-line: 3 + :end-line: 4 + +.. admonition:: Example code + :class: toggle + + .. literalinclude:: ../examples/session_patch.py + :lines: 1,6- + + +Cache expiration +~~~~~~~~~~~~~~~~ +.. include:: ../examples/expiration.py + :start-line: 2 + :end-line: 3 + +.. admonition:: Example code + :class: toggle + + .. literalinclude:: ../examples/expiration.py + :lines: 1,5- + + +Logging requests +~~~~~~~~~~~~~~~~ +.. include:: ../examples/log_requests.py + :start-line: 2 + :end-line: 3 + +.. admonition:: Example code + :class: toggle + + .. literalinclude:: ../examples/log_requests.py + :lines: 1,5- + + +Converting an old cache +~~~~~~~~~~~~~~~~~~~~~~~ +.. include:: ../examples/convert_cache.py + :start-line: 2 + :end-line: 4 + +.. admonition:: Example code + :class: toggle + + .. literalinclude:: ../examples/convert_cache.py + :lines: 1,6- + + diff --git a/docs/index.rst b/docs/index.rst index 24a6db6..bb39011 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,6 +15,7 @@ Contents user_guide advanced_usage security + examples api contributing contributors diff --git a/docs/related_projects.rst b/docs/related_projects.rst index 5ceb81b..deca9cd 100644 --- a/docs/related_projects.rst +++ b/docs/related_projects.rst @@ -15,3 +15,5 @@ You can also check out these other python cache projects: ``aiohttp`` web server * `aiocache <https://github.com/aio-libs/aiocache>`_: General-purpose (not HTTP-specific) async cache backends +* `flask-caching <https://github.com/sh4nks/flask-caching>`_: A server-side HTTP cache for + applications using the Flask framework |
