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!: mermaid rendering #125

Merged
merged 6 commits into from
Mar 1, 2024
Merged

feat!: mermaid rendering #125

merged 6 commits into from
Mar 1, 2024

Conversation

aborgna-q
Copy link
Collaborator

Renames the dot module to render, and adds a mermaid formatter using the same style configuration structs.

BREAKING CHANGE: Moved portgraph::dot to portgraph::render

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 83.87097% with 45 lines in your changes are missing coverage. Please review.

Project coverage is 79.38%. Comparing base (d94ba4f) to head (717420e).

Files Patch % Lines
src/render.rs 39.21% 31 Missing ⚠️
src/render/mermaid.rs 93.83% 9 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
+ Coverage   78.77%   79.38%   +0.60%     
==========================================
  Files          19       21       +2     
  Lines        4773     5016     +243     
  Branches     4773     5016     +243     
==========================================
+ Hits         3760     3982     +222     
- Misses        946      962      +16     
- Partials       67       72       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/render/mermaid.rs Outdated Show resolved Hide resolved
src/render/mermaid.rs Outdated Show resolved Hide resolved
src/render/mermaid.rs Outdated Show resolved Hide resolved
@aborgna-q aborgna-q enabled auto-merge March 1, 2024 14:04
@aborgna-q aborgna-q disabled auto-merge March 1, 2024 14:17
@aborgna-q aborgna-q added this pull request to the merge queue Mar 1, 2024
Merged via the queue into main with commit 6eddd63 Mar 1, 2024
11 checks passed
@aborgna-q aborgna-q deleted the feat/mermaid branch March 1, 2024 14:31
@github-actions github-actions bot mentioned this pull request Mar 1, 2024
github-merge-queue bot pushed a commit that referenced this pull request Mar 1, 2024
## 🤖 New release
* `portgraph`: 0.11.0 -> 0.12.0 (⚠️ API breaking changes)

### ⚠️ `portgraph` breaking changes

```
--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.29.1/src/lints/enum_missing.ron

Failed in:
  enum portgraph::dot::PortStyle, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:33
  enum portgraph::dot::EdgeStyle, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:74
  enum portgraph::dot::NodeStyle, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:10

--- failure module_missing: pub module removed or renamed ---

Description:
A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.29.1/src/lints/module_missing.ron

Failed in:
  mod portgraph::dot, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:1

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.29.1/src/lints/struct_missing.ron

Failed in:
  struct portgraph::dot::DotFormatter, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:99

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.29.1/src/lints/trait_missing.ron

Failed in:
  trait portgraph::dot::DotFormat, previously in file /tmp/.tmpRl5Civ/portgraph/src/dot.rs:359
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## 0.12.0 (2024-03-01)

### Features

- Proptest for Multiportgraph
- (Multi)Portgraph implement Arbitrary
- [**breaking**] Mermaid rendering
([#125](#125))

### Miscellaneous Tasks

- [**breaking**] Hike MSRV to 1.75
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit to CQCL/hugr that referenced this pull request 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
@github-actions github-actions bot mentioned this pull request Apr 15, 2024
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.

2 participants