Skip to content

Commit 17a5e82

Browse files
committed
Update VitessceWidget docs
1 parent 1ed2b2f commit 17a5e82

File tree

4 files changed

+50
-20
lines changed

4 files changed

+50
-20
lines changed

docs/api_config.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ vitessce.config
1919
:exclude-members: VitessceConfig, VitessceChainableConfig
2020
:member-order: bysource
2121

22+
vitessce.widget
23+
***************
24+
25+
.. autoclass:: vitessce.widget.VitessceWidget()
26+
:members:
27+
:private-members:
28+
:exclude-members: close
29+
30+
.. autoclass:: vitessce.widget.VitesscePlugin
31+
:members:
32+
2233
vitessce.constants
2334
******************
2435

docs/api_data.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ vitessce.wrappers
1919
:members:
2020

2121
vitessce.export
22-
*****************
22+
***************
2323

2424
.. automodule:: vitessce.export
2525
:members:
2626

2727
vitessce.data_utils
28-
*****************
28+
*******************
2929

3030
.. automodule:: vitessce.data_utils.ome
3131
:members:

src/vitessce/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,17 @@ def widget(self, **kwargs):
17911791
:param int height: The height of the widget, in pixels. By default, 600.
17921792
:param int port: The port to use when serving data objects on localhost. By default, 8000.
17931793
:param bool proxy: Is this widget being served through a proxy, for example with a cloud notebook (e.g. Binder)?
1794+
:param str js_package_version: The version of the NPM package ('vitessce' if not js_dev_mode else '@vitessce/dev').
1795+
:param bool js_dev_mode: Should @vitessce/dev be used (typically for debugging purposes)? By default, False.
1796+
:param str custom_js_url: A URL to a JavaScript file to use (instead of 'vitessce' or '@vitessce/dev' NPM package).
1797+
:param list[VitesscePlugin] plugins: A list of subclasses of VitesscePlugin. Optional.
1798+
:param bool remount_on_uid_change: Passed to the remountOnUidChange prop of the <Vitessce/> React component. By default, True.
1799+
:param bool prefer_local: Should local data be preferred (only applies to `*_artifact` data objects)? By default, True.
1800+
:param int invoke_timeout: The timeout in milliseconds for invoking Python functions from JavaScript. By default, 300000.
1801+
:param bool invoke_batched: Should invocations (Zarr gets) be submitted in batch, or individually? By default, True.
1802+
:param bool page_mode: Whether to render the <Vitessce/> component in grid-mode or page-mode. By default, False.
1803+
:param str page_esm: The ES module string for the page component creation function. Optional.
1804+
:param bool prevent_scroll: Should mouseover in the Vitessce widget prevent disable the scrolling of the notebook? By default, True.
17941805
17951806
:returns: The Jupyter widget.
17961807
:rtype: VitessceWidget

src/vitessce/widget.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,12 @@ class VitesscePlugin:
597597
"""
598598
A class that represents a Vitessce widget plugin. Custom plugins can be created by subclassing this class.
599599
"""
600-
plugin_esm = DEFAULT_PLUGIN_ESM
601-
commands = {}
600+
601+
#: The ES module string for the plugin.
602+
plugin_esm = DEFAULT_PLUGIN_ESM # type: str
603+
604+
#: A dictionary mapping command name strings to functions. Functions should take two arguments (message, buffers) and return a tuple (response, buffers).
605+
commands = {} # type: dict
602606

603607
def on_config_change(self, new_config):
604608
"""
@@ -614,19 +618,29 @@ def on_config_change(self, new_config):
614618

615619
class VitessceWidget(anywidget.AnyWidget):
616620
"""
617-
A class to represent a Jupyter widget for Vitessce.
621+
A class to represent a Jupyter widget for Vitessce. Not intended to be instantiated directly; instead, use ``VitessceConfig.widget``.
622+
623+
.. code-block:: python
624+
:emphasize-lines: 4
625+
626+
from vitessce import VitessceConfig
627+
628+
vc = VitessceConfig.from_object(my_scanpy_object)
629+
vw = vc.widget()
630+
vw
618631
"""
619632
_esm = ESM
620633

621634
# Widget specific property.
622635
# Widget properties are defined as traitlets. Any property tagged with `sync=True`
623636
# is automatically synced to the frontend *any* time it changes in Python.
624637
# It is synced back to Python from the frontend *any* time the model is touched.
625-
_config = Dict({}).tag(sync=True)
626-
"""dict: Dictionary representation of the Vitessce JSON configuration. Synced via traitlets upon interactions."""
638+
639+
#: Dictionary representation of the Vitessce JSON configuration. Synced via traitlets upon interactions.
640+
_config = Dict({}).tag(sync=True) # type: dict
627641

628-
config = None
629-
"""VitessceConfig: The VitessceConfig instance used to create this widget. Not synced upon interactions."""
642+
#: The VitessceConfig instance used to create this widget. Not synced upon interactions.
643+
config = None # type: vitessce.config.VitessceConfig
630644

631645
height = Int(600).tag(sync=True)
632646
theme = Unicode('auto').tag(sync=True)
@@ -650,9 +664,10 @@ class VitessceWidget(anywidget.AnyWidget):
650664
store_urls = List(trait=Unicode(''), default_value=[]).tag(sync=True)
651665

652666
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.12', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, prefer_local=True, invoke_timeout=300000, invoke_batched=True, page_mode=False, page_esm=None, prevent_scroll=True):
667+
""" """
653668
"""
654-
Construct a new Vitessce widget.
655-
669+
Construct a new Vitessce widget. Not intended to be instantiated directly; instead, use ``VitessceConfig.widget``.
670+
656671
:param config: A view config instance.
657672
:type config: VitessceConfig
658673
:param str theme: The theme name, either "light" or "dark". By default, "auto", which selects light or dark based on operating system preferences.
@@ -671,14 +686,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
671686
:param str page_esm: The ES module string for the page component creation function. Optional.
672687
:param bool prevent_scroll: Should mouseover in the Vitessce widget prevent disable the scrolling of the notebook? By default, True.
673688
674-
.. code-block:: python
675-
:emphasize-lines: 4
676-
677-
from vitessce import VitessceConfig, VitessceWidget
678-
679-
vc = VitessceConfig.from_object(my_scanpy_object)
680-
vw = vc.widget()
681-
vw
689+
Note: these parameter docstrings need to be manually kept in sync with the VitessceConfig.widget docstring.
682690
"""
683691

684692
base_url, use_port, VitessceWidget.next_port = get_base_url_and_port(
@@ -817,7 +825,7 @@ def ipython_display(config, height=600, theme='auto', base_url=None, host_name=N
817825
"has_host_name": host_name is not None,
818826
"height": height,
819827
"theme": theme,
820-
"config": config_dict,
828+
"_config": config_dict,
821829
"store_urls": [],
822830
}
823831

0 commit comments

Comments
 (0)