Skip to content

Commit d524709

Browse files
authored
Link Documents for all module commands (#1711)
1 parent 3da0b13 commit d524709

File tree

4 files changed

+181
-87
lines changed

4 files changed

+181
-87
lines changed

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ Contributing
7373
License
7474
*******
7575

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

redis/commands/json/commands.py

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class JSONCommands:
1010
def arrappend(self, name, path=Path.rootPath(), *args):
1111
"""Append the objects ``args`` to the array under the
1212
``path` in key ``name``.
13-
"""
13+
14+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrappend
15+
""" # noqa
1416
pieces = [name, str(path)]
1517
for o in args:
1618
pieces.append(self._encode(o))
@@ -23,7 +25,9 @@ def arrindex(self, name, path, scalar, start=0, stop=-1):
2325
2426
The search can be limited using the optional inclusive ``start``
2527
and exclusive ``stop`` indices.
26-
"""
28+
29+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrindex
30+
""" # noqa
2731
return self.execute_command(
2832
"JSON.ARRINDEX", name, str(path), self._encode(scalar),
2933
start, stop
@@ -32,7 +36,9 @@ def arrindex(self, name, path, scalar, start=0, stop=-1):
3236
def arrinsert(self, name, path, index, *args):
3337
"""Insert the objects ``args`` to the array at index ``index``
3438
under the ``path` in key ``name``.
35-
"""
39+
40+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrinsert
41+
""" # noqa
3642
pieces = [name, str(path), index]
3743
for o in args:
3844
pieces.append(self._encode(o))
@@ -41,45 +47,64 @@ def arrinsert(self, name, path, index, *args):
4147
def arrlen(self, name, path=Path.rootPath()):
4248
"""Return the length of the array JSON value under ``path``
4349
at key``name``.
44-
"""
50+
51+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrlen
52+
""" # noqa
4553
return self.execute_command("JSON.ARRLEN", name, str(path))
4654

4755
def arrpop(self, name, path=Path.rootPath(), index=-1):
4856
"""Pop the element at ``index`` in the array JSON value under
4957
``path`` at key ``name``.
50-
"""
58+
59+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrpop
60+
""" # noqa
5161
return self.execute_command("JSON.ARRPOP", name, str(path), index)
5262

5363
def arrtrim(self, name, path, start, stop):
5464
"""Trim the array JSON value under ``path`` at key ``name`` to the
5565
inclusive range given by ``start`` and ``stop``.
56-
"""
66+
67+
For more information: https://oss.redis.com/redisjson/commands/#jsonarrtrim
68+
""" # noqa
5769
return self.execute_command("JSON.ARRTRIM", name, str(path),
5870
start, stop)
5971

6072
def type(self, name, path=Path.rootPath()):
61-
"""Get the type of the JSON value under ``path`` from key ``name``."""
73+
"""Get the type of the JSON value under ``path`` from key ``name``.
74+
75+
For more information: https://oss.redis.com/redisjson/commands/#jsontype
76+
""" # noqa
6277
return self.execute_command("JSON.TYPE", name, str(path))
6378

6479
def resp(self, name, path=Path.rootPath()):
65-
"""Return the JSON value under ``path`` at key ``name``."""
80+
"""Return the JSON value under ``path`` at key ``name``.
81+
82+
For more information: https://oss.redis.com/redisjson/commands/#jsonresp
83+
""" # noqa
6684
return self.execute_command("JSON.RESP", name, str(path))
6785

6886
def objkeys(self, name, path=Path.rootPath()):
6987
"""Return the key names in the dictionary JSON value under ``path`` at
70-
key ``name``."""
88+
key ``name``.
89+
90+
For more information: https://oss.redis.com/redisjson/commands/#jsonobjkeys
91+
""" # noqa
7192
return self.execute_command("JSON.OBJKEYS", name, str(path))
7293

7394
def objlen(self, name, path=Path.rootPath()):
7495
"""Return the length of the dictionary JSON value under ``path`` at key
7596
``name``.
76-
"""
97+
98+
For more information: https://oss.redis.com/redisjson/commands/#jsonobjlen
99+
""" # noqa
77100
return self.execute_command("JSON.OBJLEN", name, str(path))
78101

79102
def numincrby(self, name, path, number):
80103
"""Increment the numeric (integer or floating point) JSON value under
81104
``path`` at key ``name`` by the provided ``number``.
82-
"""
105+
106+
For more information: https://oss.redis.com/redisjson/commands/#jsonnumincrby
107+
""" # noqa
83108
return self.execute_command(
84109
"JSON.NUMINCRBY", name, str(path), self._encode(number)
85110
)
@@ -88,7 +113,9 @@ def numincrby(self, name, path, number):
88113
def nummultby(self, name, path, number):
89114
"""Multiply the numeric (integer or floating point) JSON value under
90115
``path`` at key ``name`` with the provided ``number``.
91-
"""
116+
117+
For more information: https://oss.redis.com/redisjson/commands/#jsonnummultby
118+
""" # noqa
92119
return self.execute_command(
93120
"JSON.NUMMULTBY", name, str(path), self._encode(number)
94121
)
@@ -100,11 +127,16 @@ def clear(self, name, path=Path.rootPath()):
100127
101128
Return the count of cleared paths (ignoring non-array and non-objects
102129
paths).
103-
"""
130+
131+
For more information: https://oss.redis.com/redisjson/commands/#jsonclear
132+
""" # noqa
104133
return self.execute_command("JSON.CLEAR", name, str(path))
105134

106135
def delete(self, key, path=Path.rootPath()):
107-
"""Delete the JSON value stored at key ``key`` under ``path``."""
136+
"""Delete the JSON value stored at key ``key`` under ``path``.
137+
138+
For more information: https://oss.redis.com/redisjson/commands/#jsondel
139+
"""
108140
return self.execute_command("JSON.DEL", key, str(path))
109141

110142
# forget is an alias for delete
@@ -117,7 +149,9 @@ def get(self, name, *args, no_escape=False):
117149
``args`` is zero or more paths, and defaults to root path
118150
```no_escape`` is a boolean flag to add no_escape option to get
119151
non-ascii characters
120-
"""
152+
153+
For more information: https://oss.redis.com/redisjson/commands/#jsonget
154+
""" # noqa
121155
pieces = [name]
122156
if no_escape:
123157
pieces.append("noescape")
@@ -140,7 +174,9 @@ def mget(self, keys, path):
140174
"""
141175
Get the objects stored as a JSON values under ``path``. ``keys``
142176
is a list of one or more keys.
143-
"""
177+
178+
For more information: https://oss.redis.com/redisjson/commands/#jsonmget
179+
""" # noqa
144180
pieces = []
145181
pieces += keys
146182
pieces.append(str(path))
@@ -157,6 +193,8 @@ def set(self, name, path, obj, nx=False, xx=False, decode_keys=False):
157193
158194
For the purpose of using this within a pipeline, this command is also
159195
aliased to jsonset.
196+
197+
For more information: https://oss.redis.com/redisjson/commands/#jsonset
160198
"""
161199
if decode_keys:
162200
obj = decode_dict_keys(obj)
@@ -178,7 +216,9 @@ def set(self, name, path, obj, nx=False, xx=False, decode_keys=False):
178216
def strlen(self, name, path=None):
179217
"""Return the length of the string JSON value under ``path`` at key
180218
``name``.
181-
"""
219+
220+
For more information: https://oss.redis.com/redisjson/commands/#jsonstrlen
221+
""" # noqa
182222
pieces = [name]
183223
if path is not None:
184224
pieces.append(str(path))
@@ -187,14 +227,18 @@ def strlen(self, name, path=None):
187227
def toggle(self, name, path=Path.rootPath()):
188228
"""Toggle boolean value under ``path`` at key ``name``.
189229
returning the new value.
190-
"""
230+
231+
For more information: https://oss.redis.com/redisjson/commands/#jsontoggle
232+
""" # noqa
191233
return self.execute_command("JSON.TOGGLE", name, str(path))
192234

193235
def strappend(self, name, value, path=Path.rootPath()):
194236
"""Append to the string JSON value. If two options are specified after
195237
the key name, the path is determined to be the first. If a single
196238
option is passed, then the rootpath (i.e Path.rootPath()) is used.
197-
"""
239+
240+
For more information: https://oss.redis.com/redisjson/commands/#jsonstrappend
241+
""" # noqa
198242
pieces = [name, str(path), self._encode(value)]
199243
return self.execute_command(
200244
"JSON.STRAPPEND", *pieces
@@ -203,7 +247,9 @@ def strappend(self, name, value, path=Path.rootPath()):
203247
def debug(self, subcommand, key=None, path=Path.rootPath()):
204248
"""Return the memory usage in bytes of a value under ``path`` from
205249
key ``name``.
206-
"""
250+
251+
For more information: https://oss.redis.com/redisjson/commands/#jsondebg
252+
""" # noqa
207253
valid_subcommands = ["MEMORY", "HELP"]
208254
if subcommand not in valid_subcommands:
209255
raise DataError("The only valid subcommands are ",

0 commit comments

Comments
 (0)