Skip to content

Commit cf6fe9d

Browse files
committed
DOC: Update Viewers class docstrings
1 parent 8648b15 commit cf6fe9d

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

itkwidgets/cell_watcher.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import sys
33
from inspect import isawaitable, iscoroutinefunction
4+
from typing import Dict, List
45
from IPython import get_ipython
56
from queue import Queue
67
from imjoy_rpc.utils import FuturePromise
@@ -9,27 +10,64 @@
910

1011

1112
class Viewers(object):
13+
"""This class is designed to track each instance of the Viewer class that
14+
is instantiated as well as whether or not that instance is available for
15+
updates or requests.
16+
"""
1217
def __init__(self):
1318
self._data = {}
1419

1520
@property
16-
def data(self):
21+
def data(self) -> Dict[str, Dict[str, bool]]:
22+
"""Get the underlying data dict containg all viewer data
23+
24+
:return: The data object that contains all created Viewer information.
25+
:rtype: Dict[str, Dict[str, bool]]
26+
"""
1727
return self._data
1828

1929
@property
20-
def not_created(self):
21-
# Return a list of names of viewers that have not been created yet
30+
def not_created(self) -> List[str]:
31+
"""Return a list of all unavailable viewers
32+
33+
:return: A list of names of viewers that have not yet been created.
34+
:rtype: List[str]
35+
"""
2236
return [k for k in self.data.keys() if not self.viewer_ready(k)]
2337

2438
def add_viewer(self, view: str) -> None:
39+
"""Add a new Viewer object to track.
40+
41+
:param view: The unique string identifier for the Viewer object
42+
:type view: str
43+
"""
2544
self.data[view] = {"ready": False}
2645

27-
def update_viewer_status(self, view, status):
46+
def update_viewer_status(self, view: str, status: bool) -> None:
47+
"""Update a Viewer's 'ready' status.
48+
49+
:param view: The unique string identifier for the Viewer object
50+
:type view: str
51+
:param status: Boolean value indicating whether or not the viewer is
52+
available for requests or updates. This should be false when the plugin
53+
API is not yet available or new data is not yet rendered.
54+
:type status: bool
55+
"""
2856
if view not in self.data.keys():
2957
self.add_viewer(view)
3058
self.data[view]["ready"] = status
3159

3260
def viewer_ready(self, view: str) -> bool:
61+
"""Request the 'ready' status of a viewer.
62+
63+
:param view: The unique string identifier for the Viewer object
64+
:type view: str
65+
66+
:return: Boolean value indicating whether or not the viewer is
67+
available for requests or updates. This will be false when the plugin
68+
API is not yet available or new data is not yet rendered.
69+
:rtype: bool
70+
"""
3371
return self.data.get(view, {}).get("ready", False)
3472

3573

0 commit comments

Comments
 (0)