From 2a8ff9ca75e38380b78bb3e469d119ab2e6a9f69 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 3 Apr 2022 22:09:17 -0700 Subject: [PATCH] docs: adopt mermaid-js for flowchart This is a bit more compact and easier to edit. A downside is that the search engine highlight can break the diagram and cause it to emit a syntax error. --- .github/workflows/pages.yml | 3 +- .github/workflows/verify-pages.yml | 3 +- .gitignore | 1 + ci/build-docs.sh | 1 + docs/book.toml | 6 ++++ docs/config/lua/config/default_cwd.md | 51 ++++++++++----------------- docs/mermaid-init.js | 4 +++ 7 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 docs/mermaid-init.js diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 88308508b..839f7ef4a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -29,12 +29,13 @@ jobs: uses: actions/cache@v1 with: path: ~/mdbook-bin - key: cargo-bin-mdbook-1 + key: cargo-bin-mdbook-2 - name: Install mdBook run: | mkdir -p ~/mdbook-bin (test -x ~/mdbook-bin/mdbook || (cd && cargo install --vers "^0.4" mdbook && cp -p ~/.cargo/bin/mdbook ~/mdbook-bin)) (test -x ~/mdbook-bin/mdbook-linkcheck || (cd && cargo install mdbook-linkcheck && cp -p ~/.cargo/bin/mdbook-linkcheck ~/mdbook-bin)) + (test -x ~/mdbook-bin/mdbook-mermaid || (cd && cargo install mdbook-mermaid && cp -p ~/.cargo/bin/mdbook-mermaid ~/mdbook-bin)) - name: Build run: | source $HOME/.cargo/env diff --git a/.github/workflows/verify-pages.yml b/.github/workflows/verify-pages.yml index c3778a395..f127e7172 100644 --- a/.github/workflows/verify-pages.yml +++ b/.github/workflows/verify-pages.yml @@ -27,12 +27,13 @@ jobs: uses: actions/cache@v1 with: path: ~/mdbook-bin - key: cargo-bin-mdbook-1 + key: cargo-bin-mdbook-2 - name: Install mdBook run: | mkdir -p ~/mdbook-bin (test -x ~/mdbook-bin/mdbook || (cd && cargo install --vers "^0.4" mdbook && cp -p ~/.cargo/bin/mdbook ~/mdbook-bin)) (test -x ~/mdbook-bin/mdbook-linkcheck || (cd && cargo install mdbook-linkcheck && cp -p ~/.cargo/bin/mdbook-linkcheck ~/mdbook-bin)) + (test -x ~/mdbook-bin/mdbook-mermaid || (cd && cargo install mdbook-mermaid && cp -p ~/.cargo/bin/mdbook-mermaid ~/mdbook-bin)) - name: Build run: | source $HOME/.cargo/env diff --git a/.gitignore b/.gitignore index 685769b72..b583fd26d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ /docs/config/lua/mux-events/index.md /docs/config/lua/window-events/index.md /docs/config/lua/keyassignment/index.md +/docs/mermaid.min.js **/*.rs.bk .*.sw* /esctest.log diff --git a/ci/build-docs.sh b/ci/build-docs.sh index bb19ae84b..90500ef75 100755 --- a/ci/build-docs.sh +++ b/ci/build-docs.sh @@ -5,6 +5,7 @@ set -x [[ -f /tmp/wezterm.nightly.json ]] || curl https://api.github.com/repos/wez/wezterm/releases/tags/nightly > /tmp/wezterm.nightly.json python3 ci/subst-release-info.py || exit 1 python3 ci/generate-docs.py || exit 1 +mdbook-mermaid install docs mdbook build docs rm gh_pages/html/README.markdown diff --git a/docs/book.toml b/docs/book.toml index 571608e2f..ccfee6b3f 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -12,6 +12,7 @@ additional-css = ["custom.css"] default-theme = "ayu" preferred-dark-theme = "ayu" git-repository-url = "https://github.com/wez/wezterm" +additional-js = ["mermaid.min.js", "mermaid-init.js"] [output.html.fold] enable = true @@ -19,3 +20,8 @@ level = 1 [output.linkcheck] traverse-parent-directories = false + +[preprocessor] + +[preprocessor.mermaid] +command = "mdbook-mermaid" diff --git a/docs/config/lua/config/default_cwd.md b/docs/config/lua/config/default_cwd.md index 3faffdf13..fdf3e3d6e 100644 --- a/docs/config/lua/config/default_cwd.md +++ b/docs/config/lua/config/default_cwd.md @@ -17,39 +17,24 @@ local Pane. If no `cwd` can be resolved, then the `default_cwd` will be used. If `default_cwd` is not specified, then the home directory of the user will be used. -```text - Is initial window? - ______________________|______________________ - | | - Yes No - | | - Opened with CLI New pane, tab, or window. Opened with a - and `--cwd` flag? `SpawnCommand` that includes `cwd`? - __________|__________ __________|__________ - | | | | - Yes No No Yes - | | | | - Use | Is there a value Use `cwd` specified -`--cwd` | set by OSC 7? by `SpawnCommand` - __________| __________|__________ - | | | - | No Yes - | | | - | Can `cwd` be resolved via Use OSC 7 - | the process group leader? value - | __________|__________ - | | | - | No Yes - |____________| | - | Use resolved - Is `default_cwd` `cwd` - defined? - __________|__________ - | | - Yes No - | | - Use Use home - `default_cwd` directory +```mermaid +graph TD + %%{wrap}%% + X[Determine current working directory for new pane] --> A{{Is initial window?}} + A -->|Yes| B[Opened with CLI and --cwd flag?] + A -->|No| C[New pane, tab or window.] + C --> D{{Opened with a SpawnCommand
that includes cwd?}} + D -->|No| J{{Is there a value set by OSC 7?}} + B -->|Yes| E[Use --cwd] + B -->|No| F{{Is default_cwd defined?}} + F -->|Yes| G[Use default_cwd] + F -->|No| H[Use home directory] + D -->|Yes| I[Use cwd specified
by `SpawnCommand`] + J -->|Yes| K[Use the OSC 7 value] + J -->|No| L{{Can cwd be resolved via
the process group leader?}} + L -->|Yes| M[Use resolved cwd] + L -->|No| F + ``` On macOS and Linux, `wezterm` can attempt to resolve the process group leader diff --git a/docs/mermaid-init.js b/docs/mermaid-init.js new file mode 100644 index 000000000..6ffbdb7eb --- /dev/null +++ b/docs/mermaid-init.js @@ -0,0 +1,4 @@ +mermaid.initialize({ + startOnLoad:true, + theme:"dark", +});