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

docs: Render mermaid graphs #568

Merged
merged 6 commits into from
Apr 9, 2024
Merged

Conversation

lewismiddleton
Copy link
Contributor

@lewismiddleton lewismiddleton commented Apr 3, 2024

Add the plugin as a dependency as per installation guide.
poetry add mkdocs-mermaid2-plugin --group docs

Add to the mkdocs.yml via plugins syntax

This on it's own is sufficient to get the diagrams to render.

Resolves: #567

Adds the [mermaid2 plugin]
(https://github.com/fralau/mkdocs-mermaid2-plugin)
which enables mkdocs to render mermaid diagrams.
@lewismiddleton lewismiddleton requested a review from a team as a code owner April 3, 2024 07:40
@lewismiddleton
Copy link
Contributor Author

lewismiddleton commented Apr 3, 2024

Adding a fence_mermaid_custom format to superfences as per mermaid2 plugin Material theme config didn't seem to change behaviour but seems like is best practice if you want the diagrams to inherit styling from any theming you choose.

plugins: 
  - mermaid2

markdown_extensions:
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:mermaid2.fence_mermaid_custom

@lewismiddleton lewismiddleton changed the title add mermaid2 plugin docs: add mermaid2 plugin Apr 3, 2024
mkdocs.yml Outdated
Comment on lines 62 to 66
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid_custom
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @lewismiddleton! Thanks for your contribution and for spotting this issue, very much appreciated!

In my other mkdocs project I did the following:

Suggested change
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid_custom
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format

For me it seems like a healthier change as it doesn't require the extra dependency to be installed, would you mind giving it a shot see if it renders as you would like compared with mermaid2.

Thanks in advance!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree, a better solution if it works. I wasn't able to get that working, give it a try on your environment and see what you think?

You're right though in that the docs say it should be sufficient. I'm curious to know what the difference is between this project and others (if there is actually an issue - idk maybe my environment is just differnet)

Copy link
Contributor

Choose a reason for hiding this comment

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

I did try it and it worked.

Worth mentioning though that I was running my doc website through a mkdocs serve and reaching it on localhost:8000 through my browser and not via the mkdocs build, it seems like you were using the build method and I don't know if that may cause some differences in the rendering.

Regardless I have another website with those options hosted on GitHub pages that is working fine as well for rendering the mermaid graphs.

Let's give it a go with only the suggestion above, merge the PR, then if it's doesn't work we'll review the addition of the plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was using poetry run mkdocs build --strict but can confirm mkdocs serve works on my machine too.

I've reverted the commits and pushed the suggested change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome! Thank you for your patience and making the suggested changes ❤️

And good to know it doesn't behave the same with a mkdocs build!

@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.79%. Comparing base (7e869d8) to head (4bbc5a9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #568   +/-   ##
=======================================
  Coverage   85.79%   85.79%           
=======================================
  Files          31       31           
  Lines        1218     1218           
=======================================
  Hits         1045     1045           
  Misses        173      173           
Flag Coverage Δ
api 66.99% <ø> (ø)
unit 70.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@tcarmet tcarmet changed the title docs: add mermaid2 plugin docs: Render mermaid graphs Apr 9, 2024
@tcarmet tcarmet merged commit 7f87a23 into scality:main Apr 9, 2024
8 of 11 checks passed
@lewismiddleton lewismiddleton deleted the mermaid-plugin branch September 23, 2024 14:05
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.

docs: mermaid diagrams don't render
3 participants