8000 Add mermaid file export functionality by Mahad-lab · Pull Request #145 · eralchemy/eralchemy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add mermaid file export functionality #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mahad-lab
Copy link
Contributor

Currently, the Mermaid diagrams are exported into a Markdown file as comments and rendered as images using the mermaid.ink link.
I have now implemented a feature to export the Mermaid diagrams into a Markdown file with the mode="mermaid_plain" parameter.

Copy link
Collaborator
@maurerle maurerle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution.

Can you maybe clarify the use case of the plain method?
I don't see the added value, as you typically want to copy from the output to something else anyway..?

I don't like that this copies the content of forum.py.
One could use from forum import Base instead.

Or just provide an (additional) CLI mode flag and just add a cli example.

@maurerle
Copy link
Collaborator
maurerle commented Dec 8, 2024

A valid usage would be to save the database to .mmd and then post-process with mermaid-cli:
https://github.com/mermaid-js/mermaid-cli?tab=readme-ov-file#usage

Then we should add it for this export format as well in

eralchemy/eralchemy/main.py

Lines 231 to 235 in b036a16

switch_output_mode = {
"er": intermediary_to_markdown,
"md": intermediary_to_mermaid,
"dot": intermediary_to_dot,
}

@Mahad-lab
Copy link
Contributor Author
Mahad-lab commented Dec 8, 2024

Can you maybe clarify the use case of the plain method? I don't see the added value, as you typically want to copy from the output to something else anyway..?

I need to have ER Diagram as a markdown file in documentation. It is because it can easily rendered in github markdown. The markdown file is easier to do quick changes and preview it instead of an image.

I don't like that this copies the content of forum.py. One could use from forum import Base instead.

That was my mistake I had fixed it

Copy link
Contributor Author
@Mahad-lab Mahad-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove code duplication

@rbange
Copy link
rbange commented Dec 8, 2024

Use Case wise I would also like to regular refresh the image in ci. No need to embed it into another markdown. Linking is just fine.

@Mahad-lab
Copy link
Contributor Author

A valid usage would be to save the database to .mmd and then post-process with mermaid-cli: https://github.com/mermaid-js/mermaid-cli?tab=readme-ov-file#usage

.mmd is not widely used as .md and github have a built-in support for mermaid. This is the one of the reason to export mermaid into markdown (use it locally). Second we will be able to do edits directly into mermaid (markdown) and preview it.

@maurerle
Copy link
Collaborator

I am still quite unsure if @rbange has the same use-case as @Mahad-lab.
If I understand correctly, deploying a picture/graphic of the mermaid output in a second step would be fine, so

A valid usage would be to save the database to .mmd and then post-process with mermaid-cli: https://github.com/mermaid-js/mermaid-cli?tab=readme-ov-file#usage

is what would be sufficient for @rbange ? Or is the current state of this PR what you would need?

As I understand, @Mahad-lab would like to have the mermaid source surrounded by ` (backticks), which would then not be compatible with mermaid cli anymore.
And I do not really know how you are using this output, as you can't easily embed markdown..?

Other tools like https://github.com/Mermaid-Chart/vscode-mermaid-preview?tab=readme-ov-file#standalone-mermaid-files support both formats.

@maurerle
Copy link
Collaborator

Furthermore it is possible to integrate other mermaid files into rst docs using:

.. mermaid:: mydiagram.mmd

But this is not yet rendered in github/gitlab

@PamelaM
Copy link
PamelaM commented Apr 17, 2025

Our main use-case is that our security monitoring can't send data to https://mermaid.ink, and a bunch of our dev docs are in md

@maurerle
Copy link
Collaborator

So @PamelaM and @rbange can you check if your use-cases would be solved by the current PR as is?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0