diff --git a/_docs/templates/_npe2_writers_guide.md.jinja b/_docs/templates/_npe2_writers_guide.md.jinja index 34c91652..1f5b1a13 100644 --- a/_docs/templates/_npe2_writers_guide.md.jinja +++ b/_docs/templates/_npe2_writers_guide.md.jinja @@ -58,7 +58,7 @@ by the corresponding writer contribution in the manifest). ```python DataType = Any # usually something like a numpy array, but varies by layer LayerAttributes = dict - LayerName = Literal["image", "labels", "points", "shapes", "surface", "tracks", "vectors"] + LayerName = Literal["graph", "image", "labels", "points", "shapes", "surface", "tracks", "vectors"] FullLayerData = Tuple[DataType, LayerAttributes, LayerName] MultiWriterFunction = Callable[[str, List[FullLayerData]], List[str]] ``` diff --git a/src/npe2/_inspection/_visitors.py b/src/npe2/_inspection/_visitors.py index 0af21357..9aa6b75c 100644 --- a/src/npe2/_inspection/_visitors.py +++ b/src/npe2/_inspection/_visitors.py @@ -235,6 +235,9 @@ def napari_get_writer(self, node: ast.FunctionDef): # we can't convert this to an npe2 command contribution pass # pragma: no cover + def napari_write_graph(self, node: ast.FunctionDef): + self._parse_writer(node, "graph") # pragma: no cover + def napari_write_image(self, node: ast.FunctionDef): self._parse_writer(node, "image") diff --git a/src/npe2/manifest/contributions/_writers.py b/src/npe2/manifest/contributions/_writers.py index 27d61b1e..395e6fc7 100644 --- a/src/npe2/manifest/contributions/_writers.py +++ b/src/npe2/manifest/contributions/_writers.py @@ -7,6 +7,7 @@ class LayerType(str, Enum): + graph = "graph" image = "image" labels = "labels" points = "points" diff --git a/src/npe2/types.py b/src/npe2/types.py index b81639da..3f649005 100644 --- a/src/npe2/types.py +++ b/src/npe2/types.py @@ -46,7 +46,7 @@ def __array__(self) -> "np.ndarray": LayerName = Literal[ - "image", "labels", "points", "shapes", "surface", "tracks", "vectors" + "graph", "image", "labels", "points", "shapes", "surface", "tracks", "vectors" ] Metadata = Dict DataType = Union[ArrayLike, Sequence[ArrayLike]] diff --git a/tests/conftest.py b/tests/conftest.py index d7c7991b..ed669df2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -118,6 +118,7 @@ class HookSpecs: def napari_provide_sample_data(): ... # type: ignore def napari_get_reader(path): ... def napari_get_writer(path, layer_types): ... + def napari_write_graph(path, data, meta): ... def napari_write_image(path, data, meta): ... def napari_write_labels(path, data, meta): ... def napari_write_points(path, data, meta): ...