Show docstrings in rendered tables
Closed this issue · 3 comments
Sometimes data classes have docstrings, for the overall class or for individual attributes. It may be useful to be able to show those docstrings.
How the visual design will work is an open question. The tables are currently compact and easy to read—it may require some creativity to add docstrings in a way that don't detract too much from that.
Some new functionality that partially addresses this feature: erdantic now includes the class docstring as a tooltip on the Graphviz graph. This will work for rendered SVG outputs, which you can test out here: https://raw.githubusercontent.com/drivendataorg/erdantic/main/docs/docs/examples/pydantic.svg
Note that raw SVG embeddings can sometimes be used for XSS attacks, so GitHub considers it unsafe and will only render rich SVG displays as an image. This means, for example, the SVG rendered on the README will not be interactive and won't have the tooltips.
Commit that has this all working: d4d735f
@pjbull I think you had asked about docstrings
I am not sure it should be in this issue or if I should create a new one, but it would be interesting for pydantic users to use the Field types and display it in the SVG too. It holds a description that could be fetched instead of the docstrings along with some information, e.g default value.
e.g:
class MyModel(BaseModel):
my_field: Optional[int] = Field(default=1234, description="Long description of the field")
PS: thanks for working on erdantic, it really helps to have such a tool
I'm going to close this issue for now since I don't think there will be any more active work on this. I think the SVG tooltips work okay. Unfortunately, I think rendering docstrings directly in the image is too difficult for these kinds of diagrams. If folks have specific proposals/mockups, post here, we can potentially revisit the topic.
With regards to the pydantic.Field
descriptions, that is addressed in #42 and released in v0.4.0.