Skip to content
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

feat: automatic mermaid diagram generation #696

Closed
ss2165 opened this issue Nov 15, 2023 · 0 comments · Fixed by #852
Closed

feat: automatic mermaid diagram generation #696

ss2165 opened this issue Nov 15, 2023 · 0 comments · Fixed by #852
Assignees
Labels
enhancement New feature or request

Comments

@ss2165
Copy link
Member

ss2165 commented Nov 15, 2023

Mermaid diagrams are syntacticly simple and use indentation to follow the same hierarchical structure that HUGR has. The walker should be a perfect fit. Could replace the dot-string code base, or share the formatting code for names/ports etc.

Blocked by #626

@ss2165 ss2165 added the enhancement New feature or request label Nov 15, 2023
@aborgna-q aborgna-q self-assigned this Feb 28, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 5, 2024
Adds a `HugrView::mermaid_string` which produces things like
```mermaid
graph LR
    subgraph 0 ["(0) DFG"]
        direction LR
        1["(1) Input"]
        1--0:0-->3
        1--1:1-->3
        2["(2) Output"]
        3["(3) test.quantum.CX"]
        3--0:1-->4
        3--1:0-->4
        3-.2:2.-4
        4["(4) test.quantum.CX"]
        4--0:0-->2
        4--1:1-->2
    end
```
Note that edges in mermaid are unordered, so I had to add the port
indices explicitly.

The new code in `src/hugr/views/render.rs` is just moved from
`src/hugr/views.rs`.

Closes #696 

Requires CQCL/portgraph#125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants