Skip to content

Commit

Permalink
Merge 1e0d5b8 into c589282
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Aug 27, 2021
2 parents c589282 + 1e0d5b8 commit eadeb32
Show file tree
Hide file tree
Showing 29 changed files with 200 additions and 97 deletions.
12 changes: 9 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'sphinx_automodapi.smart_resolver',
'sphinx_copybutton',
'sphinx_inline_tabs',
'sphinx_panels',
'sphinxcontrib.apidoc',
'myst_parser',
]
Expand Down Expand Up @@ -94,7 +95,12 @@
# HTML general settings
html_favicon = join('_static', 'favicon.ico')
html_js_files = ['collapsible_container.js']
html_css_files = ['collapsible_container.css', 'table.css']
html_css_files = [
'collapsible_container.css',
'table.css',
'https://use.fontawesome.com/releases/v5.15.3/css/all.css',
'https://use.fontawesome.com/releases/v5.15.3/css/v4-shims.css',
]
html_show_sphinx = False
pygments_style = 'friendly'
pygments_dark_style = 'material'
Expand All @@ -106,11 +112,11 @@
'dark_logo': 'requests-cache-logo-white.png',
'sidebar_hide_name': True,
'light_css_variables': {
'color-brand-primary': '#2962ff',
'color-brand-primary': '#0288d1',
'color-brand-content': '#2a5adf',
},
'dark_css_variables': {
'color-brand-primary': '#2b8cee',
'color-brand-primary': '#5eb8ff',
'color-brand-content': '#368ce2',
},
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(examples)=
# Examples
# {fa}`laptop-code` Examples
This section contains some complete examples that demonstrate the main features of requests-cache.

