drivendataorg/erdantic

PlantUML generation?

swails opened this issue · 4 comments

When I stumbled on this project, what I was really looking for was a way to generate an ERD in PlantUML. I've implemented that for personal use, but I'm happy to contribute the work back if it would be considered for inclusion. The changes are quite small.

This was a remarkably easy code base to grok and dig into, so kudos on a useful project!

jayqi commented

Hi @swails, thank you for the positive feedback! Being able to support PlantUML does sound useful. I'd be interested in seeing your implementation to better understand the complexity, what additional dependencies might be introduced, etc. Based on that, I think we can figure out if and how integrating it makes sense.

I took a stab at hand-writing the PlantUML spec for the classes in erdantic.examples.

@startuml

map Party {
 name => str
 formed_datetime => datetime
 members => List[Adventurer]
 active_quest => Optional[Quest]
}

map Adventurer {
 name => str 
 profession => str
 alignment => Alignment
 level => int
}

map Quest {
 name => str
 giver => QuestGiver
 reward_gold => int
}

map QuestGiver {
 name => str
 faction => Optional[str]
 location => str
}

Party::members -{ Adventurer::Adventurer
Party::active_quest -o| Quest::Quest
Quest::giver -|| QuestGiver::QuestGiver
@enduml

Using this web editor, I got a rendered diagram like this:

plantuml_example

This doesn't look production-ready to me. I'm not that familiar with PlantUML, so it would be great to have someone who knows PlantUML better to figure out how to get the output to look nicer (e.g., layout, where edges connect up to).

Ah, here were the changes I made way back when: main...swails:erdantic:feature/plantuml-diagrams

It looks like the code base has changed substantially since I did that, but this worked for me.

@swails do you have an example of the output PlantUML spec you created?

The code base has indeed changed substantially, though this happened fairly recently. See v1.0.0rc1. It generally shouldn't be too hard to figure out equivalent changes under the new backend design though.