mersinvald / aquamarine

Inline diagrams for rustdoc with mermaid.js
MIT License
508 stars 28 forks source link

Leftmost part of the graph not visible sometimes #30

Closed mgr-inz-rafal closed 1 year ago

mgr-inz-rafal commented 1 year ago

Hello, For some of the flowcharts, the leftmost part is not visible when embedded into the docs. Can we overcome that?

image

mersinvald commented 1 year ago

Could you please give me a reproducible example?

mgr-inz-rafal commented 1 year ago

Yes, certainly. This is the graph source code:

 flowchart TD
     style Start fill:#66ccff,stroke:#333,stroke-width:4px
     style End fill:#66ccff,stroke:#333,stroke-width:4px

     Start --> Initialize
     Initialize --> CatchUp
     CatchUp --> KeepUp
     KeepUp --> CatchUp
     KeepUp --> Validate
     Validate --> KeepUp
     CatchUp --> ShutdownForUpgrade
     KeepUp --> ShutdownForUpgrade
     Validate --> ShutdownForUpgrade
     CatchUp --> Upgrading
     CatchUp -->|at genesis| Validate
     Upgrading --> CatchUp
     ShutdownForUpgrade --> End

and this is the pic embededd in docs:

image

mersinvald commented 1 year ago

@mgr-inz-rafal it doesn't reproduce for me locally with cargo doc --open. Does it break for you locally? Is that a public crate I could see docs.rs page for?

image
mgr-inz-rafal commented 1 year ago

Yes, it reproduces for me locally in both Chrome and Firefox on Linux Mint.

The repo is public: https://github.com/casper-network/casper-node

However, the docs are not yet published. The charts are merged into the dev branch.

This file contains the mentioned graph: https://github.com/casper-network/casper-node/blob/dev/node/src/reactor/main_reactor/reactor_state.rs

PS. I use this to generate the docs:

cargo doc --document-private-items --open
mersinvald commented 1 year ago

@mgr-inz-rafal add the following init line in your flowchart declaration:

/// flowchart TD
///     %%{init: { 'flowchart': {'diagramPadding':100} }}%%
///     style Start fill:#66ccff,stroke:#333,stroke-width:4px
///     style End fill:#66ccff,stroke:#333,stroke-width:4px
///     

It would ensure you have padding at all borders, including leftmost. That should fix it. Please let me know if that's not a one-off issue, in this case I think aquamarine should enforce larger padding on all diagram types by default.

P.S: I couldn't reproduce it in a test crate or pinpoint why it happens.

mersinvald commented 1 year ago

Marking wontfix for now, will reopen if there are more occasions of this issue.

mgr-inz-rafal commented 1 year ago

@mersinvald Adding the manual padding worked like a charm, thanks! :+1: