twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

doc: sequence diagram in dark mode #3175

Closed FreeMasen closed 1 year ago

FreeMasen commented 1 year ago

Describe the bug

The font in the sequence diagram is unreadable when dark mode is turned on (this is selected based on the operating system setting the user has chosen)

To reproduce

Turn on dark mode while browsing the docs

Expected behavior

Fonts should be toggled to a lighter color when the theme changes

Additional context

Screenshot-6

twpayne commented 1 year ago

Thanks for reporting this. This should have been fixed with https://github.com/twpayne/chezmoi/pull/2309. What browser and operating system are you using?

FreeMasen commented 1 year ago

Firefox 116.0 (64-bit) on Ubuntu 22.04

bradenhilton commented 1 year ago

Okay, I'm a little all over the place at the moment investigating this and https://github.com/twpayne/chezmoi/issues/3180, but I must express my confusion.

My current working copy for https://github.com/twpayne/chezmoi/issues/3180 without switching to the native Mermaid like I did in https://github.com/twpayne/chezmoi/pull/3177 gives this:

Screen Shot 2023-08-16 at 20 14 27

Navigating to the same page on the live site still shows it incorrectly, and the browser console shows the error
Uncaught ReferenceError: mermaidAPI is not defined.

bradenhilton commented 1 year ago

On the live site, the import and initialization happen in separate script tags:

https://github.com/twpayne/chezmoi/blob/d8034dcc518db4ccfc96c29c8236c55b97f5f6b3/user-guide/command-overview/index.html#L2071-L2074

I just built the site from my working copy, and they are combined:

<script type="module">import mermaid from "https://unpkg.com/mermaid@10.1.0/dist/mermaid.esm.min.mjs";
mermaid.initialize({
    theme: (JSON.parse(__md_get("__palette").index == 1)) ? 'dark' : 'light'
});</script></body>

@twpayne is it possible you could force a rebuild of the website to see if this resolves itself (and fixes this issue)?

I still personally think it's worth switching to the native implementation, but I have no idea if the site is being built incorrectly (which could also potentially impact the native implementation), so I'm hesitant to switch at the moment.

halostatue commented 1 year ago

It’s not just that the two statements are separate, but that the initialize is being called as mermaidAPI but it is imported as mermaid. I can’t find anything in the configuration or anything else that should be calling it mermaidAPI, so something extra has happened here.

bradenhilton commented 1 year ago

@halostatue mermaidAPI is defined in the module:

u = {
  startOnLoad: !0,
  mermaidAPI: m,
  parse: z,
  render: O,
  init: C,
  run: v,
  registerExternalDiagrams: I,
  initialize: L,
  parseError: void 0,
  contentLoaded: b,
  setParseErrorHandler: $,
  detectType: P
};
export {
  u as default
};

This could be related to the regression mentioned in https://github.com/fralau/mkdocs-mermaid2-plugin/commit/32ca519c4cd4315a6ef7a1cacd0d92cd9003c1f6 from 2023-08-09T09:17:04Z.

The website was last built 2023-08-06T18:44:45Z.

twpayne commented 1 year ago

Website history is in the gh-pages branch.

@bradenhilton feel free to run mkdocs gh-deploy if it is helpful: you can always force-push to reset the branch to a previous commit if anything unexpected happens.

halostatue commented 1 year ago

@halostatue mermaidAPI is defined in the module:

u = {
  startOnLoad: !0,
  mermaidAPI: m,
  parse: z,
  render: O,
  init: C,
  run: v,
  registerExternalDiagrams: I,
  initialize: L,
  parseError: void 0,
  contentLoaded: b,
  setParseErrorHandler: $,
  detectType: P
};
export {
  u as default
};

That would mean that the import needs to be import { mermaidAPI } … or the initialization needs to be mermaid.mermaidAPI. So there is something really weird being generated. This may simply be a generation error, as you’re surmising, or it could be the regression fixed in 1.0.8.

twpayne commented 1 year ago

Sometimes dependencies break. Sometimes the right course of action is to sit back and wait until the maintainers fix the problem.

The issues here are not specific to chezmoi's use of mermaid in chezmoi's mkdocs documentation.

Zero stress. Feel free to wait this one out.

bradenhilton commented 1 year ago

@twpayne I don't believe mkdocs gh-deploy will work for me on the current master, due to the symlink and path issues outlined in https://github.com/twpayne/chezmoi/issues/3180 breaking the Links templates.

I'll open the PR now to get that solved first.

bradenhilton commented 1 year ago

@FreeMasen This was a dependency issue which is now fixed on the latest build of the website.