Skip to content

docs: add how-to guide for Mermaid diagramming tool#442

Merged
AnneCYH merged 2 commits into
mainfrom
annecyh/mermaid-how-to
Oct 14, 2025
Merged

docs: add how-to guide for Mermaid diagramming tool#442
AnneCYH merged 2 commits into
mainfrom
annecyh/mermaid-how-to

Conversation

@AnneCYH

@AnneCYH AnneCYH commented Oct 1, 2025

Copy link
Copy Markdown
Contributor
  • Have you updated CHANGELOG.md with relevant non-documentation file changes?
  • Have you updated the documentation for this change?

@AnneCYH

AnneCYH commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

Hi @SecondSkoll ,

Could you give this an initial review to see if this matches your expectations for the standard workflow + approach task?
We will align the rest of the content based on your feedback / any concerns you may have with this structure.

Thanks.

p/s: I'll make sure the 2 checkboxes are acknowledged / ticked and get the rest of the tests passing.

Comment thread docs/how-to/index.rst
Comment thread docs/how-to/index.rst
Comment thread docs/how-to/diagrams-as-code-mermaid.md
@AnneCYH AnneCYH force-pushed the annecyh/mermaid-how-to branch 2 times, most recently from 4de681f to 93c501f Compare October 3, 2025 07:33
@AnneCYH AnneCYH marked this pull request as ready for review October 3, 2025 07:37

@SecondSkoll SecondSkoll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work. I would like to see some advice on what to do for images in dark mode:

image

Which could be as simple as adding some CSS to set the background of pre.mermaid to white.

Otherwise I think this is good. I think it's possible we've got a more technical audience than this topic is aimed at - but I think with our efforts in CODA, having topics like this with a low barrier of entry is probably a good way to go.

Comment thread docs/how-to/diagrams-as-code-mermaid.md
@AnneCYH

AnneCYH commented Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

Great work. I would like to see some advice on what to do for images in dark mode:

image Which could be as simple as adding some CSS to set the background of `pre.mermaid` to white.

Otherwise I think this is good. I think it's possible we've got a more technical audience than this topic is aimed at - but I think with our efforts in CODA, having topics like this with a low barrier of entry is probably a good way to go.

Hey @SecondSkoll ,

Interesting point.
When you mentioned 'more technical audience' I think it would be helpful to understand what they want to achieve with Mermaid and improve the docs / examples accordingly.

