Skip to content

Commit 8ef82d2

Browse files
authored
Merge pull request #73 from neo4j/document-render-layout-options
Document fields in ref-docs
2 parents 36ec74b + f7133b1 commit 8ef82d2

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

docs/source/api-reference/node.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.. autoclass:: neo4j_viz.Node
22
:members:
3+
:exclude-members: model_config
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.. autoclass:: neo4j_viz.Relationship
22
:members:
3+
:exclude-members: model_config

docs/source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
# -- Options for notebook extension -------------------------------------------
3232
nbsphinx_execute = "never"
3333

34+
# -- Options for autodoc extension -------------------------------------------
35+
autodoc_typehints = "description"
36+
37+
3438
# -- Options for HTML output -------------------------------------------------
3539
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3640

python-wrapper/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies = [
3434
"ipython >=8, <9",
3535
"pydantic >=2 , <3",
3636
"pydantic-extra-types >=2, <3",
37+
"enum-tools==0.12.0"
3738
]
3839
requires-python = ">=3.9"
3940

python-wrapper/src/neo4j_viz/node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,33 @@ class Node(BaseModel, extra="allow"):
1717
All options available in the NVL library (see https://neo4j.com/docs/nvl/current/base-library/#_nodes)
1818
"""
1919

20+
#: Unique identifier for the node
2021
id: NodeIdType = Field(
2122
validation_alias=AliasChoices("id", "nodeId", "node_id"), description="Unique identifier for the node"
2223
)
24+
#: The caption of the node
2325
caption: Optional[str] = Field(None, description="The caption of the node")
26+
#: The alignment of the caption text
2427
caption_align: Optional[CaptionAlignment] = Field(
2528
None, serialization_alias="captionAlign", description="The alignment of the caption text"
2629
)
30+
#: The size of the caption text. The font size to node radius ratio
2731
caption_size: Optional[int] = Field(
2832
None,
2933
ge=1,
3034
le=3,
3135
serialization_alias="captionSize",
3236
description="The size of the caption text. The font size to node radius ratio",
3337
)
38+
#: The size of the node as radius in pixel
3439
size: Optional[RealNumber] = Field(None, ge=0, description="The size of the node as radius in pixel")
40+
#: The color of the node
3541
color: Optional[ColorType] = Field(None, description="The color of the node")
42+
#: Whether the node is pinned in the visualization
3643
pinned: Optional[bool] = Field(None, description="Whether the node is pinned in the visualization")
44+
#: The x-coordinate of the node
3745
x: Optional[RealNumber] = Field(None, description="The x-coordinate of the node")
46+
#: The y-coordinate of the node
3847
y: Optional[RealNumber] = Field(None, description="The y-coordinate of the node")
3948

4049
@field_serializer("color")

python-wrapper/src/neo4j_viz/options.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,36 @@
44
from enum import Enum
55
from typing import Any, Optional
66

7+
import enum_tools.documentation
78
from pydantic import BaseModel, Field
89

910

11+
@enum_tools.documentation.document_enum
1012
class CaptionAlignment(str, Enum):
13+
"""
14+
The alignment of the caption text for nodes and relationships.
15+
"""
16+
1117
TOP = "top"
1218
CENTER = "center"
1319
BOTTOM = "bottom"
1420

1521

22+
@enum_tools.documentation.document_enum
1623
class Layout(str, Enum):
1724
FORCE_DIRECTED = "forcedirected"
1825
HIERARCHICAL = "hierarchical"
19-
GRID = "grid"
26+
"""
27+
The nodes are then arranged by the directionality of their relationships
28+
"""
2029
COORDINATE = "free"
21-
""""
30+
"""
2231
The coordinate layout sets the position of each node based on the `x` and `y` properties of the node.
2332
"""
33+
GRID = "grid"
2434

2535

36+
@enum_tools.documentation.document_enum
2637
class Renderer(str, Enum):
2738
"""
2839
The renderer used to render the visualization.

python-wrapper/src/neo4j_viz/relationship.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,33 @@ class Relationship(BaseModel, extra="allow"):
1515
All options available in the NVL library (see https://neo4j.com/docs/nvl/current/base-library/#_relationships)
1616
"""
1717

18+
#: Unique identifier for the relationship
1819
id: Union[str, int] = Field(
1920
default_factory=lambda: uuid4().hex, description="Unique identifier for the relationship"
2021
)
22+
#: Node ID where the relationship points from
2123
source: Union[str, int] = Field(
2224
serialization_alias="from",
2325
validation_alias=AliasChoices("source", "sourceNodeId", "source_node_id", "from"),
2426
description="Node ID where the relationship points from",
2527
)
28+
#: Node ID where the relationship points to
2629
target: Union[str, int] = Field(
2730
serialization_alias="to",
2831
validation_alias=AliasChoices("target", "targetNodeId", "target_node_id", "to"),
2932
description="Node ID where the relationship points to",
3033
)
34+
#: The caption of the relationship
3135
caption: Optional[str] = Field(None, description="The caption of the relationship")
36+
#: The alignment of the caption text
3237
caption_align: Optional[CaptionAlignment] = Field(
3338
None, serialization_alias="captionAlign", description="The alignment of the caption text"
3439
)
40+
#: The size of the caption text
3541
caption_size: Optional[Union[int, float]] = Field(
3642
None, gt=0.0, serialization_alias="captionSize", description="The size of the caption text"
3743
)
44+
#: The color of the relationship
3845
color: Optional[ColorType] = Field(None, description="The color of the relationship")
3946

4047
@field_serializer("color")

python-wrapper/src/neo4j_viz/visualization_graph.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Optional
66

77
from IPython.display import HTML
8-
from pydantic import BaseModel, Field
98
from pydantic_extra_types.color import Color, ColorType
109

1110
from .colors import ColorsType, neo4j_colors
@@ -16,13 +15,29 @@
1615
from .relationship import Relationship
1716

1817

19-
class VisualizationGraph(BaseModel):
18+
class VisualizationGraph:
2019
"""
2120
A graph to visualize.
2221
"""
2322

24-
nodes: list[Node] = Field(description="The nodes in the graph")
25-
relationships: list[Relationship] = Field(description="The relationships in the graph")
23+
#: "The nodes in the graph"
24+
nodes: list[Node]
25+
#: "The relationships in the graph"
26+
relationships: list[Relationship]
27+
28+
def __init__(self, nodes: list[Node], relationships: list[Relationship]) -> None:
29+
""" "
30+
Create a new `VisualizationGraph`.
31+
32+
Parameters
33+
----------
34+
nodes:
35+
The nodes in the graph.
36+
relationships:
37+
The relationships in the graph.
38+
"""
39+
self.nodes = nodes
40+
self.relationships = relationships
2641

2742
def render(
2843
self,

0 commit comments

Comments
 (0)