feat: Add custom node labels in mermaid_string
To move PersistentHugr out of hugr-core, I need to be able to provide custom node labels to the mermaid printer. Whilst adding a field for this to RenderConfig would not be breaking, the problem is that such a field would have to be an Option<HashMap>, which is non-Copy and non-Hash. That would be a breaking change to RenderConfig.
I have found a creative way around this here, keeping the Copy-able RenderConfig and adding a FullRenderConfig struct with support for From and TryInto.
Is this the preferred approach? How would I make a note that this ought to be simplified ahead of the next breaking release?
Codecov Report
Attention: Patch coverage is 78.02691% with 49 lines in your changes missing coverage. Please review.
Project coverage is 82.35%. Comparing base (
1ecd755) to head (3c92e64). Report is 7 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2275 +/- ##
==========================================
+ Coverage 82.33% 82.35% +0.01%
==========================================
Files 240 240
Lines 43577 43726 +149
Branches 39488 39637 +149
==========================================
+ Hits 35881 36012 +131
- Misses 5701 5719 +18
Partials 1995 1995
| Flag | Coverage Δ | |
|---|---|---|
| python | 85.39% <ø> (ø) |
|
| rust | 82.04% <78.02%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
How about replicating the MermaidFormatter builder pattern from Portgraph, just wrapping it with HUGR types? Existing methods would just build and finish this new struct internally, and you are free to add a with_node_style(Fn(Node) -> String) method to it.
Existing mermaid_string_with_config could be deprecated in favour of hugr.mermaid_formatter().with_config(..)
@ss2165 this should be ready to be reviewed now! See if this is what you had in mind. Once this is merged in, you can also merge in https://github.com/CQCL/hugr/pull/2277. Thanks a lot!