Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
4b472947
Commit
4b472947
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: added more customization options to plantuml converter
parent
bd7f3ed7
No related branches found
No related tags found
2 merge requests
!57
RELEASE 0.7.3
,
!52
F refactor high level api
Pipeline
#20083
failed
3 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/utils/plantuml.py
+86
-51
86 additions, 51 deletions
src/caosdb/utils/plantuml.py
with
86 additions
and
51 deletions
src/caosdb/utils/plantuml.py
+
86
−
51
View file @
4b472947
...
...
@@ -41,6 +41,8 @@ from caosdb.common.datatype import is_reference, get_referenced_recordtype
from
typing
import
Optional
import
tempfile
REFERENCE
=
"
REFERENCE
"
...
...
@@ -82,13 +84,23 @@ class Grouped(object):
return
self
.
parents
def
recordtypes_to_plantuml_string
(
iterable
):
def
recordtypes_to_plantuml_string
(
iterable
,
add_properties
:
bool
=
True
,
add_recordtypes
:
bool
=
True
,
add_legend
:
bool
=
True
,
style
:
str
=
"
default
"
):
"""
Converts RecordTypes into a string for PlantUML.
This function obtains an iterable and returns a string which can
be input into PlantUML for a representation of all RecordTypes in
the iterable.
Current options for style
-------------------------
"
default
"
- Standard rectangles with uml class circle and methods section
"
salexan
"
- Round rectangles, hide circle and methods section
Current limitations
-------------------
...
...
@@ -143,10 +155,23 @@ def recordtypes_to_plantuml_string(iterable):
return
result
result
=
"
@startuml
\n\n
"
if
style
==
"
default
"
:
result
+=
"
skinparam classAttributeIconSize 0
\n
"
elif
style
==
"
salexan
"
:
result
+=
"""
skinparam roundcorner 20
\n
skinparam boxpadding 20
\n
\n
hide methods
\n
hide circle
\n
"""
else
:
raise
ValueError
(
"
Unknown style.
"
)
result
+=
"
package Properties #DDDDDD {
\n
"
if
add_properties
:
result
+=
"
package Properties #DDDDDD {
\n
"
for
p
in
properties
:
inheritances
[
p
]
=
p
.
get_parents
()
dependencies
[
p
]
=
[]
...
...
@@ -166,6 +191,7 @@ def recordtypes_to_plantuml_string(iterable):
result
+=
"
}
\n\n
"
result
+=
"
}
\n\n
"
if
add_recordtypes
:
result
+=
"
package RecordTypes #DDDDDD {
\n
"
for
c
in
classes
:
...
...
@@ -203,6 +229,7 @@ def recordtypes_to_plantuml_string(iterable):
result
+=
"
\"
{klass}
\"
*--
\"
{dep}
\"\n
"
.
format
(
klass
=
c
.
name
,
dep
=
dep
)
if
add_legend
:
result
+=
"""
package
\"
B is a subtype of A
\"
<<Rectangle>> {
...
...
@@ -296,7 +323,11 @@ def retrieve_substructure(start_record_types, depth, result_id_set=None, result_
def
to_graphics
(
recordtypes
:
list
[
db
.
Entity
],
filename
:
str
,
output_dirname
:
Optional
[
str
]
=
None
,
formats
:
list
[
str
]
=
[
"
tsvg
"
],
silent
:
bool
=
True
):
silent
:
bool
=
True
,
add_properties
:
bool
=
True
,
add_recordtypes
:
bool
=
True
,
add_legend
:
bool
=
True
,
style
:
str
=
"
default
"
):
"""
Calls recordtypes_to_plantuml_string(), saves result to file and
creates an svg image
...
...
@@ -319,7 +350,11 @@ def to_graphics(recordtypes: list[db.Entity], filename: str,
silent : bool
Don
'
t output messages.
"""
pu
=
recordtypes_to_plantuml_string
(
recordtypes
)
pu
=
recordtypes_to_plantuml_string
(
recordtypes
,
add_properties
,
add_recordtypes
,
add_legend
,
style
)
if
output_dirname
is
None
:
output_dirname
=
os
.
getcwd
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment