1# Zed Docs
  2
  3Welcome to Zed's documentation.
  4
  5This is built on push to `main` and published automatically to [https://zed.dev/docs](https://zed.dev/docs).
  6
  7To preview the docs locally you will need to install [mdBook](https://rust-lang.github.io/mdBook/) (`cargo install mdbook@0.4.40`) and then run:
  8
  9```sh
 10mdbook serve docs
 11```
 12
 13It's important to note the version number above. For an unknown reason, as of 2025-04-23, running 0.4.48 will cause odd URL behavior that breaks docs.
 14
 15Before committing, verify that the docs are formatted in the way Prettier expects with:
 16
 17```
 18cd docs && pnpm dlx prettier@3.5.0 . --write && cd ..
 19```
 20
 21## Preprocessor
 22
 23We have a custom mdbook preprocessor for interfacing with our crates (`crates/docs_preprocessor`).
 24
 25If for some reason you need to bypass the docs preprocessor, you can comment out `[preprocessor.zed_docs_preprocessor]
 26` from the `book.toml`.:
 27
 28## Images and videos
 29
 30To add images or videos to the docs, upload them to another location (e.g., zed.dev, GitHub's asset storage) and then link out to them from the docs.
 31
 32Putting binary assets such as images in the Git repository will bloat the repository size over time.
 33
 34## Internal notes:
 35
 36- We have a Cloudflare router called `docs-proxy` that intercepts requests to `zed.dev/docs` and forwards them to the "docs" Cloudflare Pages project.
 37- CI uploads a new version to the Pages project from `.github/workflows/deploy_docs.yml` on every push to `main`.
 38
 39### Table of Contents
 40
 41The table of contents files (`theme/page-toc.js` and `theme/page-doc.css`) were initially generated by [`mdbook-pagetoc`](https://crates.io/crates/mdbook-pagetoc).
 42
 43Since all this preprocessor does is generate the static assets, we don't need to keep it around once they have been generated.
 44
 45## Referencing Keybindings and Actions
 46
 47When referencing keybindings or actions, use the following formats:
 48
 49### Keybindings:
 50
 51`{#kb scope::Action}` - e.g., `{#kb zed::OpenSettings}`.
 52
 53This will output a code element like: `<code>Cmd+,|Ctrl+,</code>`. We then use a client-side plugin to show the actual keybinding based on the user's platform.
 54
 55By using the action name, we can ensure that the keybinding is always up-to-date rather than hardcoding the keybinding.
 56
 57### Actions:
 58
 59`{#action scope::Action}` - e.g., `{#action zed::OpenSettings}`.
 60
 61This will render a human-readable version of the action name, e.g., "zed: open settings", and will allow us to implement things like additional context on hover, etc.
 62
 63### Creating New Templates
 64
 65Templates are just functions that modify the source of the docs pages (usually with a regex match & replace). You can see how the actions and keybindings are templated in `crates/docs_preprocessor/src/main.rs` for reference on how to create new templates.
 66
 67### References
 68
 69- Template Trait: crates/docs_preprocessor/src/templates.rs
 70- Example template: crates/docs_preprocessor/src/templates/keybinding.rs
 71- Client-side plugins: docs/theme/plugins.js
 72
 73## Postprocessor
 74
 75A postprocessor is implemented as a sub-command of `docs_preprocessor` that wraps the builtin `html` renderer and applies post-processing to the `html` files, to add support for page-specific title and meta description values.
 76
 77An example of the syntax can be found in `git.md`, as well as below
 78
 79```md
 80---
 81title: Some more detailed title for this page
 82description: A page-specific description
 83---
 84
 85# Editor
 86```
 87
 88The above will be transformed into (with non-relevant tags removed)
 89
 90```html
 91<head>
 92  <title>Editor | Some more detailed title for this page</title>
 93  <meta name="description" contents="A page-specific description" />
 94</head>
 95<body>
 96  <h1>Editor</h1>
 97</body>
 98```
 99
100If no front-matter is provided, or If one or both keys aren't provided, the title and description will be set based on the `default-title` and `default-description` keys in `book.toml` respectively.
101
102### Implementation details
103
104Unfortunately, `mdbook` does not support post-processing like it does pre-processing, and only supports defining one description to put in the meta tag per book rather than per file. So in order to apply post-processing (necessary to modify the html head tags) the global book description is set to a marker value `#description#` and the html renderer is replaced with a sub-command of `docs_preprocessor` that wraps the builtin `html` renderer and applies post-processing to the `html` files, replacing the marker value and the `<title>(.*)</title>` with the contents of the front-matter if there is one.
105
106### Known limitations
107
108The front-matter parsing is extremely simple, which avoids needing to take on an additional dependency, or implement full yaml parsing.
109
110- Double quotes and multi-line values are not supported, i.e. Keys and values must be entirely on the same line, with no double quotes around the value.
111
112The following will not work:
113
114```md
115---
116title: Some
117  Multi-line
118  Title
119---
120```
121
122And neither will:
123
124```md
125---
126title: "Some title"
127---
128```
129
130- The front-matter must be at the top of the file, with only white-space preceding it
131
132- The contents of the title and description will not be html-escaped. They should be simple ascii text with no unicode or emoji characters