Skip to content

Commit

Permalink
Merge pull request #803 from neo4j-contrib/feature/diagram-script
Browse files Browse the repository at this point in the history
Feature/diagram script
  • Loading branch information
mariusconjeaud authored May 28, 2024
2 parents 7ae255b + 380bc1b commit f7dcdb5
Show file tree
Hide file tree
Showing 13 changed files with 1,000 additions and 36 deletions.
18 changes: 18 additions & 0 deletions doc/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ After executing, it will print all indexes and constraints it has removed.
Ommitting the ``--db`` argument will default to the ``NEO4J_BOLT_URL`` environment variable. This is useful for masking
your credentials.

Generate class diagram
======================
You can generate a class diagram of your models using the ``neomodel_generate_diagram`` command::

$ neomodel_generate_diagram models/my_models.py --file-type arrows --write-to-dir img

You must specify a directory in which to lookup neomodel classes (nodes and rels). Typing '.' will search in your whole directory.

You have the option to generate the diagram in different file types using ``--file-type`` : ``arrows``, ``puml`` (which uses the dot notation).

Ommitting the ``--write-to-dir`` option will default to the current directory.

.. note::

Property types and the presence of indexes, constraints and required rules will be displayed on the nodes.

Relationship properties are not supported in the diagram generation.

Create, Update, Delete operations
=================================

Expand Down
5 changes: 5 additions & 0 deletions doc/source/module_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Scripts
:undoc-members:
:show-inheritance:

.. automodule:: neomodel.scripts.neomodel_generate_diagram
:members:
:undoc-members:
:show-inheritance:

.. automodule:: neomodel.scripts.neomodel_install_labels
:members:
:undoc-members:
Expand Down
241 changes: 241 additions & 0 deletions model_diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
{
"style": {
"node-color": "#ffffff",
"border-color": "#000000",
"caption-color": "#000000",
"arrow-color": "#000000",
"label-background-color": "#ffffff",
"directionality": "directed",
"arrow-width": 5
},
"nodes": [
{
"id": "n0",
"position": {
"x": 0,
"y": 0
},
"caption": "",
"style": {},
"labels": [
"Claim"
],
"properties": {
"uid": "str - unique",
"content": "str",
"claim_number": "int",
"embedding": "list[float]"
}
},
{
"id": "n1",
"position": {
"x": 346.4101615137755,
"y": 199.99999999999997
},
"caption": "",
"style": {},
"labels": [
"Inventor"
],
"properties": {
"name": "str - index"
}
},
{
"id": "n2",
"position": {
"x": 2.4492935982947064e-14,
"y": 400.0
},
"caption": "",
"style": {},
"labels": [
"Applicant"
],
"properties": {
"name": "str - index"
}
},
{
"id": "n3",
"position": {
"x": -346.4101615137754,
"y": 200.00000000000014
},
"caption": "",
"style": {},
"labels": [
"Owner"
],
"properties": {
"name": "str - index"
}
},
{
"id": "n4",
"position": {
"x": -346.4101615137755,
"y": -199.99999999999991
},
"caption": "",
"style": {},
"labels": [
"CPC"
],
"properties": {
"symbol": "str - unique"
}
},
{
"id": "n5",
"position": {
"x": -7.347880794884119e-14,
"y": -400.0
},
"caption": "",
"style": {},
"labels": [
"IPCR"
],
"properties": {
"symbol": "str - unique"
}
},
{
"id": "n6",
"position": {
"x": 346.41016151377534,
"y": -200.00000000000017
},
"caption": "",
"style": {},
"labels": [
"Description"
],
"properties": {
"uid": "str - unique",
"content": "str"
}
},
{
"id": "n7",
"position": {
"x": 1146.4101615137754,
"y": 0
},
"caption": "",
"style": {},
"labels": [
"Abstract"
],
"properties": {
"uid": "str - unique",
"content": "str"
}
},
{
"id": "n8",
"position": {
"x": -399.99999999999983,
"y": 692.820323027551
},
"caption": "",
"style": {},
"labels": [
"Patent"
],
"properties": {
"uid": "str - unique",
"docdb_id": "str",
"earliest_claim_date": "date",
"status": "str",
"application_date": "date",
"granted": "str",
"discontinuation_date": "date",
"kind": "str",
"doc_number": "str",
"title": "str",
"grant_date": "date",
"language": "str",
"publication_date": "date",
"doc_key": "str",
"application_number": "str"
}
}
],
"relationships": [
{
"id": "e0",
"type": "HAS_INVENTOR",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n2"
},
{
"id": "e1",
"type": "HAS_APPLICANT",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n3"
},
{
"id": "e2",
"type": "HAS_CPC",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n5"
},
{
"id": "e3",
"type": "HAS_DESCRIPTION",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n7"
},
{
"id": "e4",
"type": "HAS_ABSTRACT",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n8"
},
{
"id": "e5",
"type": "SIMPLE_FAMILY",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n0"
},
{
"id": "e6",
"type": "EXTENDED_FAMILY",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n0"
},
{
"id": "e7",
"type": "HAS_OWNER",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n4"
},
{
"id": "e8",
"type": "HAS_CLAIM",
"style": {},
"properties": {},
"fromId": "n8",
"toId": "n1"
}
]
}
22 changes: 22 additions & 0 deletions model_diagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
digraph G {
node [shape=record];
Patent [label="Patent|{}}"];
Patent -> Inventor [label="has_inventor: RelationshipTo"];
Patent -> Applicant [label="has_applicant: RelationshipTo"];
Patent -> CPC [label="has_cpc: RelationshipTo"];
Patent -> Description [label="has_description: RelationshipTo"];
Patent -> Abstract [label="has_abstract: RelationshipTo"];
Patent -> Patent [label="simple_family: RelationshipTo"];
Patent -> Patent [label="extended_family: RelationshipTo"];
Patent -> Owner [label="has_owner: RelationshipTo"];
Patent -> Claim [label="has_claim: RelationshipTo"];
Claim [label="Claim|{}}"];
Inventor [label="Inventor|{}}"];
Applicant [label="Applicant|{}}"];
Owner [label="Owner|{}}"];
CPC [label="CPC|{}}"];
IPCR [label="IPCR|{}}"];
Description [label="Description|{}}"];
Abstract [label="Abstract|{}}"];
}@enduml
Loading

0 comments on commit f7dcdb5

Please sign in to comment.