Comment thread docs/_static/mermaid-sequence.css Outdated
/* Only apply to Mermaid diagrams in dark mode */
body[data-theme="dark"] .mermaid {
border: 2px solid #BEA8B9; /* subtle border */
background-color:#CEBECA; /* dark background */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

these are from the Ubuntu color palette
avoiding white as it's a bit too jarring in dark mode.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if data-theme="auto", and your browser just detects dark mode, this overwrite doesn't work.

image

@AnneCYH AnneCYH requested a review from SecondSkoll October 6, 2025 06:01

@medubelko medubelko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @AnneCYH, I think this is great. It'll make some of my engineers happy. :)

Comment thread docs/conf.py Outdated
Comment thread docs/_static/mermaid-sequence.css Outdated
Comment thread docs/reuse/mermaid.txt
Comment thread docs/_static/mermaid-sequence.css Outdated
@AnneCYH AnneCYH requested a review from medubelko October 10, 2025 02:30
@AnneCYH AnneCYH self-assigned this Oct 10, 2025
@AnneCYH AnneCYH mentioned this pull request Oct 10, 2025
2 tasks

@AshleyCliff AshleyCliff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Section formatting and wording look good to me! (Per request to review from @medubelko)

@medubelko medubelko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm approving this for its technical correctness, but I'm not certain how we want this to be used. I believe @SecondSkoll might have an answer.

We've written this as an opt-in guide for Mermaid, but as far as this is a template repo, the implementation is at cross-purposes because:

  1. When a user duplicates the repo, the Mermaid config, including the stylesheet with Ubuntu branding, is already active. So if they follow the guide, there will be nothing for them to do.
  2. We also render some Mermaid diagrams in the docs, so it's not a simple matter of disabling the extension.

If we wanted to make this a truly opt-in guide, I don't think we should enable the extension or include the CSS file. The only workaround for the docs I can think of is to insert images of the generated diagrams.

@AnneCYH

AnneCYH commented Oct 12, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @medubelko .

It's similar to the rest of the approaches / tools we are trying to document; they are optional.

I agree with what you said. Maybe this doc should just guide you on how to get it enabled but as you said, the settings should not be enabled by default. And attaching PNGs of the rendered diagrams to demonstrate how they would appear would avoid build failures because of Mermaid code.

@AnneCYH

AnneCYH commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

Note: library-related links are down at the moment; suggesting to skip those as 'blocking' issues if we want to merge.
Thanks.

Comment thread docs/_static/mermaid-sequence.css Outdated
/* Only apply to Mermaid diagrams in dark mode */
body[data-theme="dark"] .mermaid {
border: 2px solid #BEA8B9; /* subtle border */
background-color:#CEBECA; /* dark background */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if data-theme="auto", and your browser just detects dark mode, this overwrite doesn't work.

image

@SecondSkoll

Copy link
Copy Markdown
Collaborator

@medubelko raises a salient point. Part of this work is to make sure we continue to support these extensions over time, but we do want to ensure the starter pack itself is relatively minimal so it can be used as a template. This means there should probably be a separate project that is tightly linked to the starter pack, where we can link to the practical implementation of what we document here. I can't think of a really neat solution to this. I agree with using images for now.

@AnneCYH

AnneCYH commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

Hi @SecondSkoll , I don't know how to properly fix the CSS in a theme- mode-agnostic manner.
Could we set a background color regardless of the theme / mode for now? This way it renders clearly enough regardless of your browser / device settings.

Thanks.

@SecondSkoll

Copy link
Copy Markdown
Collaborator

Hi @SecondSkoll , I don't know how to properly fix the CSS in a theme- mode-agnostic manner. Could we set a background color regardless of the theme / mode for now? This way it renders clearly enough regardless of your browser / device settings.

Thanks.

Yep, that should be fine.

@AnneCYH AnneCYH force-pushed the annecyh/mermaid-how-to branch 3 times, most recently from 4d1db52 to fedfbee Compare October 13, 2025 07:53
Signed-off-by: annecyh <anne.chew@canonical.com>
@AnneCYH AnneCYH force-pushed the annecyh/mermaid-how-to branch from e64b5c5 to e3808d6 Compare October 13, 2025 07:59
@AnneCYH

AnneCYH commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

Hi @medubelko and @SecondSkoll ,

I've addressed all the comments and updated the PR.

  • Used images instead of 'live code' for Mermaid diagrams
  • Set a background for the Mermaid CSS so it shows up properly in any color scheme / theme

Please do review and lemme know if I'm still missing anything else.

Thanks!

@AnneCYH

AnneCYH commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Fixed the merge conflict, @SecondSkoll , thanks.

@SecondSkoll SecondSkoll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. I don't love using the asset manager, but the diagrams won't need to change as they're just examples of diagrams.

@AnneCYH AnneCYH merged commit 5a768e7 into main Oct 14, 2025
7 checks passed
@AnneCYH AnneCYH deleted the annecyh/mermaid-how-to branch October 15, 2025 05:42
SecondSkoll added a commit that referenced this pull request Nov 13, 2025
* fix: CLA check to run on PRs only

* refactor: Replace build_metrics.sh with something nicer (#373)

* Replace build_metrics.sh with something nicer

* docs: update changelog

* docs: fix info about setting RTD key as GitHub deploy key (#423)

* fix: spelling mistake in update script (#425)

* fix spelling mistake in update script

* add change to CHANGELOG.md

* Add warning to set-up-automated-testing.rst (#427)

* feat: exclude generated pages from sitemap by default, document wildcards (#429)

* add info about wildcard excludes

* add placeholder sitemap_excludes in conf.py

* adjust wording of comment

* enable typical sitemap_excludes by default

* use consistent wording and formatting

* Use long parameter for 'fail on warning' (#430)

* docs: add troubleshooting how-to (#432)

Add tag desync as the first issue.

* Fix stale references to `custom_conf.py` (#433)

* fix(ci): make check-removed-urls work with private forks (#437)

* fix(ci): make check-removed-urls work with private forks

Fixes #436

* docs: update changelog

* chore: add `CODEOWNERS` (#439)

* chore: add `CODEOWNERS`

Enumerate individual reviewers for now.

Later, we can add a Sphinx development team, once we've established one.

* docs: add #438 to changelog

* chore: missing hyphen

Co-authored-by: Michael Park <michael.park@canonical.com>

* chore: revert changelog entry

Co-authored-by: Michael Park <michael.park@canonical.com>

---------

Co-authored-by: Michael Park <michael.park@canonical.com>

* Update Open Graph image URL in conf.py (#441)

The preview image being used was an old one, and the design team has suggested the use of this one instead.

* Update workflow action versions (#445)

* update workflow action versions

* update changelog

* Update CHANGELOG.md

Co-authored-by: Dave Wilding <david.wilding@canonical.com>

---------

Co-authored-by: Dave Wilding <david.wilding@canonical.com>

* Fix whitespace and executable flag of scripts (#448)

* make scripts executable

* remove whitespace from vale script

* update CHANGELOG.md

* docs: add how-to guide for Mermaid diagramming tool (#442)

Signed-off-by: annecyh <anne.chew@canonical.com>

* Move from canonical-sphinx-exensions to individual packages (#449)

* Move from canonical-sphinx-exensions to individual packages

* Update CHANGELOG.md

* build(deps): bump sphinx-terminal to v0.1.1 (#454)

* docs: add how-to guide for sphinx autodoc extension (#450)

* docs: update how to index.rst add autodocs

* docs: create autodocs.md

* fix: conf file formatting in autodocs.md

* fix: fix conf.py formatting in autodocs.md

* fix: pr comment updates

* fix: requested pr changes

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

* fix: autodoc table formatting

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

* docs: update changelog for autodoc

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

* fix: autodoc spell fix

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

* fix: autodoc formatting

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

---------

Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>

* build: move Vale dependencies to requirements.txt (#456)

* move Vale dependencies to requirements.txt

* add PR link to CHANGELOG.md

* Add OpenAPI how-to guide (#446)

* Add OpenAPI how-to guide

* Include RTD steps in OpenAPI how-to guide

* docs: add guidelines for using custom base templates (#455)

* docs: add guidelines for using custom base templates

Signed-off-by: annecyh <anne.chew@canonical.com>

* docs: add a how-to guide for data tables (#451)

* add first draft of data tables guide

* add data tables guide to index

* add details about Sphinx DataTables

* adjust wording

* update landing page per suggestion

* adjust wording

* mention new doc in CHANGELOG

* remove full stop

* put links in alphabetical order

* use reST formatting

* explain purpose of links and remove duplicated links

* improve wording per review

* docs: consolidate custom template information (#459)

Signed-off-by: annecyh <anne.chew@canonical.com>

* Details about sphinx-terminal (#447)

* Details about sphinx-terminal

* Describe the terminal copy button

Co-authored-by: JJ Coldiron <jj.coldiron@canonical.com>

* fix(build): remove em dash from fallback target (#461)

 #388 introduced an emdash in the makefile that was almost certainly not
intended; this causes the fallthrough case to infinitely recurse.

---------

Signed-off-by: Wesley Hershberger <wesley.hershberger@gmail.com>
Co-authored-by: Michael DuBelko <michael.dubelko@gmail.com>

* feat!: incorporate redesigned terminal (#460)

* fix(docs): update style guide redirects (#453)

* docs: add step to remove CODEOWNERS in the tutorial (#458)

Reorganise the first two sections so copying and pruning files are
discrete actions.

* Ensure update_sp.py is executable from any directory not just docs/ (#424)

* ensure this file is executable from any directory not just docs/

* Add a new line

* update requirements.txt path

* update NEWFILES.txt path

* chore: refactor makefile (#426)

Co-authored-by: Michael Park <michael.park@canonical.com>

* chore: Remove `ALLFILES` from makefile (#434)

* Remove `ALLFILES` from Makefile

* Update changelog

---------

Co-authored-by: Michael Park <michael.park@canonical.com>

* feat: better canonical URL support (#462)

* fix: config for canonical URL

* docs: update html_baseurl context in conf file

* Update CHANGELOG.md

* Update CHANGELOG.md

* chore: reword changelog entry

* chore: bump version

* fix: CHANGELOG

* fix: spelling issues

---------

Signed-off-by: annecyh <anne.chew@canonical.com>
Signed-off-by: Ashley Cliff <ashley.cliff@canonical.com>
Signed-off-by: Wesley Hershberger <wesley.hershberger@gmail.com>
Co-authored-by: Dave Jones <dave@waveform.org.uk>
Co-authored-by: Dave Wilding <david.wilding@canonical.com>
Co-authored-by: Erin Conley <erin.conley@canonical.com>
Co-authored-by: Robert Krátký <robert.kratky@canonical.com>
Co-authored-by: Michael DuBelko <michael.dubelko@canonical.com>
Co-authored-by: tarek-y-ismail <tarek.ismail@canonical.com>
Co-authored-by: Alex Lowe <alex.lowe@canonical.com>
Co-authored-by: Dimple Kuriakose <123362247+k-dimple@users.noreply.github.com>
Co-authored-by: AnneCYH <anne.chew@canonical.com>
Co-authored-by: Artem Konev <141050460+akcano@users.noreply.github.com>
Co-authored-by: JJ Coldiron <jj.coldiron@canonical.com>
Co-authored-by: Ashley Cliff <ashley.cliff@canonical.com>
Co-authored-by: Marek Suchánek <marek.suchanek@canonical.com>
Co-authored-by: Wesley Hershberger <wesley.hershberger@canonical.com>
Co-authored-by: Michael DuBelko <michael.dubelko@gmail.com>
Co-authored-by: Charles Uneze <charlesniklaus@gmail.com>
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.

4 participants