Skip to content

Commit f4519f3

Browse files
authored
Splitting documentation for read the docs (#1743)
1 parent 393cd62 commit f4519f3

16 files changed

+209
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Python interface to the Redis key-value store.
99
[![codecov](https://codecov.io/gh/redis/redis-py/branch/master/graph/badge.svg?token=yenl5fzxxr)](https://codecov.io/gh/redis/redis-py)
1010
[![Total alerts](https://img.shields.io/lgtm/alerts/g/redis/redis-py.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/redis/redis-py/alerts/)
1111

12-
[Installation](##installation) | [Contributing](##contributing) | [Getting Started](##getting-started) | [Connecting To Redis](##connecting-to-redis)
12+
[Installation](#installation) | [Contributing](#contributing) | [Getting Started](#getting-started) | [Connecting To Redis](#connecting-to-redis)
1313

1414
---------------------------------------------
1515

docs/backoff.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Backoff
2+
#############
3+
4+
.. automodule:: redis.backoff
5+
:members:

docs/conf.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
extensions = [
3030
"sphinx.ext.autodoc",
3131
"sphinx.ext.doctest",
32-
"sphinx.ext.viewcode"
32+
"sphinx.ext.viewcode",
33+
"sphinx.ext.autosectionlabel",
3334
]
3435

3536
# Add any paths that contain templates here, relative to this directory.
@@ -53,10 +54,11 @@
5354
# built documents.
5455
#
5556
# The short X.Y version.
56-
version = "4.0"
57+
import redis
58+
version = '.'.join(redis.__version__.split(".")[0:2])
5759

5860
# The full version, including alpha/beta/rc tags.
59-
release = "4.0.0"
61+
release = redis.__version__
6062

6163
# The language for content autogenerated by Sphinx. Refer to documentation
6264
# for a list of supported languages.
@@ -93,17 +95,27 @@
9395
# A list of ignored prefixes for module index sorting.
9496
# modindex_common_prefix = []
9597

98+
nitpicky = True
99+
96100

97101
# -- Options for HTML output --------------------------------------------------
98102

99103
# The theme to use for HTML and HTML Help pages. See the documentation for
100104
# a list of builtin themes.
101-
html_theme = "default"
105+
html_theme = "sphinx_rtd_theme"
102106

103107
# Theme options are theme-specific and customize the look and feel of a theme
104108
# further. For a list of options available for each theme, see the
105109
# documentation.
106-
# html_theme_options = {}
110+
html_theme_options = {
111+
'display_version': True,
112+
'prev_next_buttons_location': 'bottom',
113+
'style_external_links': False,
114+
# Toc options
115+
'collapse_navigation': True,
116+
'sticky_navigation': True,
117+
'navigation_depth': 4,
118+
}
107119

108120
# Add any paths that contain custom themes here, relative to this directory.
109121
# html_theme_path = []

docs/connections.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Connecting to Redis
2+
#####################
3+
4+
Generic Client
5+
**************
6+
.. autoclass:: redis.client.Redis
7+
:members:
8+
9+
Connection Pools
10+
*****************
11+
.. autoclass:: redis.connection.ConnectionPool
12+
:members:

docs/exceptions.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
Exceptions
4+
##########
5+
6+
.. automodule:: redis.exceptions
7+
:members:

docs/genindex.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Module Index
2+
============

docs/index.rst

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,71 @@
66
Welcome to redis-py's documentation!
77
====================================
88

9-
Indices and tables
10-
------------------
9+
Getting Started
10+
****************
1111

12-
* :ref:`genindex`
13-
* :ref:`modindex`
14-
* :ref:`search`
12+
`redis-py <https://pypi.org/project/redis>`_ requires a running Redis server, and Python 3.6+. See the `Redis
13+
quickstart <https://redis.io/topics/quickstart>`_ for Redis installation instructions.
1514

16-
Contents:
17-
---------
15+
redis-py can be installed using pip via ``pip install redis``.
16+
17+
18+
Quickly connecting to redis
19+
************
20+
21+
There are two quick ways to connect to Redis.
22+
23+
Assuming you run Redis on localhost:6379 (the default)::
24+
import redis
25+
r = redis.Redis()
26+
r.ping()
27+
28+
Running redis on foo.bar.com, port 12345::
29+
import redis
30+
r = redis.Redis(host='foo.bar.com', port=12345)
31+
r.ping()
32+
33+
Another example with foo.bar.com, port 12345::
34+
import redis
35+
r = redis.from_url('redis://foo.bar.com:12345')
36+
r.ping()
37+
38+
After that, you probably want to `run redis commands <redis_core_commands.html>`_.
1839

1940
.. toctree::
20-
:maxdepth: 2
41+
:hidden:
42+
43+
genindex
2144

22-
.. automodule:: redis
23-
:members:
45+
Redis Command Functions
46+
***********************
47+
.. toctree::
48+
:maxdepth: 2
2449

25-
.. automodule:: redis.backoff
26-
:members:
50+
redis_core_commands
51+
sentinel_commands
52+
redismodules
2753

28-
.. automodule:: redis.connection
29-
:members:
54+
Module Documentation
55+
********************
56+
.. toctree::
57+
:maxdepth: 1
3058

31-
.. automodule:: redis.commands
32-
:members:
59+
backoff
60+
connections
61+
exceptions
62+
lock
63+
retry
3364

34-
.. automodule:: redis.exceptions
35-
:members:
65+
Contributing
66+
*************
3667

37-
.. automodule:: redis.lock
38-
:members:
68+
- `How to contribute <https://github.com/redis/redis-py/blob/master/CONTRIBUTING.md>`_
69+
- `Issue Tracker <https://github.com/redis/redis-py/issues>`_
70+
- `Source Code <https://github.com/redis/redis-py/>`_
71+
- `Release History <https://github.com/redis/redis-py/releases/>`_
3972

40-
.. automodule:: redis.sentinel
41-
:members:
73+
License
74+
*******
4275

76+
This projectis licensed under the `MIT license <https://github.com/redis/redis-py/blob/master/LICENSE>`_.

docs/lock.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Lock
2+
#########
3+
4+
.. automodule:: redis.lock
5+
:members:

docs/redis_core_commands.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Redis Core Commands
2+
####################
3+
4+
The following functions can be used to replicate their equivalent `Redis command <https://redis.io/commands>`_. Generally they can be used as functions on your redis connection. For the simplest example, see below:
5+
6+
Getting and settings data in redis::
7+
8+
import redis
9+
r = redis.Redis(decode_responses=True)
10+
r.set('mykey', 'thevalueofmykey')
11+
r.get('mykey')
12+
13+
.. autoclass:: redis.commands.core.CoreCommands
14+
:members:

docs/redismodules.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Redis Modules Commands
2+
######################
3+
4+
Accessing redis module commands requires the installation of the supported `Redis module <https://docs.redis.com/latest/modules/>`_. For a quick start with redis modules, try the `Redismod docker <https://hub.docker.com/r/redislabs/redismod>`_.
5+
6+
RedisTimeSeries Commands
7+
************************
8+
.. automodule:: redis.commands.timeseries.commands
9+
:members: TimeSeriesCommands
10+
11+
RedisJSON Commands
12+
******************
13+
.. automodule:: redis.commands.json.commands
14+
:members: JSONCommands
15+
16+
RediSearch Commands
17+
*******************
18+
.. automodule:: redis.commands.search.commands
19+
:members: SearchCommands

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
sphinx<2
22
docutils<0.18
3+
sphinx-rtd-theme

docs/retry.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Retry Helpers
2+
#############
3+
4+
.. automodule:: redis.retry
5+
:members:

docs/sentinel_commands.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Redis Sentinel Commands
2+
=======================
3+
4+
redis-py can be used together with `Redis
5+
Sentinel <https://redis.io/topics/sentinel>`_ to discover Redis nodes. You
6+
need to have at least one Sentinel daemon running in order to use
7+
redis-py's Sentinel support.
8+
9+
Connection example (assumes redis redis on the ports listed below):
10+
11+
>>> from redis import Sentinel
12+
>>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
13+
>>> sentinel.discover_master('mymaster')
14+
('127.0.0.1', 6379)
15+
>>> sentinel.discover_slaves('mymaster')
16+
[('127.0.0.1', 6380)]
17+
18+
19+
.. autoclass:: redis.commands.sentinel.SentinelCommands
20+
:members:

0 commit comments

Comments
 (0)