Skip to content

Commit df5925f

Browse files
committed
kvs: add rst format to inline docs
Problem: on the web version of the docs, which are auto-generated, multiple lines of python appear on the same line, and are formatted weirdly. Add rst format to the inline docs.
1 parent ff92b52 commit df5925f

File tree

1 file changed

+30
-20
lines changed
  • src/bindings/python/flux

1 file changed

+30
-20
lines changed

src/bindings/python/flux/kvs.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def exists(flux_handle, key, namespace=None):
6161
Args:
6262
flux_handle: A Flux handle obtained from flux.Flux()
6363
key: key to check for existence
64-
65-
Returns:
66-
bool: True if key exists, False if not
6764
namespace: namespace to read from, defaults to None. If namespace
6865
is None, the namespace specified in the FLUX_KVS_NAMESPACE
6966
environment variable will be used. If FLUX_KVS_NAMESPACE is not
7067
set, the primary namespace will be used.
68+
69+
Returns:
70+
bool: True if key exists, False if not
7171
"""
7272
try:
7373
get_key_direct(flux_handle, key, namespace=namespace)
@@ -86,13 +86,13 @@ def isdir(flux_handle, key, namespace=None):
8686
Args:
8787
flux_handle: A Flux handle obtained from flux.Flux()
8888
key: key to check if it is a directory
89-
90-
Returns:
91-
bool: True if key is a directory, False if not
9289
namespace: namespace to read from, defaults to None. If namespace
9390
is None, the namespace specified in the FLUX_KVS_NAMESPACE
9491
environment variable will be used. If FLUX_KVS_NAMESPACE is not
9592
set, the primary namespace will be used.
93+
94+
Returns:
95+
bool: True if key is a directory, False if not
9696
"""
9797
try:
9898
get_key_direct(flux_handle, key, namespace=namespace)
@@ -374,8 +374,12 @@ class KVSTxn:
374374
Can be used as a context manager and commits will be handled at
375375
exit. e.g.
376376
377-
with KVSTxn(handle, "basedirectory") as kt:
378-
kt.put("a", 1)
377+
.. code-block:: python
378+
379+
>>> import flux
380+
>>> flux_handle = flux.Flux()
381+
>>> with KVSTxn(handle, "basedirectory") as kt:
382+
>>> kt.put("a", 1)
379383
380384
Args:
381385
flux_handle: A Flux handle obtained from flux.Flux()
@@ -467,20 +471,27 @@ class KVSDir(WrapperPimpl, abc.MutableMapping):
467471
468472
KVS values can be read or written through this class's item accessor. e.g.
469473
470-
mydir = KVSDir(flux_handle)
471-
print(mydir["mykey"])
474+
.. code-block:: python
472475
473-
mydir["newkey"] = "foo"
474-
mydir.commit()
476+
>>> import flux
477+
>>> flux_handle = flux.Flux()
478+
>>> mydir = KVSDir(flux_handle)
479+
>>> print(mydir["mykey"])
480+
>>> mydir["newkey"] = "foo"
481+
>>> mydir.commit()
475482
476483
Any KVS directories accessed through the item accessor will share
477484
the same internal KVS transaction, so that only a single call to
478485
commit() is necessary. e.g.
479486
480-
mydir = KVSDir(flux_handle)
481-
subdir = mydir["subdir"]
482-
subdir["anotherkey"] = "bar"
483-
mydir.commit()
487+
.. code-block:: python
488+
489+
>>> import flux
490+
>>> flux_handle = flux.Flux()
491+
>>> mydir = KVSDir(flux_handle)
492+
>>> subdir = mydir["subdir"]
493+
>>> subdir["anotherkey"] = "bar"
494+
>>> mydir.commit()
484495
485496
Args:
486497
flux_handle: A Flux handle obtained from flux.Flux()
@@ -495,7 +506,6 @@ class KVSDir(WrapperPimpl, abc.MutableMapping):
495506
# pylint: disable=too-many-ancestors, too-many-public-methods
496507

497508
class InnerWrapper(Wrapper):
498-
499509
# pylint: disable=no-value-for-parameter
500510
def __init__(self, flux_handle=None, path=".", handle=None, namespace=None):
501511
dest = RAW.flux_kvsdir_destroy
@@ -887,9 +897,9 @@ def kvs_watch_async(
887897
detect this as the exact key has not been changed. Defaults to
888898
False.
889899
890-
Returns:
891-
KVSWatchFuture: a KVSWatchFuture object. Call .get() from the then
892-
callback to get the currently returned value from the Future object.
900+
:rtype: :py:obj:`flux.kvs.KVSWatchFuture`
901+
:return: Call .get() from the then callback to
902+
get the currently returned value from the Future object.
893903
"""
894904

895905
flags = flux.constants.FLUX_KVS_WATCH

0 commit comments

Comments
 (0)