## Articles
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Documentation for the latest stable release can be found at [requests-cache.read
```{toctree}
:maxdepth: 2
user_guide/index
examples
user_guide
reference
project_info/index
examples
project_info
````
11 changes: 11 additions & 0 deletions docs/project_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# {fa}`info-circle` Project Info

```{toctree}
:maxdepth: 2
project_info/contributing
project_info/contributors
project_info/code_of_conduct
project_info/related_projects
project_info/history
````
2 changes: 2 additions & 0 deletions docs/project_info/code_of_conduct.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# {fa}`handshake` Code of Conduct
```{include} ../../.github/CODE_OF_CONDUCT.md
:start-line: 1
```
2 changes: 2 additions & 0 deletions docs/project_info/contributing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(contributing)=
# {fa}`lightbulb` Contributing
```{include} ../../CONTRIBUTING.md
:start-line: 1
```
2 changes: 2 additions & 0 deletions docs/project_info/contributors.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# {fa}`users` Contributors
```{include} ../../CONTRIBUTORS.md
:start-line: 1
```
2 changes: 2 additions & 0 deletions docs/project_info/history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(changelog)=
# {fa}`history` History
```{include} ../../HISTORY.md
:start-line: 1
```
11 changes: 0 additions & 11 deletions docs/project_info/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/project_info/related_projects.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(related-projects)=
# Related Projects
# {fa}`external-link` Related Projects
If requests-cache isn't quite what you need, you can help make it better! See the
{ref}`Contributing Guide <contributing>` for details.

Expand Down
3 changes: 1 addition & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
% Note: The module sources referenced here are auto-generated with apidoc
(reference)=

# API Reference
# {fa}`list` API Reference
This section covers all the public interfaces of requests-cache.

:::{tip}
Expand Down
29 changes: 29 additions & 0 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(user-guide)=
# {fa}`book` User Guide
This section covers the main features of requests-cache.

```{toctree}
:caption: The Basics
:maxdepth: 2
user_guide/installation
user_guide/general
user_guide/files
user_guide/troubleshooting
```

```{toctree}
:caption: Features & Options
:maxdepth: 2
user_guide/backends
user_guide/filtering
user_guide/headers
user_guide/inspection
user_guide/expiration
user_guide/matching
user_guide/security
user_guide/serializers
user_guide/advanced_requests
user_guide/compatibility
```
10 changes: 6 additions & 4 deletions docs/user_guide/advanced_requests.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!-- TODO: Better title for this section -->
# Usage with other requests features
# {fa}`info-circle` Advanced Requests
Following are some tips on using requests-cache with some of the more
[advanced features](https://docs.python-requests.org/en/latest/user/advanced/) of the requests
library.

## Request Hooks
Requests has an [Event Hook](https://requests.readthedocs.io/en/master/user/advanced/#event-hooks)
## Event Hooks
Requests has an [event hook](https://requests.readthedocs.io/en/master/user/advanced/#event-hooks)
system that can be used to add custom behavior into different parts of the request process.
It can be used, for example, for request throttling:

Expand Down
7 changes: 4 additions & 3 deletions docs/user_guide/backends.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(backends)=
# Backends
# {fa}`database` Backends
![](../_static/sqlite_32px.png)
![](../_static/redis_32px.png)
![](../_static/mongodb_32px.png)
Expand All @@ -8,14 +8,15 @@

Several cache backends are included. The default is SQLite, since it's generally the simplest to
use, and requires no extra dependencies or configuration.

See {py:mod}`.requests_cache.backends` for usage details for specific backends.

```{note}
In the rare case that SQLite is not available
(for example, [on Heroku](https://devcenter.heroku.com/articles/sqlite3)), a non-persistent
in-memory cache is used by default.
```

See {py:mod}`.requests_cache.backends` for usage details for specific backends.

## Backend Dependencies
Most of the other backends require some extra dependencies, listed below.

Expand Down
8 changes: 4 additions & 4 deletions docs/user_guide/compatibility.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- TODO: Fix relative links -->
(compatibility)=
# Usage with other requests-based libraries
# {fa}`plus-square` Usage with other requests-based libraries
This library works by patching and/or extending {py:class}`requests.Session`. Many other libraries
out there do the same thing, making it potentially difficult to combine them.

Expand Down Expand Up @@ -123,15 +123,15 @@ This has the advantage of only using request-mock's behavior for

:::{admonition} Example code
:class: toggle
```{literalinclude} ../tests/compat/test_requests_mock_load_cache.py
```{literalinclude} ../../tests/compat/test_requests_mock_load_cache.py
:lines: 21-40
```
:::

To turn that into a complete example:
:::{admonition} Example code
:class: toggle
```{literalinclude} ../tests/compat/test_requests_mock_load_cache.py
```{literalinclude} ../../tests/compat/test_requests_mock_load_cache.py
```
:::

Expand All @@ -141,6 +141,6 @@ requests-mock examples above.

:::{admonition} Example code
:class: toggle
```{literalinclude} ../tests/compat/test_responses_load_cache.py
```{literalinclude} ../../tests/compat/test_responses_load_cache.py
```
:::
2 changes: 1 addition & 1 deletion docs/user_guide/expiration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(expiration)=
# Expiration
# {fa}`clock` Expiration
By default, cached responses will be stored indefinitely. There are a number of options for
specifying how long to store responses, either with a single expiration value, glob patterns,
or {ref}`cache headers <headers>`.
Expand Down
9 changes: 4 additions & 5 deletions docs/user_guide/files.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(files)=
# Cache Files
# {fa}`folder-open` Cache Files
```{note}
This section only applies to the {py:mod}`~requests_cache.backends.sqlite` and
{py:mod}`~requests_cache.backends.filesystem` backends.
This section only applies to the {py:mod}`SQLite <requests_cache.backends.sqlite>` and
{py:mod}`Filesystem <requests_cache.backends.filesystem>` backends.
```
For file-based backends, the cache name will be used as a path to the cache file(s). You can use
a relative path, absolute path, or use some additional options for system-specific default paths.
Expand Down Expand Up @@ -35,8 +35,7 @@ You can also give an absolute path, including user paths (with `~`).

## System Paths
If you don't know exactly where you want to put your cache files, your system's **temp directory**
or **cache directory** is a good choice. Some options are available as shortcuts to use whatever the
default locations are for your operating system.
or **cache directory** is a good choice. Some options are available as shortcuts for these locations.

Use the default temp directory with the `use_temp` option:
:::{tab} Linux
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/filtering.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(filtering)=
# Cache Filtering
# {fa}`filter` Cache Filtering
In many cases you will want to choose what you want to cache instead of just caching everything. By
default, all **read-only** (`GET` and `HEAD`) **requests with a 200 response code** are cached. A
few options are available to modify this behavior.
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/general.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(general)=
# General Usage
# {fa}`play-circle` General Usage
There are two main ways of using requests-cache:
- **Sessions:** (recommended) Use {py:class}`.CachedSession` to send your requests
- **Patching:** Globally patch `requests` using {py:func}`.install_cache()`
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/headers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(headers)=
# Cache Headers
# {fa}`file-code` Cache Headers
Most common request and response headers related to caching are supported, including
[Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
and [ETags](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag).
Expand Down
21 changes: 0 additions & 21 deletions docs/user_guide/index.md

This file was deleted.

9 changes: 6 additions & 3 deletions docs/user_guide/inspection.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<!-- TODO: This could use some more details and examples -->
(inspection)=
# Cache Inspection
# {fa}`search` Cache Inspection
Here are some ways to get additional information out of the cache session, backend, and responses:

## Response Details
The following attributes are available on responses:
- `from_cache`: indicates if the response came from the cache
- `cache_key`: The unique identifier used to match the request to the response (see {ref}`matching`
for details)
- `created_at`: {py:class}`~datetime.datetime` of when the cached response was created or last updated
- `expires`: {py:class}`~datetime.datetime` after which the cached response will expire
- `is_expired`: indicates if the cached response is expired (if an old response was returned due to a request error)
- `expires`: {py:class}`~datetime.datetime` after which the cached response will expire (see
{ref}`expiration` for details)
- `is_expired`: indicates if the cached response is expired (if, for example, an old response was returned due to a request error)

Examples:
:::{admonition} Example code
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/installation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Installation
# {fa}`download` Installation
Installation instructions:

:::{tab} Pip
Expand Down
3 changes: 2 additions & 1 deletion docs/user_guide/matching.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(matching)=
# Request Matching
# {fa}`equals` Request Matching
Requests are matched according to the request URL, parameters and body. All of these values are
normalized to account for any variations that do not modify response content.

Expand Down Expand Up @@ -56,6 +56,7 @@ As well as headers, if `include_get_headers` is also used:
Since `ignored_parameters` is most often used for sensitive info like credentials, these values will also be removed from the cached request parameters, body, and headers.
```

(custom-matching)=
## Custom Request Matching
If you need more advanced behavior, you can implement your own custom request matching.

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/security.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(security)=
# Security
# {fa}`lock` Security

## Pickle Vulnerabilities
:::{warning}
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/serializers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(serializers)=
# Serializers
# {fa}`barcode` Serializers
![](../_static/file-pickle_32px.png)
![](../_static/file-json_32px.png)
![](../_static/file-yaml_32px.png)
Expand Down

0 comments on commit eadeb32

Please sign in to comment.