docs: author the sidebar in per-section YAML compiled to manifest.json (#30165)

## Summary

The docs sidebar is now written as YAML files under `docs/manifest/`,
one route and its direct children per file, and a new tool,
`scripts/docsmanifestgen`, compiles them into `docs/manifest.json`.
Moving two top-level sections is now a 2-line change in
`docs/manifest/index.yml` instead of a diff of hundreds of lines in a
2,600-line JSON file.
The compiled `docs/manifest.json` is byte-identical to `main`, so
coder.com, docs-preview, deploy-docs, and offlinedocs need no changes.

Refs
[DOCS-1131](https://linear.app/codercom/issue/DOCS-1131/author-the-docs-sidebar-in-per-section-yaml-compiled-to)

## Changes

- **Sources:** `docs/manifest/index.yml` holds `versions` and the
section files in sidebar order.
Each section file (`about.yml`, `admin.yml`, and so on) holds one
top-level route.
- **One level per file:** a file holds one route and its direct
children.
A child with children of its own, or with `children_from`, lives in its
own file in a directory named after the parent file, and the parent
lists it as `- include: admin/users.yml`.
For example, `get-started.yml` includes
`get-started/customize-your-template.yml`, which lists that page's
children.
  The 8 section files split into 53 source files.
- **`scripts/docsmanifestgen`:** `build` compiles the sources into
`docs/manifest.json`, `fmt` formats them, and `check` validates them.
- Keys must be known (a typo like `titel:` fails with a line number) and
appear in a fixed order in both the YAML and the JSON.
- Every `path` must exist, and every file under `docs/manifest/` must be
referenced from `index.yml`, an `include`, or a `children_from`.
- A grandchild in the same file fails with a message to move the child
into its own file, and an `include` entry can't set other keys or name a
file that is already used.
- A comment on the same line as a `title` or `description` is rejected,
because an unquoted ` #` would silently cut off the value.
- **Generated fragments:** `clidocgen` and `apidocgen` no longer rewrite
the manifest.
They write the Command Line and REST API children to
`docs/manifest/generated/*.json`, which the sources pull in with
`children_from`.
  The tool accepts fragments as YAML or JSON.
- The hand-written REST API descriptions and states moved into the YAML,
attached to generated routes by title.
A YAML entry that matches no generated route, or disagrees with one,
fails the build instead of being dropped silently.
- **Shared code:** loading, validation, and fragment merging live in
`scripts/docgenenv/sources.go`, so the generators and the tool share one
loader.
`docgenenv.Route` gains YAML tags and the source-only `ChildrenFrom` and
`Include` fields (`json:"-"`).
`LoadManifest` is removed because nothing reads the compiled JSON
anymore.
- **Makefile:**
- `docs/manifest.json` is built from the sources and fragments, which
replaces the `_gen/manifest-staging.json` handoff.
- Each fragment has its own rule, and the fragments are added to the
`.PRECIOUS`, `GEN_FILES`, and `gen/mark-fresh` lists.
  - `DOCS_MANIFEST_SOURCES` finds the source files recursively.
- New targets: `fmt/docs-manifest` (part of `fmt`), `lint/docs-manifest`
(part of `lint`), and `gen/docs-manifest`, the quick path after a
sidebar-only edit that skips regenerating the CLI and API fragments.
- **`.gitattributes`:** marks `docs/manifest.json` and
`docs/manifest/generated/*` as generated so GitHub collapses them in
diffs.
- **Guidance:** the content guidelines, the style guide,
`DOCS_STYLE_GUIDE.md`, the `write-docs` and `doc-check` skills,
`docs/README.md`, and `docs/tutorials/example-guide.md` now point to the
YAML sources instead of `docs/manifest.json`.

## Testing

- Split today's `docs/manifest.json` into the sources, rebuilt it, and
confirmed the output is byte-identical to `main`.
After splitting the sources to one level per file, the rebuilt
`docs/manifest.json` and a fresh `clidocgen` CLI fragment were still
byte-identical, and `LoadManifestSources` still finds the REST API and
Command Line routes through their includes.
After rebasing onto `main`, both commits rebuild `main`'s
`docs/manifest.json` byte for byte.
- Hand-edited `docs/manifest.json` and a YAML source, then rebuilt: the
YAML change persisted and the JSON edit was overwritten.
CI's `make -B gen` plus `check_unstaged.sh` fails on a committed hand
edit to the JSON.
- Deleted both fragments and ran `make docs/manifest.json` in a fresh
worktree, which regenerated them through swag and `clidocgen`.
`docs/manifest.json`, the fragments, and every generated CLI and API
page had no diff.
- Swapped User Guides and Administration in `index.yml`: 2 changed lines
in the source, 166 generated lines in `docs/manifest.json`.
  Swapping back restored the file exactly.
- `go test` for `scripts/docgenenv`, `scripts/docsmanifestgen`,
`scripts/clidocgen`, and `scripts/apidocgen/postprocess`.
The new tests cover merging, includes, every validation error,
idempotent formatting that keeps comments, and a check that the key
order matches the struct field order.
- `golangci-lint` on the changed packages, and the full `make
pre-commit` hook (gen, fmt, lint including `lint/docs-manifest`, and the
slim build).

## Notes

- Open PRs that edit `docs/manifest.json` will need to redo their
sidebar changes in the YAML sources after this merges.
- #30161 (merged) stopped escaping `&`, `<`, and `>` in
`docs/manifest.json`.
This PR carries that over: all manifest JSON escaping is in
`docgenenv.MarshalJSON`, which sets `enc.SetEscapeHTML(false)`, and
`Manifest.Marshal` from #30161 is gone because the generators no longer
write the manifest.
- #30129 (merged) flattened `admin/external-auth/index.md` and
`ai-coder/agents/tools/index.md` to single files, and the YAML sources
use the new paths.
- The CLI index and REST API page front matter still update only on a
full `make gen` when their sidebar metadata changes, as it did before.
That gap and the overall cost of `make gen` are tracked in
[DOCS-1141](https://linear.app/codercom/issue/DOCS-1141/reduce-the-compute-cost-of-make-gen).

<details>
<summary>Decision log</summary>

### Goal

Make the sidebar easy to reorder and hard to break, with strict key
order and YAML sources, while keeping `docs/manifest.json` as the file
downstream systems read.

### Jsonnet vs. a custom tool

Jsonnet was evaluated first and rejected, based on tests against
go-jsonnet v0.22.0:

- Jsonnet always sorts object keys alphabetically, and there's no option
to keep them in order (`preserve_order` isn't a parameter of
`manifestJsonEx` or `objectFieldsEx`).
Passing today's manifest through Jsonnet and then biome changed 2,114 of
2,478 lines.
- Unknown keys pass through silently, so a `titel:` typo ends up in the
output.
- The sources would be `.jsonnet` files, not YAML.
Reading YAML takes `std.parseYaml(importstr ...)`, and the keys still
come out sorted.
- Restoring key order would need a Go step after Jsonnet anyway, and
that step is most of this tool.

Decoding YAML into Go structs with yaml.v3 (already a dependency) gives
key order from the struct, rejects unknown keys, keeps comments, and
reproduced the current manifest byte for byte.

### Design choices

- **Ordered by `index.yml`:** reordering sections touches only the
index.
- **One route and its direct children per file:** every file stays short
and flat, so a subsection can be found, reviewed, and moved as one file.
Files nest by parent file name rather than by docs path, so the
directory tree matches the sidebar tree.
Include paths are relative to `docs/manifest/`, like `children_from`, so
every reference to a file is spelled the same way.
A child with `children_from` also gets its own file, so the rule has no
exceptions.
- **Generated subtrees in their own fragments:** the generators can't
safely rewrite hand-edited YAML, so they own separate files.
Hand-written metadata for generated routes lives in the YAML, attached
by title, so descriptions never live in a generated file.
- **Key order enforced in both sources and output:** `fmt` rewrites the
sources, `check` fails on unformatted sources, and the output order
comes from the `docgenenv.Route` field order.
- **`&` left unescaped:** the output matches `main` after #30161, which
stopped escaping `&` downstream.
- **`gen/docs-manifest` separate from `fmt`:** keeping manifest assembly
out of `fmt` means `make -j gen fmt` never has two jobs writing
`docs/manifest.json` at once.
- **YAML pitfalls:** unquoted `no` and `123` stay strings because the
fields are typed as strings, an unquoted `: ` is a parse error, and the
silent ` #` truncation is rejected by the comment check.

### Out of scope

- Replacing `&` with "and" in titles (a style question).
- Reducing the cost of `make gen` (DOCS-1141).

</details>

---

_This PR was generated by Coder Agents on behalf of @nickvigilante._
This commit is contained in:
Nick Vigilante authored and GitHub committed 2026-09-30 21:27:14 +00:00
1 parent 8e323e435c
commit f1ed84ffab
74 files changed
+3536 -145

No files matched your search

+2 -2
View File
@@ -276,7 +276,7 @@ Document exact values from code:
## Documentation Manifest
Add every documentation page to `docs/manifest.json`; pages missing from the manifest do not appear in navigation. Read the manifest file to understand the structure and find the appropriate section for your documentation. Place new pages in logical sections matching the existing hierarchy.
Add every documentation page to the sidebar sources in `docs/manifest/`; pages missing from the sidebar do not appear in navigation. `docs/manifest/index.yml` lists the top-level section files in sidebar order. Each source file holds one route and its direct children; a child with children of its own lives in its own file under a directory named after its parent file, such as `docs/manifest/admin/users.yml`, and the parent lists it with `- include: admin/users.yml`. Find the source file for the parent page and place new pages in logical sections matching the existing hierarchy. Run `make gen/docs-manifest` to format the sources and rebuild `docs/manifest.json`, which is generated and must not be edited directly.
## Documentation lands with the change
@@ -374,5 +374,5 @@ When you rename or move a doc page, create a PR in coder/coder.com to add the re
[Evidence justifies a claim; it does not belong in the claim](../../docs/.style/content-guidelines.md#evidence-justifies-a-claim-it-does-not-belong-in-the-claim)
3. **Screenshots** - Include one only when the topic needs it; refer to [Screenshot policy](#screenshot-policy)
4. **Link everything** - Related docs, API endpoints, CLI references
5. **Manifest inclusion** - Add to manifest.json for navigation
5. **Manifest inclusion** - Add to `docs/manifest/` for navigation
6. **Add redirects** - When moving/renaming pages, add redirects in coder/coder.com repo
+5 -3
View File
@@ -258,8 +258,10 @@ only on the user-facing portion.
## Key Documentation Info
- **`docs/manifest.json`** is the navigation structure; new pages MUST be
added here.
- **`docs/manifest/**/*.yml`** is the navigation structure; new pages MUST be
added to the right source file there. Each file holds one route and its
direct children, and `include` pulls in a child's own file. `docs/manifest.json` is compiled
from it by `make gen/docs-manifest`; don't edit the JSON directly.
- **`docs/reference/cli/*.md`** is auto-generated from Go code. Don't
edit directly.
- **`docs/.style/content-guidelines.md`** is the canonical source for
@@ -267,7 +269,7 @@ only on the user-facing portion.
### Premium feature signaling
Pages documenting staged features must include the applicable `state` in their `docs/manifest.json` entry.
Pages documenting staged features must include the applicable `state` in their route in `docs/manifest/**/*.yml`, such as `state: [premium]`.
Do not add feature-state suffixes such as `(Premium)` or `(Beta)` to page titles or H1s.
The state is displayed in navigation metadata.
+5 -4
View File
@@ -69,9 +69,10 @@ style.
3. **Pick the Diátaxis mode and the manifest slot.** Choose one mode per page
(tutorial, how-to guide, reference, or explanation) per
the Diátaxis framework in the [content guidelines](../../../docs/.style/content-guidelines.md#follow-the-diátaxis-framework).
One outcome per page. New pages MUST be added to `docs/manifest.json` under
the right section, and the documentation lands in the same change as the
feature. If the change introduces, renames, or deprecates a Coder product
One outcome per page. New pages MUST be added to the right source file in
`docs/manifest/` (then run `make gen/docs-manifest`), and the documentation
lands in the same change as the feature. If the change introduces,
renames, or deprecates a Coder product
or feature name, update the [glossary](../../../docs/reference/glossary.md)
in the same change (add, edit, or mark the entry) per the
[Structural rules](../../../docs/.style/content-guidelines.md#structural-rules).
@@ -187,7 +188,7 @@ the whole series as a single review.
unverified for the reviewer.
- [ ] The content belongs in `docs/`; anything that does not was routed.
- [ ] One outcome per page, correct Diátaxis mode, added to
`docs/manifest.json`.
`docs/manifest/`, and `docs/manifest.json` rebuilt.
- [ ] New, renamed, or deprecated product or feature names have a matching
`docs/reference/glossary.md` entry (a rename keeps the former name; a
deprecation names the replacement).
+2
View File
@@ -6,6 +6,8 @@ coderd/apidoc/docs.go linguist-generated=true
coderd/externalauth/gitprovider/testdata/*/*/*.yaml linguist-generated=true
docs/reference/api/*.md linguist-generated=true
docs/reference/cli/**/*.md linguist-generated=true
docs/manifest.json linguist-generated=true
docs/manifest/generated/* linguist-generated=true
coderd/apidoc/swagger.json linguist-generated=true
coderd/database/dump.sql linguist-generated=true
+70 -11
View File
@@ -76,6 +76,8 @@ endif
site/src/theme/icons.json \
examples/examples.gen.json \
docs/manifest.json \
docs/manifest/generated/cli.json \
docs/manifest/generated/rest-api.json \
docs/admin/integrations/prometheus.md \
docs/admin/security/audit-logs.md \
docs/admin/setup/configuration-reference.md \
@@ -111,6 +113,16 @@ CLIDOCGEN_INPUTS := \
scripts/clidocgen/command.tpl \
$(CLIDOC_SRC_FILES)
# Hand-edited YAML sidebar sources that docsmanifestgen compiles, together
# with the generated fragments under docs/manifest/generated, into
# docs/manifest.json. Each file holds one route and one level of children, so
# the sources nest in subdirectories.
DOCS_MANIFEST_SOURCES := $(shell find docs/manifest -type f -name '*.yml' -not -path 'docs/manifest/generated/*')
DOCSMANIFESTGEN_INPUTS := \
$(filter-out %_test.go,$(wildcard scripts/docsmanifestgen/*.go)) \
$(filter-out %_test.go,$(wildcard scripts/docgenenv/*.go))
# Helper binaries that import repo packages need their compile-time inputs on
# the binary target. Most generated outputs keep these binaries as order-only
# prereqs, so stale binaries otherwise survive source changes.
@@ -159,6 +171,10 @@ _gen/bin/clidocgen: $(CLIDOCGEN_INPUTS) | _gen
@mkdir -p _gen/bin
go build -o $@ ./scripts/clidocgen
_gen/bin/docsmanifestgen: $(DOCSMANIFESTGEN_INPUTS) | _gen
@mkdir -p _gen/bin
go build -o $@ ./scripts/docsmanifestgen
# configdocgen reflects over codersdk.DeploymentValues to produce the
# configuration reference page.
_gen/bin/configdocgen: $(wildcard scripts/configdocgen/*.go) $(wildcard codersdk/*.go) | _gen
@@ -632,7 +648,7 @@ YELLOW := $(shell tput setaf 3 2>/dev/null)
DIM := $(shell tput dim 2>/dev/null || tput setaf 8 2>/dev/null)
RESET := $(shell tput sgr0 2>/dev/null)
fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/biome fmt/markdown
fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/biome fmt/markdown fmt/docs-manifest
.PHONY: fmt
# Subset of fmt that does not require Go or Node toolchains.
@@ -739,11 +755,25 @@ else
endif
.PHONY: fmt/markdown
# Formats the YAML sidebar sources under docs/manifest: canonical key order,
# two-space indentation, and quoting only where YAML needs it.
fmt/docs-manifest: _gen/bin/docsmanifestgen
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/docs-manifest$(RESET)"
_gen/bin/docsmanifestgen fmt
.PHONY: fmt/docs-manifest
# Formats the sidebar sources and rebuilds docs/manifest.json from them and
# the committed generated fragments. Run this after editing the sidebar. It
# skips regenerating the CLI and REST API fragments, which make gen does.
gen/docs-manifest: fmt/docs-manifest site/node_modules/.installed | _gen
$(build-docs-manifest)
.PHONY: gen/docs-manifest
# Note: we don't run zizmor in the lint target because it takes a while.
# GitHub Actions linters are run in a separate CI job (lint-actions) that only
# triggers when workflow files change, so we skip them here when CI=true.
LINT_ACTIONS_TARGETS := $(if $(CI),,lint/actions/actionlint)
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/docs-html lint/style-claims lint/check-scopes lint/migrations lint/bootstrap lint/architecture lint/emdash lint/agents lint/mise-versions $(LINT_ACTIONS_TARGETS)
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/docs-html lint/docs-manifest lint/style-claims lint/check-scopes lint/migrations lint/bootstrap lint/architecture lint/emdash lint/agents lint/mise-versions $(LINT_ACTIONS_TARGETS)
.PHONY: lint
# Fast lint subset for lightweight hooks. Some targets use mise-managed tools.
@@ -796,6 +826,14 @@ lint/docs-html:
go run ./scripts/docshtmlcheck
.PHONY: lint/docs-html
# Fails when the YAML sidebar sources under docs/manifest are unformatted or
# invalid: unknown or misordered keys, missing pages, overlays that match no
# generated route, or source files that nothing references.
lint/docs-manifest: _gen/bin/docsmanifestgen
echo "--- check docs sidebar sources"
_gen/bin/docsmanifestgen check
.PHONY: lint/docs-manifest
# Fails when the style guide claims a prose rule is enforced by tooling that is
# not enabled, when an enabled rule has no style guide section, or when the
# coverage tables on the style guide landing page drift from the annotations.
@@ -1036,6 +1074,8 @@ GEN_FILES := \
docs/admin/setup/configuration-reference.md \
coderd/apidoc/swagger.json \
docs/manifest.json \
docs/manifest/generated/cli.json \
docs/manifest/generated/rest-api.json \
provisioner/terraform/testdata/generation.sha1 \
scripts/metricsdocgen/generated_metrics \
site/e2e/provisionerGenerated.ts \
@@ -1134,6 +1174,8 @@ gen/mark-fresh:
docs/admin/setup/configuration-reference.md \
coderd/apidoc/swagger.json \
docs/manifest.json \
docs/manifest/generated/cli.json \
docs/manifest/generated/rest-api.json \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json \
@@ -1353,7 +1395,7 @@ docs/reference/cli/index.md: node_modules/.installed examples/examples.gen.json
tmpdir=$$(mktemp -d -p _gen) && \
tmpdir=$$(realpath "$$tmpdir") && \
mkdir -p "$$tmpdir/docs/reference/cli" && \
cp docs/manifest.json "$$tmpdir/docs/manifest.json" && \
cp -R docs/manifest "$$tmpdir/docs/manifest" && \
CI=true DOCS_DIR="$$tmpdir/docs" _gen/bin/clidocgen && \
pnpm exec markdownlint-cli2 --fix "$$tmpdir/docs/reference/cli/**/*.md" && \
pnpm exec markdown-table-formatter "$$tmpdir/docs/reference/cli/**/*.md" && \
@@ -1393,26 +1435,43 @@ coderd/apidoc/.gen: \
tmpdir=$$(mktemp -d -p _gen) && swagtmp=$$(mktemp -d -p _gen) && \
tmpdir=$$(realpath "$$tmpdir") && swagtmp=$$(realpath "$$swagtmp") && \
mkdir -p "$$tmpdir/reference/api" && \
cp docs/manifest.json "$$tmpdir/manifest.json" && \
cp -R docs/manifest "$$tmpdir/manifest" && \
SWAG_OUTPUT_DIR="$$swagtmp" APIDOCGEN_DOCS_DIR="$$tmpdir" ./scripts/apidocgen/generate.sh && \
pnpm exec markdownlint-cli2 --fix "$$tmpdir/reference/api/*.md" && \
pnpm exec markdown-table-formatter "$$tmpdir/reference/api/*.md" && \
./scripts/biome_format.sh "$$swagtmp/swagger.json" && \
./scripts/biome_format.sh "$$tmpdir/manifest/generated/rest-api.json" && \
for f in "$$tmpdir/reference/api/"*.md; do mv "$$f" "docs/reference/api/$$(basename "$$f")"; done && \
mv "$$tmpdir/manifest.json" _gen/manifest-staging.json && \
mv "$$tmpdir/manifest/generated/rest-api.json" docs/manifest/generated/rest-api.json && \
mv "$$swagtmp/docs.go" coderd/apidoc/docs.go && \
mv "$$swagtmp/swagger.json" coderd/apidoc/swagger.json && \
rm -rf "$$tmpdir" "$$swagtmp"
touch "$@"
# The API doc rule stages the manifest with its section rebuilt; clidocgen then
# rebuilds the "Command Line" section on top of it so both land in the tree.
docs/manifest.json: site/node_modules/.installed coderd/apidoc/.gen docs/reference/cli/index.md _gen/bin/clidocgen | _gen
# apidocgen writes the REST API sidebar fragment named by children_from in
# docs/manifest; the rule above moves it into place.
docs/manifest/generated/rest-api.json: coderd/apidoc/.gen
touch "$@"
# clidocgen writes the "Command Line" sidebar fragment named by children_from
# in docs/manifest, built from the command tree.
docs/manifest/generated/cli.json: site/node_modules/.installed _gen/bin/clidocgen | _gen
tmpdir=$$(mktemp -d -p _gen) && tmpdir=$$(realpath "$$tmpdir") && \
cp _gen/manifest-staging.json "$$tmpdir/manifest.json" && \
cp -R docs/manifest "$$tmpdir/manifest" && \
CI=true DOCS_DIR="$$tmpdir" _gen/bin/clidocgen -manifest-only && \
./scripts/biome_format.sh "$$tmpdir/manifest.json" && \
mv "$$tmpdir/manifest.json" "$@" && rm -rf "$$tmpdir"
./scripts/biome_format.sh "$$tmpdir/manifest/generated/cli.json" && \
mv "$$tmpdir/manifest/generated/cli.json" "$@" && rm -rf "$$tmpdir"
# Compiles the sidebar sources and generated fragments into docs/manifest.json.
define build-docs-manifest
tmpdir=$$(mktemp -d -p _gen) && tmpfile=$$(realpath "$$tmpdir")/manifest.json && \
_gen/bin/docsmanifestgen build -out "$$tmpfile" && \
./scripts/biome_format.sh "$$tmpfile" && \
mv "$$tmpfile" docs/manifest.json && rm -rf "$$tmpdir"
endef
docs/manifest.json: $(DOCS_MANIFEST_SOURCES) docs/manifest/generated/cli.json docs/manifest/generated/rest-api.json site/node_modules/.installed _gen/bin/docsmanifestgen docs/reference/cli/index.md | _gen
$(build-docs-manifest)
coderd/apidoc/swagger.json: site/node_modules/.installed coderd/apidoc/.gen
touch "$@"
+4 -3
View File
@@ -231,13 +231,14 @@ Each entry includes the reason it belongs in the docs.
These govern *how* content enters the docs, for both humans and the doc-check agent.
- **Every new page must be added to `docs/manifest.json`.**
Pages not in the manifest don't appear in navigation and effectively don't exist on [coder.com/docs](https://coder.com/docs).
- **Every new page must be added to the sidebar sources in `docs/manifest/`.**
Pages not in the sidebar don't appear in navigation and effectively don't exist on [coder.com/docs](https://coder.com/docs).
Run `make gen/docs-manifest` to rebuild `docs/manifest.json` from the sources; don't edit the JSON directly.
- **Never hand-edit auto-generated content.**
Files under `docs/reference/cli/` are generated from Go code; changes go in the CLI definitions (typically under `cli/`), then regenerate.
Generated sections are marked with `<!-- Code generated ... DO NOT EDIT -->`.
- **Feature states are marked in navigation metadata.**
The page's `docs/manifest.json` entry must include its state, such as `"state": ["premium"]` or `"state": ["beta"]`.
The page's route in `docs/manifest/` must include its state, such as `state: [premium]` or `state: [beta]`.
Do not add a feature-state suffix to the page title or H1.
- **Moving or renaming a page requires link updates and a redirect.**
If a page changes its position in the directory structure:
@@ -353,7 +353,7 @@ A page's H1 and its sidebar title serve different jobs and may diverge.
Refer to [Declare audience and scope up front](./audience-and-scope.md#declare-audience-and-scope-up-front) for how the H1 names the outcome.
- The **sidebar title** is a navigation label.
It fits the limited horizontal space of the sidebar and reads fast when the reader is scanning a tree of dozens of pages.
The Coder docs site reads the sidebar title from the `title` field in [`docs/manifest.json`](../../manifest.json).
The Coder docs site reads the sidebar title from the `title` field of the page's route in the sidebar sources under [`docs/manifest/`](../../manifest/index.yml).
The two must each stand alone, but they don't need to be identical.
Breadcrumb depth already supplies one layer of context.
@@ -396,15 +396,13 @@ No Vale rule.*
## Page descriptions
Each page declares a description that appears in search engine results, in social-media previews, and in screen-reader page summaries.
The Coder docs site reads descriptions from [`docs/manifest.json`](../../manifest.json), not from YAML front matter inside the Markdown file.
The manifest maps each page to a `title` and a `description`:
The Coder docs site reads descriptions from `docs/manifest.json`, not from YAML front matter inside the Markdown file.
That file is compiled from the sidebar sources under [`docs/manifest/`](../../manifest/index.yml), where each route maps a page to a `title` and a `description`:
```json
{
"title": "Configure your workspace",
"description": "Configure SSH access, environment variables, and autostart for a Coder workspace.",
"path": "./admin/workspaces/configure.md"
}
```yaml
- title: Configure your workspace
description: Configure SSH access, environment variables, and autostart for a Coder workspace.
path: ./admin/workspaces/configure.md
```
A good description:
@@ -416,24 +414,24 @@ A good description:
**Do**:
```json
"description": "Configure SSH access, environment variables, and autostart for a Coder workspace."
```yaml
description: Configure SSH access, environment variables, and autostart for a Coder workspace.
```
**Don't**:
```json
"description": "Workspace configuration"
```yaml
description: Workspace configuration
```
```json
"description": "The best, fastest, most reliable way to configure everything you need to know about Coder workspaces."
```yaml
description: The best, fastest, most reliable way to configure everything you need to know about Coder workspaces.
```
The short description tells the reader nothing.
The marketing description doesn't survive truncation and adds no information.
If a page doesn't yet have a description in the manifest, add one in the same PR that touches the page.
If a page doesn't yet have a description in the sidebar sources, add one in the same PR that touches the page.
*Documentation-only.
No Vale rule.*
+1 -1
View File
@@ -3,7 +3,7 @@ title: About
markdown_url: /docs.md
---
<!-- Warning for docs contributors: The first route in manifest.json must be titled "About" for the static landing page to work correctly. -->
<!-- Warning for docs contributors: The first section in docs/manifest/index.yml must be titled "About" for the static landing page to work correctly. -->
Coder is a self-hosted platform for running AI coding agents and cloud
development environments on infrastructure you control. It works with any
+9
View File
@@ -0,0 +1,9 @@
title: About
description: Coder is a self-hosted platform for running AI coding agents and cloud development environments on the infrastructure you control.
path: ./README.md
icon_path: ./images/icons/home.svg
children:
- title: Screenshots
description: See screenshots of the Coder platform, including browser-based workspace access and the admin dashboard.
path: ./about/screenshots.md
- include: about/support.yml
+7
View File
@@ -0,0 +1,7 @@
title: Support
description: Get help with your Coder deployment through GitHub issues, our Discord community, and premium support.
path: ./support/index.md
children:
- title: Support bundle
description: Generate a support bundle and share workspace and deployment diagnostics with Coder support to troubleshoot issues.
path: ./support/support-bundle.md
+16
View File
@@ -0,0 +1,16 @@
title: Administration
description: Guides for the template and deployment administrators who configure, secure, and operate Coder.
path: ./admin/index.md
icon_path: ./images/icons/wrench.svg
children:
- include: admin/setup.yml
- include: admin/users.yml
- include: admin/templates.yml
- title: External authentication
description: Configure external authentication so workspaces can access Git providers and other OAuth services.
path: ./admin/external-auth.md
icon_path: ./images/icons/plug.svg
- include: admin/integrations.yml
- include: admin/networking.yml
- include: admin/monitoring.yml
- include: admin/security.yml
+31
View File
@@ -0,0 +1,31 @@
title: Integrations
description: Extend Coder with integrations for observability, secrets, source control, and other platforms.
path: ./admin/integrations/index.md
icon_path: ./images/icons/puzzle.svg
children:
- title: Prometheus
description: Collect and export Coder deployment metrics to a Prometheus server for monitoring.
path: ./admin/integrations/prometheus.md
- title: Kubernetes event logs
description: Stream Kubernetes event logs into workspace startup logs to debug pod scheduling issues.
path: ./admin/integrations/kubernetes-logs.md
- title: Additional clusters
description: Deploy Coder workspaces across additional Kubernetes clusters beyond the control plane cluster.
path: ./admin/integrations/multiple-kube-clusters.md
- title: JFrog Artifactory
description: Integrate Coder with JFrog Artifactory to secure workspaces and manage packages and tokens.
path: ./admin/integrations/jfrog-artifactory.md
- title: Island browser integration
description: Integrate Coder with the Island Enterprise Browser for secure, policy-controlled workspace access.
path: ./admin/integrations/island.md
- title: DX PlatformX
description: Forward Coder notifications to DX PlatformX to measure and improve developer experience.
path: ./admin/integrations/platformx.md
- title: DX Data Cloud
description: Tag and sync Coder users with DX Data Cloud to measure developer productivity.
path: ./admin/integrations/dx-data-cloud.md
- title: HashiCorp Vault
description: Integrate Coder with HashiCorp Vault to inject secrets securely into your workspaces.
path: ./admin/integrations/vault.md
- include: admin/integrations/oauth2-provider.yml
- include: admin/integrations/devcontainers.yml
@@ -0,0 +1,8 @@
title: Dev Containers
description: Configure dev container support in your templates using either Docker or Envbuilder.
path: ./admin/integrations/devcontainers/index.md
children:
- title: Configure a template for Dev Containers
description: Configure a Coder template for native dev containers backed by Docker.
path: ./admin/integrations/devcontainers/integration.md
- include: admin/integrations/devcontainers/envbuilder.yml
@@ -0,0 +1,13 @@
title: Envbuilder
description: Use Envbuilder to build dev containers from a repository without requiring Docker.
path: ./admin/integrations/devcontainers/envbuilder/index.md
children:
- title: Add an Envbuilder template
description: Add an Envbuilder-compatible template so users can build dev containers from a repository.
path: ./admin/integrations/devcontainers/envbuilder/add-envbuilder.md
- title: Security and caching
description: Configure Envbuilder registry authentication and layer caching for faster, secure builds.
path: ./admin/integrations/devcontainers/envbuilder/envbuilder-security-caching.md
- title: Releases and known issues
description: Learn about Envbuilder's release channels and current known issues before you deploy it.
path: ./admin/integrations/devcontainers/envbuilder/envbuilder-releases-known-issues.md
@@ -0,0 +1,22 @@
title: OAuth2 provider
description: Use Coder as an OAuth2 authorization server so third-party apps can authenticate users.
path: ./admin/integrations/oauth2-provider/index.md
children:
- title: Integration patterns
description: Client authentication methods, the standard flow, the required PKCE flow, and discovery endpoints.
path: ./admin/integrations/oauth2-provider/integration-patterns.md
- title: Scopes
description: How access tokens are bounded by scope, and how to set an application's scope allowlist.
path: ./admin/integrations/oauth2-provider/scopes.md
- title: Token management
description: Refresh an access token, revoke a token, and delete an OAuth2 application.
path: ./admin/integrations/oauth2-provider/token-management.md
- title: Callback URL schemes
description: Which redirect URI schemes and hosts Coder accepts.
path: ./admin/integrations/oauth2-provider/callback-url-schemes.md
- title: Troubleshooting
description: Diagnose and fix OAuth2 provider errors by their exact error code or message.
path: ./admin/integrations/oauth2-provider/troubleshooting.md
- title: Security and limitations
description: Security considerations and current limitations of the OAuth2 provider.
path: ./admin/integrations/oauth2-provider/security.md
+19
View File
@@ -0,0 +1,19 @@
title: Monitoring
description: Monitor your Coder deployment with logs, metrics, health checks, and alerting best practices.
path: ./admin/monitoring/index.md
icon_path: ./images/icons/speed.svg
children:
- title: Logs
description: Learn how Coder services write logs to standard output and how to collect them.
path: ./admin/monitoring/logs.md
- title: Metrics
description: Learn about the deployment metrics Coder exposes and how to use them to monitor health.
path: ./admin/monitoring/metrics.md
- title: Deployment health
description: Use Coder's deployment health page to monitor your control plane and its dependencies.
path: ./admin/monitoring/health-check.md
- title: Connection logs
description: Monitor SSH, app, and agent connections to your workspaces with the connection log.
path: ./admin/monitoring/connection-logs.md
state: [premium]
- include: admin/monitoring/notifications.yml
@@ -0,0 +1,10 @@
title: Notifications
description: Configure how Coder sends notifications for deployment events over email and webhooks.
path: ./admin/monitoring/notifications/index.md
children:
- title: Slack notifications
description: Set up a Slack integration to deliver Coder notifications to your channels.
path: ./admin/monitoring/notifications/slack.md
- title: Microsoft Teams notifications
description: Set up a Microsoft Teams integration to deliver Coder notifications to your channels.
path: ./admin/monitoring/notifications/teams.md
+25
View File
@@ -0,0 +1,25 @@
title: Networking
description: Understand Coder's networking model, including how workspaces, servers, and clients connect.
path: ./admin/networking/index.md
icon_path: ./images/icons/networking.svg
children:
- title: Port forwarding
description: Learn how port forwarding works in Coder and how to expose workspace ports to users.
path: ./admin/networking/port-forwarding.md
- title: STUN and NAT
description: Learn how Coder uses STUN and NAT traversal to establish direct peer-to-peer workspace connections.
path: ./admin/networking/stun.md
- title: Workspace proxies
description: Run geo-distributed workspace proxies to give distributed teams low-latency workspace access.
path: ./admin/networking/workspace-proxies.md
state: [premium]
- title: High availability
description: Configure Coder in high availability (HA) mode for horizontal scalability and failover.
path: ./admin/networking/high-availability.md
state: [premium]
- title: Wildcard access URLs
description: Configure a wildcard access URL to enable port forwarding, web IDEs, and app previews.
path: ./admin/networking/wildcard-access-url.md
- title: Troubleshooting
description: Diagnose and resolve Coder networking issues using coder ping and other built-in tools.
path: ./admin/networking/troubleshooting.md
+16
View File
@@ -0,0 +1,16 @@
title: Security
description: Secure your Coder deployment with audit logs, secrets management, and database encryption.
path: ./admin/security/index.md
icon_path: ./images/icons/lock.svg
children:
- title: Audit logs
description: Track user and administrator actions across your Coder deployment with audit logs.
path: ./admin/security/audit-logs.md
state: [premium]
- title: Secrets
description: Learn the recommended ways to get secrets into your Coder workspaces securely.
path: ./admin/security/secrets.md
- title: Database encryption
description: Encrypt sensitive values in the Coder database to protect tokens and secrets at rest.
path: ./admin/security/database-encryption.md
state: [premium]
+22
View File
@@ -0,0 +1,22 @@
title: Configure control plane access
description: Configure your Coder control plane with server settings and environment variables.
path: ./admin/setup/index.md
icon_path: ./images/icons/toggle_on.svg
children:
- title: Appearance
description: Customize your Coder deployment's appearance, including the logo, service banner, and application name.
path: ./admin/setup/appearance.md
state: [premium]
- title: Configuration reference
description: Searchable list of every Coder server setting with its environment variable, CLI flag, and YAML key
path: ./admin/setup/configuration-reference.md
- title: Telemetry
description: Learn what usage telemetry Coder collects, why it is collected, and how to opt out.
path: ./admin/setup/telemetry.md
- title: Chat lifecycle hooks
description: Configure an external policy service for chat agent lifecycle events
path: ./admin/setup/chat-lifecycle-hooks.md
state: [early access]
- title: Data retention
description: Configure retention policies that automatically purge old records from Coder database tables.
path: ./admin/setup/data-retention.md
+20
View File
@@ -0,0 +1,20 @@
title: Templates
description: Learn how to author, publish, and maintain the Coder templates that define your workspaces.
path: ./admin/templates/index.md
icon_path: ./images/icons/picture.svg
children:
- title: Creating templates
description: Create a Coder template with Terraform to define the infrastructure for your workspaces.
path: ./admin/templates/creating-templates.md
- include: admin/templates/managing-templates.yml
- include: admin/templates/extending-templates.yml
- title: Open in Coder
description: Add an Open in Coder button to your repositories and wikis so users can create workspaces fast.
path: ./admin/templates/open-in-coder.md
- title: Permissions
description: Control which users and groups can use, edit, and administer each Coder template.
path: ./admin/templates/template-permissions.md
state: [premium]
- title: Troubleshoot templates
description: Troubleshoot common Coder template problems, from failed builds to misconfigured workspaces.
path: ./admin/templates/troubleshooting.md
@@ -0,0 +1,70 @@
title: Extend templates
description: Extend your Coder templates with parameters, metadata, web IDEs, Docker, and more.
path: ./admin/templates/extending-templates/index.md
children:
- title: Agent metadata
description: Display real-time metrics from the workspace agent, such as CPU, memory, and disk usage.
path: ./admin/templates/extending-templates/agent-metadata.md
- title: Parameters
description: Use build parameters to prompt users and customize each workspace when it is created.
path: ./admin/templates/extending-templates/parameters.md
- title: Dynamic parameters
description: Build conditional, identity-aware template forms with Coder's dynamic parameters.
path: ./admin/templates/extending-templates/dynamic-parameters.md
- title: Prebuilt workspaces
description: Pre-provision a ready-to-deploy workspace with a defined set of parameters
path: ./admin/templates/extending-templates/prebuilt-workspaces.md
state: [premium]
- title: Icons
description: Customize your Coder templates and resources with built-in or custom icons.
path: ./admin/templates/extending-templates/icons.md
- title: Resource metadata
description: Expose key workspace resource information to your users in the Coder dashboard with metadata.
path: ./admin/templates/extending-templates/resource-metadata.md
- title: Resource monitoring
description: Monitor workspace resource usage and alert on thresholds from the Coder dashboard.
path: ./admin/templates/extending-templates/resource-monitoring.md
- title: UI resource ordering
description: Control the order that resources and parameters appear in the workspace creation UI.
path: ./admin/templates/extending-templates/resource-ordering.md
- title: Resource persistence
description: Control which workspace resources persist across restarts and which are recreated on each build.
path: ./admin/templates/extending-templates/resource-persistence.md
- title: Environment variables
description: Inject environment variables into Coder workspaces using the coder_env Terraform resource.
path: ./admin/templates/extending-templates/environment-variables.md
- title: Terraform template-wide variables
description: Use Terraform template-wide variables to parameterize and manage your Coder templates.
path: ./admin/templates/extending-templates/variables.md
- title: Reuse template code
description: Reuse Terraform code across your Coder templates with shared, versioned modules.
path: ./admin/templates/extending-templates/modules.md
- title: Web IDEs in templates
description: Add and configure web IDEs in your Coder templates as coder_app resources.
path: ./admin/templates/extending-templates/web-ides.md
- title: Pre-install JetBrains IDEs
description: Pre-install JetBrains IDE backends in your template for faster first-time connections.
path: ./admin/templates/extending-templates/jetbrains-preinstall.md
- title: JetBrains IDEs in an air-gapped environment
description: Configure JetBrains IDEs to work in air-gapped Coder deployments without internet access.
path: ./admin/templates/extending-templates/jetbrains-airgapped.md
- title: Docker in workspaces
description: Run Docker inside container-based Coder workspaces using several supported approaches.
path: ./admin/templates/extending-templates/docker-in-workspaces.md
- title: Workspace tags
description: Route workspace builds to specific provisioners using workspace tags and parameters.
path: ./admin/templates/extending-templates/workspace-tags.md
- title: Provider authentication
description: Authenticate the Coder control plane to cloud provider APIs so it can provision workspaces.
path: ./admin/templates/extending-templates/provider-authentication.md
- title: Dev Containers
description: Extend your Coder templates with containerized dev container development environments.
path: ./admin/templates/extending-templates/devcontainers.md
- title: Improve agent resiliency
description: Improve workspace agent resiliency by tuning child process CPU and out-of-memory priority.
path: ./admin/templates/extending-templates/process-priority.md
- title: Workspace process logging
description: Log all system-level process activity inside workspaces for security and auditing.
path: ./admin/templates/extending-templates/process-logging.md
state: [premium]
- include: admin/templates/extending-templates/startup-coordination.yml
@@ -0,0 +1,14 @@
title: Workspace startup coordination
description: Coordinate workspace startup scripts with dependency management so they run in the right order.
path: ./admin/templates/startup-coordination/index.md
state: [early access]
children:
- title: Usage
description: Declare units and dependencies with coder exp sync to coordinate your workspace startup scripts.
path: ./admin/templates/startup-coordination/usage.md
- title: Troubleshooting
description: Diagnose and resolve common problems with workspace startup coordination and coder exp sync.
path: ./admin/templates/startup-coordination/troubleshooting.md
- title: Examples
description: A complete, production-ready example of coordinating workspace startup scripts with sync units.
path: ./admin/templates/startup-coordination/example.md
@@ -0,0 +1,23 @@
title: Work with templates
description: Learn how to edit, version, and manage Coder templates, along with recommended best practices.
path: ./admin/templates/managing-templates/index.md
children:
- title: Image management
description: Learn how to build and manage the container images that back your Coder templates.
path: ./admin/templates/managing-templates/image-management.md
- title: Change management
description: Manage Coder template changes with source control, versioning, and CI/CD publishing.
path: ./admin/templates/managing-templates/change-management.md
- title: Envbuilder
description: Use Envbuilder to shift workspace environment definitions from templates into your Git repositories.
path: ./admin/templates/managing-templates/envbuilder.md
- title: Template dependencies
description: Manage provider and module dependencies in your Coder templates to keep builds reproducible.
path: ./admin/templates/managing-templates/dependencies.md
- title: Workspace scheduling
description: Configure template settings that control how workspaces autostart, autostop, and stay available.
path: ./admin/templates/managing-templates/schedule.md
- title: External workspaces
description: Connect externally managed servers and machines to Coder as external workspaces.
path: ./admin/templates/managing-templates/external-workspaces.md
state: [premium, early access]
+35
View File
@@ -0,0 +1,35 @@
title: Users
description: Learn how to create, manage, and audit users and their access in your Coder deployment.
path: ./admin/users/index.md
icon_path: ./images/icons/users.svg
children:
- include: admin/users/oidc-auth.yml
- title: GitHub
description: Set up authentication through GitHub OAuth to enable secure user login and sign-up
path: ./admin/users/github-auth.md
- title: Password authentication
description: Manage username/password authentication settings and user password reset workflows
path: ./admin/users/password-auth.md
- title: Headless authentication
description: Create and manage headless service accounts for automated systems and API integrations
path: ./admin/users/headless-auth.md
state: [premium]
- title: Groups and roles
description: Manage access control with user groups and role-based permissions for Coder resources
path: ./admin/users/groups-roles.md
state: [premium]
- title: IdP sync
description: Synchronize user groups, roles, and organizations from your identity provider to Coder
path: ./admin/users/idp-sync.md
state: [premium]
- title: Organizations
description: Segment and isolate resources by creating separate organizations for different teams or projects
path: ./admin/users/organizations.md
state: [premium]
- title: Quotas
description: Control resource usage by implementing workspace budgets and credit-based cost management
path: ./admin/users/quotas.md
state: [premium]
- title: API & session tokens
description: Manage authentication tokens for API access and configure session duration policies
path: ./admin/users/sessions-tokens.md
+13
View File
@@ -0,0 +1,13 @@
title: OpenID Connect
description: Configure OpenID Connect authentication with identity providers like Okta or Active Directory
path: ./admin/users/oidc-auth/index.md
children:
- title: Google
description: Configure Coder to authenticate users with Google using OpenID Connect (OIDC).
path: ./admin/users/oidc-auth/google.md
- title: Microsoft
description: Configure Coder to authenticate users with Microsoft Entra ID using OpenID Connect (OIDC).
path: ./admin/users/oidc-auth/microsoft.md
- title: Configure OIDC refresh tokens
description: Configure OIDC refresh tokens so Coder can keep user sessions active beyond token expiration.
path: ./admin/users/oidc-auth/refresh-tokens.md
+18
View File
@@ -0,0 +1,18 @@
title: Run AI coding agents in Coder
description: Run and manage AI coding agents like Claude Code and Codex in Coder workspaces, alongside your existing development environments.
path: ./ai-coder/index.md
icon_path: ./images/icons/wand.svg
children:
- title: Best practices
description: Cultural and technical best practices for introducing AI coding agents into your organization.
path: ./ai-coder/best-practices.md
- title: In the IDE
description: Run in-IDE AI coding assistants and agents while backing their compute with Coder workspaces.
path: ./ai-coder/ide-agents.md
- include: ai-coder/agents.yml
- include: ai-coder/agent-relay.yml
- include: ai-coder/ai-governance.yml
- title: MCP server
description: Connect external AI coding agents to Coder using its built-in Model Context Protocol server.
path: ./ai-coder/mcp-server.md
state: [beta]
+13
View File
@@ -0,0 +1,13 @@
title: Agent Relay
description: Connect supported cloud-hosted AI agents to self-hosted Coder workspaces with Agent Relay.
path: ./ai-coder/agent-relay/index.md
state: [early access]
children:
- title: Agent Relay for Cursor
description: Run Cursor's cloud agent sessions inside self-hosted Coder workspaces with Agent Relay.
path: ./ai-coder/agent-relay/cursor.md
state: [early access]
- title: Agent Relay for Claude Code
description: Run Claude Code's cloud sessions inside self-hosted Coder workspaces with Agent Relay.
path: ./ai-coder/agent-relay/claude-code.md
state: [early access]
+32
View File
@@ -0,0 +1,32 @@
title: Coder Agents
description: Delegate development work to coding agents in your deployment with Coder Agents, a chat interface and API.
path: ./ai-coder/agents/index.md
children:
- title: Getting started
description: Enable Coder Agents, prepare your deployment, and run your first Coder Agent
path: ./ai-coder/agents/getting-started.md
- title: Architecture
description: Learn how the Coder Agents control-plane agent communicates with your workspaces.
path: ./ai-coder/agents/architecture.md
- include: ai-coder/agents/platform-controls.yml
- title: Extending agents
description: Extend Coder Agents with custom skills and MCP tools defined in your workspace templates.
path: ./ai-coder/agents/extending-agents.md
- title: Models
description: Configure the LLM providers and models that power Coder Agents from Admin settings.
path: ./ai-coder/agents/models.md
- title: Tools
description: How Coder Agents uses tool calls to select templates and create workspaces
path: ./ai-coder/agents/tools.md
- title: Chat sharing
description: Give other users and groups read-only access to a Coder Agents conversation with chat sharing.
path: ./ai-coder/agents/chat-sharing.md
- title: Conversation search syntax
description: Filter Coder Agents conversations by title, status, and linked pull requests with search syntax.
path: ./ai-coder/agents/chat-search-syntax.md
- title: Licensing & usage
description: Compare Coder Agents licenses and learn how Coder measures and reports Agent Time usage.
path: ./ai-coder/agents/licensing-usage.md
- title: Migrate from the Tasks API to the Chats API
description: Migrate your integrations from the removed Coder Tasks API to the Coder Agents Chats API.
path: ./ai-coder/agents/tasks-to-chats-migration.md
@@ -0,0 +1,44 @@
title: Platform controls
description: Learn how platform teams control Coder Agents behavior, models, spend, and policies.
path: ./ai-coder/agents/platform-controls/index.md
children:
- title: Template optimization
description: Best practices for creating templates that are discoverable and useful to Coder Agents
path: ./ai-coder/agents/platform-controls/template-optimization.md
- title: Organization scope
description: Learn which Coder Agents settings belong to an organization, what an upgrade migrates, and who can change them.
path: ./ai-coder/agents/platform-controls/organizations.md
- title: Network isolation
description: Run Coder Agents in a separate sandbox with a two-Pod Kubernetes template.
path: ./ai-coder/agents/platform-controls/agent-isolation.md
state: [early access]
- title: MCP servers
description: Configure external MCP servers that provide additional tools for agent chat sessions
path: ./ai-coder/agents/platform-controls/mcp-servers.md
- title: Spend management
description: Cap Coder Agents spend with AI Gateway budgets and track the resulting spend.
path: ./ai-coder/agents/platform-controls/spend-management.md
state: [premium]
- title: Git providers
description: Configure Git providers so Coder Agents can show pull request diffs in the in-chat viewer.
path: ./ai-coder/agents/platform-controls/git-providers.md
- title: Conversation data retention
description: Configure automatic cleanup of old Coder Agents conversation data to manage database size.
path: ./ai-coder/agents/platform-controls/chat-retention.md
- title: Chat debug data retention
description: Configure automatic cleanup of old Coder Agents chat debug data to manage database size.
path: ./ai-coder/agents/platform-controls/chat-debug-retention.md
- title: Conversation auto-archive
description: Automatically archive long-inactive Coder Agents conversations to keep chat lists tidy.
path: ./ai-coder/agents/platform-controls/chat-auto-archive.md
- title: Advisor
description: Provide strategic, high-level guidance to root Coder Agents chats with the Advisor.
path: ./ai-coder/agents/platform-controls/advisor.md
state: [early access]
- title: Virtual desktop
description: Give Coder Agents a graphical virtual desktop inside workspaces for GUI-based tasks.
path: ./ai-coder/agents/platform-controls/virtual-desktop.md
state: [early access]
- title: Chat debug logging
description: Record detailed traces of each Coder Agents chat turn to troubleshoot agent behavior.
path: ./ai-coder/agents/platform-controls/chat-debug-logging.md
+7
View File
@@ -0,0 +1,7 @@
title: AI Governance
description: "Govern AI usage at scale with AI Governance: Agent Firewall, AI Gateway, and reporting."
path: ./ai-coder/ai-governance.md
state: [premium]
children:
- include: ai-coder/ai-governance/agent-firewall.yml
- include: ai-coder/ai-governance/ai-gateway.yml
@@ -0,0 +1,15 @@
title: Agent Firewall
description: Restrict and audit the network access of AI agents with Agent Firewall, a process-level firewall.
path: ./ai-coder/agent-firewall/index.md
state: [premium]
children:
- include: ai-coder/ai-governance/agent-firewall/nsjail.yml
- title: Landjail jail type
description: Learn how Agent Firewall's landjail jail type isolates agents using Landlock v4.
path: ./ai-coder/agent-firewall/landjail.md
- title: Rules engine
description: Learn how the Agent Firewall rules engine filters agent network requests with configurable rules.
path: ./ai-coder/agent-firewall/rules-engine.md
- title: Version requirements
description: Check the Coder and Claude Code module version requirements for running Agent Firewall.
path: ./ai-coder/agent-firewall/version.md
@@ -0,0 +1,13 @@
title: NsJail jail type
description: Learn how Agent Firewall's default NsJail jail type isolates agents using Linux namespaces.
path: ./ai-coder/agent-firewall/nsjail/index.md
children:
- title: NsJail on Docker
description: Runtime and permission requirements for running Agent Firewall's NsJail jail type on Docker.
path: ./ai-coder/agent-firewall/nsjail/docker.md
- title: NsJail on Kubernetes
description: Runtime and permission requirements for running Agent Firewall's NsJail jail type on Kubernetes.
path: ./ai-coder/agent-firewall/nsjail/k8s.md
- title: NsJail on ECS
description: Runtime and permission requirements for running Agent Firewall's NsJail jail type on AWS ECS.
path: ./ai-coder/agent-firewall/nsjail/ecs.md
@@ -0,0 +1,47 @@
title: AI Gateway
description: Govern and observe AI coding traffic with AI Gateway.
path: ./ai-coder/ai-gateway/index.md
icon_path: ./images/icons/api.svg
state: [premium]
children:
- title: Setup
description: Enable and configure AI Gateway inside the Coder control plane, with no extra compute to deploy.
path: ./ai-coder/ai-gateway/setup.md
state: [premium]
- title: Standalone deployment
description: Deploy and operate AI Gateway as a standalone service
path: ./ai-coder/ai-gateway/standalone.md
state: [premium]
- title: Authentication
description: Authenticate AI coding tools against AI Gateway using your Coder API token.
path: ./ai-coder/ai-gateway/auth.md
state: [premium]
- include: ai-coder/ai-governance/ai-gateway/clients.yml
- title: MCP tools injection
description: Connect MCP servers to AI Gateway to inject tools and centrally manage what users can call.
path: ./ai-coder/ai-gateway/mcp.md
- include: ai-coder/ai-governance/ai-gateway/ai-gateway-proxy.yml
- title: Provider configuration
description: Learn how AI Gateway stores and reloads LLM provider configuration for your deployment.
path: ./ai-coder/ai-gateway/providers.md
state: [premium]
- title: Audit AI sessions
description: Audit AI coding sessions and threads captured by AI Gateway for governance and review.
path: ./ai-coder/ai-gateway/audit.md
state: [premium]
- title: Monitoring
description: Monitor AI Gateway activity, including prompts, token usage, and tool calls per request.
path: ./ai-coder/ai-gateway/monitoring.md
state: [premium]
- title: AI Governance cost control
description: Configure AI Gateway budgets, enforcement, notifications, and spend reporting.
path: ./ai-coder/ai-gateway/cost-controls.md
state: [premium]
- title: Reference
description: Technical reference for AI Gateway, including deployment topologies, version compatibility, and supported APIs.
path: ./ai-coder/ai-gateway/reference.md
state: [premium]
- title: Rebranding migration
description: Update configuration and references after the AI Bridge rename to AI Gateway.
path: ./ai-coder/ai-gateway/rebranding-migration.md
state: [premium]
@@ -0,0 +1,9 @@
title: AI Gateway Proxy
description: Use AI Gateway Proxy to route AI tools that don't support base URL overrides through AI Gateway.
path: ./ai-coder/ai-gateway/ai-gateway-proxy/index.md
state: [premium]
children:
- title: Setup
description: Enable and configure AI Gateway Proxy inside the Coder control plane, with no extra compute.
path: ./ai-coder/ai-gateway/ai-gateway-proxy/setup.md
state: [premium]
@@ -0,0 +1,53 @@
title: Client configuration
description: Configure your AI coding tools to route their model requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/index.md
state: [premium]
children:
- title: Claude Code
description: Configure Claude Code to route requests through AI Gateway using environment variables.
path: ./ai-coder/ai-gateway/clients/claude-code.md
state: [premium]
- title: Codex
description: Configure the Codex CLI to route requests through AI Gateway with a custom model provider.
path: ./ai-coder/ai-gateway/clients/codex.md
state: [premium]
- title: Xum
description: Configure Xum, the parallel coding agent tool, to route requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/xum.md
state: [premium]
- title: OpenCode
description: Configure OpenCode to route its OpenAI and Anthropic requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/opencode.md
state: [premium]
- title: Factory
description: Configure Factory's Droid agent to route its model requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/factory.md
state: [premium]
- title: Cline
description: Configure Cline to route its OpenAI and Anthropic requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/cline.md
state: [premium]
- title: Kilo Code
description: Configure Kilo Code to route its model requests through AI Gateway from the UI.
path: ./ai-coder/ai-gateway/clients/kilo-code.md
state: [premium]
- title: VS Code
description: Configure VS Code to route its AI model requests through Coder's AI Gateway.
path: ./ai-coder/ai-gateway/clients/vscode.md
state: [premium]
- title: JetBrains
description: Configure JetBrains AI Assistant to route model requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/jetbrains.md
state: [premium]
- title: Junie
description: Configure Junie CLI to route requests through AI Gateway with a custom model profile.
path: ./ai-coder/ai-gateway/clients/junie.md
state: [premium]
- title: Zed
description: Configure the Zed editor's language models to route requests through AI Gateway.
path: ./ai-coder/ai-gateway/clients/zed.md
state: [premium]
- title: GitHub Copilot
description: Route GitHub Copilot model requests through AI Gateway using the AI Gateway Proxy.
path: ./ai-coder/ai-gateway/clients/copilot.md
state: [premium]
+926
View File
@@ -0,0 +1,926 @@
[
{
"title": "`agent-firewall`",
"description": "Network isolation tool for monitoring and restricting HTTP/HTTPS requests",
"path": "reference/cli/agent-firewall.md"
},
{
"title": "`ai-gateway`",
"description": "Manage AI Gateway",
"path": "reference/cli/ai-gateway/index.md",
"children": [
{
"title": "`keys`",
"description": "Manage AI Gateway keys",
"path": "reference/cli/ai-gateway/keys/index.md",
"children": [
{
"title": "`create`",
"description": "Create an AI Gateway key",
"path": "reference/cli/ai-gateway/keys/create.md"
},
{
"title": "`delete`",
"description": "Delete an AI Gateway key",
"path": "reference/cli/ai-gateway/keys/delete.md"
},
{
"title": "`list`",
"description": "List AI Gateway keys",
"path": "reference/cli/ai-gateway/keys/list.md"
}
]
},
{
"title": "`start`",
"description": "Run a standalone AI Gateway server",
"path": "reference/cli/ai-gateway/start.md"
}
]
},
{
"title": "`autoupdate`",
"description": "Toggle auto-update policy for a workspace",
"path": "reference/cli/autoupdate.md"
},
{
"title": "`completion`",
"description": "Install or update shell completion scripts for the detected or chosen shell.",
"path": "reference/cli/completion.md"
},
{
"title": "`config-ssh`",
"description": "Add an SSH Host entry for your workspaces \"ssh workspace.coder\"",
"path": "reference/cli/config-ssh.md"
},
{
"title": "`create`",
"description": "Create a workspace",
"path": "reference/cli/create.md"
},
{
"title": "`delete`",
"description": "Delete a workspace",
"path": "reference/cli/delete.md"
},
{
"title": "`dotfiles`",
"description": "Personalize your workspace by applying a canonical dotfiles repository",
"path": "reference/cli/dotfiles.md"
},
{
"title": "`external-auth`",
"description": "Manage external authentication",
"path": "reference/cli/external-auth/index.md",
"children": [
{
"title": "`access-token`",
"description": "Print auth for an external provider",
"path": "reference/cli/external-auth/access-token.md"
}
]
},
{
"title": "`external-workspaces`",
"description": "Create or manage external workspaces",
"path": "reference/cli/external-workspaces/index.md",
"children": [
{
"title": "`agent-instructions`",
"description": "Get the instructions for an external agent",
"path": "reference/cli/external-workspaces/agent-instructions.md"
},
{
"title": "`create`",
"description": "Create a new external workspace",
"path": "reference/cli/external-workspaces/create.md"
},
{
"title": "`list`",
"description": "List external workspaces",
"path": "reference/cli/external-workspaces/list.md"
}
]
},
{
"title": "`favorite`",
"description": "Add a workspace to your favorites",
"path": "reference/cli/favorite.md"
},
{
"title": "`features`",
"description": "List Enterprise features",
"path": "reference/cli/features/index.md",
"children": [
{
"title": "`list`",
"path": "reference/cli/features/list.md"
}
]
},
{
"title": "`groups`",
"description": "Manage groups",
"path": "reference/cli/groups/index.md",
"children": [
{
"title": "`create`",
"description": "Create a user group",
"path": "reference/cli/groups/create.md"
},
{
"title": "`delete`",
"description": "Delete a user group",
"path": "reference/cli/groups/delete.md"
},
{
"title": "`edit`",
"description": "Edit a user group",
"path": "reference/cli/groups/edit.md"
},
{
"title": "`list`",
"description": "List user groups",
"path": "reference/cli/groups/list.md"
}
]
},
{
"title": "`licenses`",
"description": "Add, delete, and list licenses",
"path": "reference/cli/licenses/index.md",
"children": [
{
"title": "`add`",
"description": "Add license to Coder deployment",
"path": "reference/cli/licenses/add.md"
},
{
"title": "`delete`",
"description": "Delete license by ID",
"path": "reference/cli/licenses/delete.md"
},
{
"title": "`list`",
"description": "List licenses (including expired)",
"path": "reference/cli/licenses/list.md"
}
]
},
{
"title": "`list`",
"description": "List workspaces",
"path": "reference/cli/list.md"
},
{
"title": "`login`",
"description": "Authenticate with Coder deployment",
"path": "reference/cli/login/index.md",
"children": [
{
"title": "`token`",
"description": "Print the current session token",
"path": "reference/cli/login/token.md"
}
]
},
{
"title": "`logout`",
"description": "Unauthenticate your local session",
"path": "reference/cli/logout.md"
},
{
"title": "`logs`",
"description": "View logs for a workspace",
"path": "reference/cli/logs.md"
},
{
"title": "`netcheck`",
"description": "Print network debug information for DERP and STUN",
"path": "reference/cli/netcheck.md"
},
{
"title": "`notifications`",
"description": "Manage Coder notifications",
"path": "reference/cli/notifications/index.md",
"children": [
{
"title": "`custom`",
"description": "Send a custom notification",
"path": "reference/cli/notifications/custom.md"
},
{
"title": "`pause`",
"description": "Pause notifications",
"path": "reference/cli/notifications/pause.md"
},
{
"title": "`resume`",
"description": "Resume notifications",
"path": "reference/cli/notifications/resume.md"
},
{
"title": "`test`",
"description": "Send a test notification",
"path": "reference/cli/notifications/test.md"
}
]
},
{
"title": "`oauth2-provider`",
"description": "Manage Coder OAuth2 provider settings",
"path": "reference/cli/oauth2-provider/index.md",
"children": [
{
"title": "`dcr`",
"description": "Manage OAuth2 dynamic client registration (RFC 7591)",
"path": "reference/cli/oauth2-provider/dcr/index.md",
"children": [
{
"title": "`disable`",
"description": "Disable OAuth2 dynamic client registration",
"path": "reference/cli/oauth2-provider/dcr/disable.md"
},
{
"title": "`enable`",
"description": "Enable OAuth2 dynamic client registration",
"path": "reference/cli/oauth2-provider/dcr/enable.md"
}
]
}
]
},
{
"title": "`open`",
"description": "Open a workspace",
"path": "reference/cli/open/index.md",
"children": [
{
"title": "`app`",
"description": "Open a workspace application.",
"path": "reference/cli/open/app.md"
},
{
"title": "`vscode`",
"description": "Open a workspace in VS Code Desktop",
"path": "reference/cli/open/vscode.md"
}
]
},
{
"title": "`organizations`",
"description": "Organization related commands",
"path": "reference/cli/organizations/index.md",
"children": [
{
"title": "`create`",
"description": "Create a new organization.",
"path": "reference/cli/organizations/create.md"
},
{
"title": "`delete`",
"description": "Delete an organization",
"path": "reference/cli/organizations/delete.md"
},
{
"title": "`edit`",
"description": "Edit organization settings.",
"path": "reference/cli/organizations/edit.md"
},
{
"title": "`list`",
"description": "List all organizations",
"path": "reference/cli/organizations/list.md"
},
{
"title": "`members`",
"description": "Manage organization members",
"path": "reference/cli/organizations/members/index.md",
"children": [
{
"title": "`add`",
"description": "Add a new member to the current organization",
"path": "reference/cli/organizations/members/add.md"
},
{
"title": "`edit-roles`",
"description": "Edit organization member's roles",
"path": "reference/cli/organizations/members/edit-roles.md"
},
{
"title": "`list`",
"description": "List all organization members",
"path": "reference/cli/organizations/members/list.md"
},
{
"title": "`remove`",
"description": "Remove a new member to the current organization",
"path": "reference/cli/organizations/members/remove.md"
}
]
},
{
"title": "`roles`",
"description": "Manage organization roles.",
"path": "reference/cli/organizations/roles/index.md",
"children": [
{
"title": "`create`",
"description": "Create a new organization custom role",
"path": "reference/cli/organizations/roles/create.md"
},
{
"title": "`show`",
"description": "Show role(s)",
"path": "reference/cli/organizations/roles/show.md"
},
{
"title": "`update`",
"description": "Update an organization custom role",
"path": "reference/cli/organizations/roles/update.md"
}
]
},
{
"title": "`settings`",
"description": "Manage organization settings.",
"path": "reference/cli/organizations/settings/index.md",
"children": [
{
"title": "`set`",
"description": "Update specified organization setting.",
"path": "reference/cli/organizations/settings/set/index.md",
"children": [
{
"title": "`group-sync`",
"description": "Group sync settings to sync groups from an IdP.",
"path": "reference/cli/organizations/settings/set/group-sync.md"
},
{
"title": "`organization-sync`",
"description": "Organization sync settings to sync organization memberships from an IdP.",
"path": "reference/cli/organizations/settings/set/organization-sync.md"
},
{
"title": "`role-sync`",
"description": "Role sync settings to sync organization roles from an IdP.",
"path": "reference/cli/organizations/settings/set/role-sync.md"
},
{
"title": "`workspace-sharing`",
"description": "Workspace sharing settings for the organization.",
"path": "reference/cli/organizations/settings/set/workspace-sharing.md"
}
]
},
{
"title": "`show`",
"description": "Outputs specified organization setting.",
"path": "reference/cli/organizations/settings/show/index.md",
"children": [
{
"title": "`group-sync`",
"description": "Group sync settings to sync groups from an IdP.",
"path": "reference/cli/organizations/settings/show/group-sync.md"
},
{
"title": "`organization-sync`",
"description": "Organization sync settings to sync organization memberships from an IdP.",
"path": "reference/cli/organizations/settings/show/organization-sync.md"
},
{
"title": "`role-sync`",
"description": "Role sync settings to sync organization roles from an IdP.",
"path": "reference/cli/organizations/settings/show/role-sync.md"
},
{
"title": "`workspace-sharing`",
"description": "Workspace sharing settings for the organization.",
"path": "reference/cli/organizations/settings/show/workspace-sharing.md"
}
]
}
]
},
{
"title": "`show`",
"description": "Show the organization. Using \"selected\" will show the selected organization from the \"--org\" flag. Using \"me\" will show all organizations you are a member of.",
"path": "reference/cli/organizations/show.md"
}
]
},
{
"title": "`ping`",
"description": "Ping a workspace",
"path": "reference/cli/ping.md"
},
{
"title": "`port-forward`",
"description": "Forward ports from a workspace to the local machine. For reverse port forwarding, use \"coder ssh -R\".",
"path": "reference/cli/port-forward.md"
},
{
"title": "`prebuilds`",
"description": "Manage Coder prebuilds",
"path": "reference/cli/prebuilds/index.md",
"children": [
{
"title": "`pause`",
"description": "Pause prebuilds",
"path": "reference/cli/prebuilds/pause.md"
},
{
"title": "`resume`",
"description": "Resume prebuilds",
"path": "reference/cli/prebuilds/resume.md"
}
]
},
{
"title": "`provisioner`",
"description": "View and manage provisioner daemons and jobs",
"path": "reference/cli/provisioner/index.md",
"children": [
{
"title": "`jobs`",
"description": "View and manage provisioner jobs",
"path": "reference/cli/provisioner/jobs/index.md",
"children": [
{
"title": "`cancel`",
"description": "Cancel a provisioner job",
"path": "reference/cli/provisioner/jobs/cancel.md"
},
{
"title": "`list`",
"description": "List provisioner jobs",
"path": "reference/cli/provisioner/jobs/list.md"
}
]
},
{
"title": "`keys`",
"description": "Manage provisioner keys",
"path": "reference/cli/provisioner/keys/index.md",
"children": [
{
"title": "`create`",
"description": "Create a new provisioner key",
"path": "reference/cli/provisioner/keys/create.md"
},
{
"title": "`delete`",
"description": "Delete a provisioner key",
"path": "reference/cli/provisioner/keys/delete.md"
},
{
"title": "`list`",
"description": "List provisioner keys in an organization",
"path": "reference/cli/provisioner/keys/list.md"
}
]
},
{
"title": "`list`",
"description": "List provisioner daemons in an organization",
"path": "reference/cli/provisioner/list.md"
},
{
"title": "`start`",
"description": "Run a provisioner daemon",
"path": "reference/cli/provisioner/start.md"
}
]
},
{
"title": "`publickey`",
"description": "Output your Coder public key used for Git operations",
"path": "reference/cli/publickey.md"
},
{
"title": "`rename`",
"description": "Rename a workspace",
"path": "reference/cli/rename.md"
},
{
"title": "`reset-password`",
"description": "Directly connect to the database to reset a user's password",
"path": "reference/cli/reset-password.md"
},
{
"title": "`restart`",
"description": "Restart a workspace",
"path": "reference/cli/restart.md"
},
{
"title": "`schedule`",
"description": "Schedule automated start and stop times for workspaces",
"path": "reference/cli/schedule/index.md",
"children": [
{
"title": "`extend`",
"description": "Extend the stop time of a currently running workspace instance.",
"path": "reference/cli/schedule/extend.md"
},
{
"title": "`show`",
"description": "Show workspace schedules",
"path": "reference/cli/schedule/show.md"
},
{
"title": "`start`",
"description": "Edit workspace start schedule",
"path": "reference/cli/schedule/start.md"
},
{
"title": "`stop`",
"description": "Edit workspace stop schedule",
"path": "reference/cli/schedule/stop.md"
}
]
},
{
"title": "`secret`",
"description": "Manage secrets",
"path": "reference/cli/secret/index.md",
"children": [
{
"title": "`create`",
"description": "Create a secret",
"path": "reference/cli/secret/create.md"
},
{
"title": "`delete`",
"description": "Delete a secret",
"path": "reference/cli/secret/delete.md"
},
{
"title": "`disable`",
"description": "Disable a secret without removing it",
"path": "reference/cli/secret/disable.md"
},
{
"title": "`enable`",
"description": "Enable a secret so it is injected into workspaces",
"path": "reference/cli/secret/enable.md"
},
{
"title": "`import`",
"description": "Import secrets from a file",
"path": "reference/cli/secret/import.md"
},
{
"title": "`list`",
"description": "List secrets, or show one by name",
"path": "reference/cli/secret/list.md"
},
{
"title": "`update`",
"description": "Update a secret",
"path": "reference/cli/secret/update.md"
}
]
},
{
"title": "`server`",
"description": "Start a Coder server",
"path": "reference/cli/server/index.md",
"children": [
{
"title": "`create-admin-user`",
"description": "Create a new admin user with the given username, email and password and adds it to every organization.",
"path": "reference/cli/server/create-admin-user.md"
},
{
"title": "`dbcrypt`",
"description": "Manage database encryption.",
"path": "reference/cli/server/dbcrypt/index.md",
"children": [
{
"title": "`decrypt`",
"description": "Decrypt a previously encrypted database.",
"path": "reference/cli/server/dbcrypt/decrypt.md"
},
{
"title": "`delete`",
"description": "Delete all encrypted data from the database. THIS IS A DESTRUCTIVE OPERATION.",
"path": "reference/cli/server/dbcrypt/delete.md"
},
{
"title": "`rotate`",
"description": "Rotate database encryption keys.",
"path": "reference/cli/server/dbcrypt/rotate.md"
}
]
},
{
"title": "`fix-oidc-links`",
"description": "Reset OIDC linked IDs that do not match the expected issuer, allowing users to re-authenticate.",
"path": "reference/cli/server/fix-oidc-links.md"
},
{
"title": "`postgres-builtin-serve`",
"description": "Run the built-in PostgreSQL deployment.",
"path": "reference/cli/server/postgres-builtin-serve.md"
},
{
"title": "`postgres-builtin-url`",
"description": "Output the connection URL for the built-in PostgreSQL deployment.",
"path": "reference/cli/server/postgres-builtin-url.md"
}
]
},
{
"title": "`show`",
"description": "Display details of a workspace's resources and agents",
"path": "reference/cli/show.md"
},
{
"title": "`speedtest`",
"description": "Run upload and download tests from your machine to a workspace",
"path": "reference/cli/speedtest.md"
},
{
"title": "`ssh`",
"description": "Start a shell into a workspace or run a command",
"path": "reference/cli/ssh.md"
},
{
"title": "`start`",
"description": "Start a workspace",
"path": "reference/cli/start.md"
},
{
"title": "`stat`",
"description": "Show resource usage for the current workspace.",
"path": "reference/cli/stat/index.md",
"children": [
{
"title": "`cpu`",
"description": "Show CPU usage, in cores.",
"path": "reference/cli/stat/cpu.md"
},
{
"title": "`disk`",
"description": "Show disk usage, in gigabytes.",
"path": "reference/cli/stat/disk.md"
},
{
"title": "`mem`",
"description": "Show memory usage, in gigabytes.",
"path": "reference/cli/stat/mem.md"
}
]
},
{
"title": "`state`",
"description": "Manually manage Terraform state to fix broken workspaces",
"path": "reference/cli/state/index.md",
"children": [
{
"title": "`pull`",
"description": "Pull a Terraform state file from a workspace.",
"path": "reference/cli/state/pull.md"
},
{
"title": "`push`",
"description": "Push a Terraform state file to a workspace.",
"path": "reference/cli/state/push.md"
}
]
},
{
"title": "`stop`",
"description": "Stop a workspace",
"path": "reference/cli/stop.md"
},
{
"title": "`support`",
"description": "Commands for troubleshooting issues with a Coder deployment.",
"path": "reference/cli/support/index.md",
"children": [
{
"title": "`bundle`",
"description": "Generate a support bundle to troubleshoot issues connecting to a workspace.",
"path": "reference/cli/support/bundle.md"
}
]
},
{
"title": "`templates`",
"description": "Manage templates",
"path": "reference/cli/templates/index.md",
"children": [
{
"title": "`archive`",
"description": "Archive unused or failed template versions from a given template(s)",
"path": "reference/cli/templates/archive.md"
},
{
"title": "`create`",
"description": "DEPRECATED: Create a template from the current directory or as specified by flag",
"path": "reference/cli/templates/create.md"
},
{
"title": "`delete`",
"description": "Delete templates",
"path": "reference/cli/templates/delete.md"
},
{
"title": "`edit`",
"description": "Edit the metadata of a template by name.",
"path": "reference/cli/templates/edit.md"
},
{
"title": "`init`",
"description": "Get started with a templated template.",
"path": "reference/cli/templates/init.md"
},
{
"title": "`list`",
"description": "List all the templates available for the organization",
"path": "reference/cli/templates/list.md"
},
{
"title": "`presets`",
"description": "Manage presets of the specified template",
"path": "reference/cli/templates/presets/index.md",
"children": [
{
"title": "`list`",
"description": "List all presets of the specified template. Defaults to the active template version.",
"path": "reference/cli/templates/presets/list.md"
}
]
},
{
"title": "`pull`",
"description": "Download the active, latest, or specified version of a template to a path.",
"path": "reference/cli/templates/pull.md"
},
{
"title": "`push`",
"description": "Create or update a template from the current directory or as specified by flag",
"path": "reference/cli/templates/push.md"
},
{
"title": "`versions`",
"description": "Manage different versions of the specified template",
"path": "reference/cli/templates/versions/index.md",
"children": [
{
"title": "`archive`",
"description": "Archive a template version(s).",
"path": "reference/cli/templates/versions/archive.md"
},
{
"title": "`list`",
"description": "List all the versions of the specified template",
"path": "reference/cli/templates/versions/list.md"
},
{
"title": "`promote`",
"description": "Promote a template version to active.",
"path": "reference/cli/templates/versions/promote.md"
},
{
"title": "`unarchive`",
"description": "Unarchive a template version(s).",
"path": "reference/cli/templates/versions/unarchive.md"
}
]
}
]
},
{
"title": "`tokens`",
"description": "Manage personal access tokens",
"path": "reference/cli/tokens/index.md",
"children": [
{
"title": "`create`",
"description": "Create a token",
"path": "reference/cli/tokens/create.md"
},
{
"title": "`list`",
"description": "List tokens",
"path": "reference/cli/tokens/list.md"
},
{
"title": "`remove`",
"description": "Expire or delete a token",
"path": "reference/cli/tokens/remove.md"
},
{
"title": "`view`",
"description": "Display detailed information about a token",
"path": "reference/cli/tokens/view.md"
}
]
},
{
"title": "`unfavorite`",
"description": "Remove a workspace from your favorites",
"path": "reference/cli/unfavorite.md"
},
{
"title": "`update`",
"description": "Will update and start a given workspace if it is out of date. If the workspace is already running, it will be stopped first.",
"path": "reference/cli/update.md"
},
{
"title": "`users`",
"description": "Manage users",
"path": "reference/cli/users/index.md",
"children": [
{
"title": "`activate`",
"description": "Update a user's status to 'active'. Active users can fully interact with the platform",
"path": "reference/cli/users/activate.md"
},
{
"title": "`create`",
"description": "Create a new user.",
"path": "reference/cli/users/create.md"
},
{
"title": "`delete`",
"description": "Delete a user by username or user_id.",
"path": "reference/cli/users/delete.md"
},
{
"title": "`edit-roles`",
"description": "Edit a user's roles by username or id",
"path": "reference/cli/users/edit-roles.md"
},
{
"title": "`list`",
"description": "Prints the list of users.",
"path": "reference/cli/users/list.md"
},
{
"title": "`oidc-claims`",
"description": "Display the OIDC claims for the authenticated user.",
"path": "reference/cli/users/oidc-claims.md"
},
{
"title": "`show`",
"description": "Show a single user. Use 'me' to indicate the currently authenticated user.",
"path": "reference/cli/users/show.md"
},
{
"title": "`suspend`",
"description": "Update a user's status to 'suspended'. A suspended user cannot log into the platform. Suspending a user stops their running workspaces; activating the user again does not restart them.",
"path": "reference/cli/users/suspend.md"
}
]
},
{
"title": "`version`",
"description": "Show coder version",
"path": "reference/cli/version.md"
},
{
"title": "`whoami`",
"description": "Fetch authenticated user info for Coder deployment",
"path": "reference/cli/whoami.md"
},
{
"title": "`workspace-proxy`",
"description": "Workspace proxies provide low-latency experiences for geo-distributed teams.",
"path": "reference/cli/workspace-proxy/index.md",
"children": [
{
"title": "`create`",
"description": "Create a workspace proxy",
"path": "reference/cli/workspace-proxy/create.md"
},
{
"title": "`delete`",
"description": "Delete a workspace proxy",
"path": "reference/cli/workspace-proxy/delete.md"
},
{
"title": "`edit`",
"description": "Edit a workspace proxy",
"path": "reference/cli/workspace-proxy/edit.md"
},
{
"title": "`ls`",
"description": "List all workspace proxies",
"path": "reference/cli/workspace-proxy/ls.md"
},
{
"title": "`regenerate-token`",
"description": "Regenerate a workspace proxy authentication token. This will invalidate the existing authentication token.",
"path": "reference/cli/workspace-proxy/regenerate-token.md"
},
{
"title": "`server`",
"description": "Start a workspace proxy server",
"path": "reference/cli/workspace-proxy/server.md"
}
]
}
]
+122
View File
@@ -0,0 +1,122 @@
[
{
"title": "General",
"path": "./reference/api/general.md"
},
{
"title": "AI Gateway",
"path": "./reference/api/aigateway.md"
},
{
"title": "AI Providers",
"path": "./reference/api/aiproviders.md"
},
{
"title": "Agents",
"path": "./reference/api/agents.md"
},
{
"title": "Applications",
"path": "./reference/api/applications.md"
},
{
"title": "Audit",
"path": "./reference/api/audit.md"
},
{
"title": "Authentication",
"path": "./reference/api/authentication.md"
},
{
"title": "Authorization",
"path": "./reference/api/authorization.md"
},
{
"title": "Builds",
"path": "./reference/api/builds.md"
},
{
"title": "Chats",
"path": "./reference/api/chats.md"
},
{
"title": "Debug",
"path": "./reference/api/debug.md"
},
{
"title": "Enterprise",
"path": "./reference/api/enterprise.md"
},
{
"title": "Files",
"path": "./reference/api/files.md"
},
{
"title": "Git",
"path": "./reference/api/git.md"
},
{
"title": "InitScript",
"path": "./reference/api/initscript.md"
},
{
"title": "Insights",
"path": "./reference/api/insights.md"
},
{
"title": "MCP",
"path": "./reference/api/mcp.md"
},
{
"title": "Members",
"path": "./reference/api/members.md"
},
{
"title": "Notifications",
"path": "./reference/api/notifications.md"
},
{
"title": "Organizations",
"path": "./reference/api/organizations.md"
},
{
"title": "PortSharing",
"path": "./reference/api/portsharing.md"
},
{
"title": "Prebuilds",
"path": "./reference/api/prebuilds.md"
},
{
"title": "Provisioning",
"path": "./reference/api/provisioning.md"
},
{
"title": "Schemas",
"path": "./reference/api/schemas.md"
},
{
"title": "Secrets",
"path": "./reference/api/secrets.md"
},
{
"title": "TemplateBuilder",
"path": "./reference/api/templatebuilder.md"
},
{
"title": "Templates",
"path": "./reference/api/templates.md"
},
{
"title": "Users",
"path": "./reference/api/users.md"
},
{
"title": "WorkspaceProxies",
"path": "./reference/api/workspaceproxies.md"
},
{
"title": "Workspaces",
"path": "./reference/api/workspaces.md"
}
]
+6
View File
@@ -0,0 +1,6 @@
title: Quickstart
description: Install Coder, build your first template, and launch your first workspace in this quickstart guide.
path: ./get-started/index.md
icon_path: ./images/icons/rocket.svg
children:
- include: get-started/customize-your-template.yml
@@ -0,0 +1,13 @@
title: Customize your template
description: Add a language, install command-line tools, and authenticate to GitHub
path: ./get-started/customize-your-template/index.md
children:
- title: Add a programming language
description: Expose a new programming language through a template parameter and install it at workspace startup.
path: ./get-started/customize-your-template/add-a-language.md
- title: Install your own command-line tools
description: Install your own command-line tools in a workspace and make them persist across rebuilds.
path: ./get-started/customize-your-template/install-command-line-tools.md
- title: Clone private repositories
description: Clone private GitHub repositories in your workspace using a Coder external-auth data source.
path: ./get-started/customize-your-template/authenticate-to-github.md
+27
View File
@@ -0,0 +1,27 @@
# Sidebar for coder.com/docs, compiled into docs/manifest.json.
#
# Edit these YAML files, not docs/manifest.json. Each file under sections is
# one top-level sidebar section, listed here in sidebar order. After editing,
# run "make gen/docs-manifest" to format the sources and rebuild
# docs/manifest.json.
#
# Each file holds one route and its direct children. A child with children of
# its own lives in its own file, in a directory named after the parent file,
# and the parent lists it as "- include: admin/users.yml". Include paths are
# relative to this directory, and an include entry sets no other key.
#
# Keys appear in this order: title, description, path, icon_path, state,
# children_from, include, children. A route with children_from gets its
# children from a generated file under generated/; its children list may only
# add description, icon_path, or state to generated routes, matched by title.
versions: [main]
sections:
- about.yml
- get-started.yml
- install.yml
- user-guides.yml
- admin.yml
- ai-coder.yml
- tutorials.yml
- reference.yml
+14
View File
@@ -0,0 +1,14 @@
title: Install
description: Plan, prepare, install, validate, and operate a Coder deployment in your own infrastructure.
path: ./install/index.md
icon_path: ./images/icons/download.svg
children:
- title: Coder CLI
description: Install the standalone Coder CLI binary on Linux, macOS, or Windows to run the control plane and client.
path: ./install/cli.md
icon_path: ./images/icons/terminal.svg
- include: install/plan.yml
- include: install/prepare.yml
- include: install/server.yml
- include: install/validate.yml
- include: install/operate.yml
+11
View File
@@ -0,0 +1,11 @@
title: Operate and maintain
description: Run the deployment day to day, add external provisioners, upgrade it, and remove it when needed.
path: ./install/operate/index.md
icon_path: ./images/icons/wrench.svg
children:
- include: install/operate/provisioners.yml
- include: install/operate/upgrade.yml
- title: Uninstall
description: Learn how to uninstall your Coder deployment and remove its associated resources.
path: ./install/operate/uninstall.md
icon_path: ./images/icons/trash.svg
@@ -0,0 +1,10 @@
title: External provisioners
description: Run external provisioner daemons to isolate builds and scale workspace provisioning.
path: ./install/operate/provisioners/index.md
icon_path: ./images/icons/key.svg
state: [premium]
children:
- title: Manage provisioner jobs
description: Monitor and manage provisioner jobs for workspace builds, including canceling stuck jobs.
path: ./install/operate/provisioners/manage-provisioner-jobs.md
state: [premium]
+14
View File
@@ -0,0 +1,14 @@
title: Upgrade
description: Learn how to upgrade your Coder deployment to a newer version, with steps for each install method.
path: ./install/operate/upgrade.md
icon_path: ./images/icons/upgrade.svg
children:
- title: Upgrade best practices
description: Follow best practices and troubleshooting tips to plan and carry out Coder upgrades.
path: ./install/operate/upgrade/best-practices.md
- title: Upgrade from ESR 2.24 to 2.29
description: A step-by-step guide to upgrade a Coder deployment from Extended Support Release 2.24 to 2.29.
path: ./install/operate/upgrade/esr-2.24-2.29-upgrade.md
- title: Upgrade from ESR 2.29 to 2.34
description: A step-by-step guide to upgrade a Coder deployment from Extended Support Release 2.29 to 2.34.
path: ./install/operate/upgrade/esr-2.29-2.34-upgrade.md
+9
View File
@@ -0,0 +1,9 @@
title: Plan your deployment
description: Learn the architecture, size the deployment, and record the decisions that shape it.
path: ./install/plan/index.md
icon_path: ./images/icons/notes.svg
children:
- title: Architecture
description: Learn about Coder's architecture and the components that make up a deployment.
path: ./install/plan/architecture.md
- include: install/plan/sizing.yml
+16
View File
@@ -0,0 +1,16 @@
title: Coder Validated Architecture
description: Reference designs and best practices for sizing a Coder deployment, from 1,000 to 10,000 users.
path: ./install/plan/sizing/index.md
children:
- title: Up to 1,000 users
description: Hardware specifications and architecture guidance for Coder deployments that support up to 1,000 users
path: ./install/plan/sizing/1k-users.md
- title: Up to 2,000 users
description: Hardware specifications and architecture guidance for Coder deployments that support up to 2,000 users
path: ./install/plan/sizing/2k-users.md
- title: Up to 3,000 users
description: Enterprise-scale architecture recommendations for Coder deployments that support up to 3,000 users
path: ./install/plan/sizing/3k-users.md
- title: Up to 10,000 users
description: Enterprise-scale architecture recommendations for Coder deployments that support up to 10,000 users
path: ./install/plan/sizing/10k-users.md
+16
View File
@@ -0,0 +1,16 @@
title: Prepare prerequisites
description: Gather the DNS records, certificates, database, license, and identity provider application a deployment needs.
path: ./install/prepare/index.md
icon_path: ./images/icons/dependency.svg
children:
- title: Licensing
description: Add and manage Coder licenses to unlock Premium and AI Governance features.
path: ./install/prepare/licensing.md
icon_path: ./images/icons/licensing.svg
- title: Air-gapped deployments
description: Run Coder in air-gapped, disconnected, or offline environments where all features remain supported.
path: ./install/prepare/airgap.md
icon_path: ./images/icons/lan.svg
- title: Mirror the registry
description: Use JFrog Artifactory to mirror the Coder Registry for air-gapped deployments
path: ./install/prepare/registry-mirror.md
+27
View File
@@ -0,0 +1,27 @@
title: Install the control plane
description: Choose a platform and install the Coder control plane on it.
path: ./install/server/index.md
icon_path: ./images/icons/download.svg
children:
- title: Docker
description: Install and run Coder using the official Docker images for a quick single-machine deployment.
path: ./install/server/docker.md
icon_path: ./images/icons/docker.svg
- include: install/server/kubernetes.yml
- title: Rancher
description: Deploy Coder on Rancher as a Kubernetes workload using the Rancher UI and Helm.
path: ./install/server/rancher.md
icon_path: ./images/icons/rancher.svg
- title: OpenShift
description: Install Coder on a Red Hat OpenShift cluster using Helm, with the required security context settings.
path: ./install/server/openshift.md
icon_path: ./images/icons/openshift.svg
- title: RHEL-family Linux
description: Install the Coder control plane from an RPM package on Red Hat Enterprise Linux and other RHEL-family distributions.
path: ./install/server/rpm.md
icon_path: ./images/icons/system.svg
- include: install/server/cloud.yml
- title: Community install methods
description: Community-contributed methods for installing Coder on platforms Coder doesn't package itself.
path: ./install/server/community.md
icon_path: ./images/icons/generic.svg
+14
View File
@@ -0,0 +1,14 @@
title: Cloud platforms
description: Install guides and example templates for deploying Coder on AWS, Google Cloud, and Azure.
path: ./install/server/cloud/index.md
icon_path: ./images/icons/cloud.svg
children:
- title: AWS Marketplace
description: Deploy a Coder proof-of-concept on AWS using the listing available in the AWS Marketplace.
path: ./install/server/cloud/aws-marketplace.md
- title: GCP Compute Engine
description: Deploy the Coder control plane on a Google Cloud Compute Engine virtual machine.
path: ./install/server/cloud/compute-engine.md
- title: Azure VM
description: Set up the Coder control plane on a Microsoft Azure virtual machine, step by step.
path: ./install/server/cloud/azure-vm.md
@@ -0,0 +1,8 @@
title: Kubernetes
description: Install Coder on a Kubernetes cluster using the official Helm chart for production deployments.
path: ./install/server/kubernetes/index.md
icon_path: ./images/icons/kubernetes.svg
children:
- title: Deploy Coder on Azure with an Application Gateway
description: Deploy Coder on Azure Kubernetes Service behind an Azure Application Gateway ingress controller.
path: ./install/server/kubernetes/kubernetes-azure-app-gateway.md
+6
View File
@@ -0,0 +1,6 @@
title: Validate your deployment
description: Harden the deployment, then prove it works and holds up under load.
path: ./install/validate/index.md
icon_path: ./images/icons/health.svg
children:
- include: install/validate/scale-testing.yml
@@ -0,0 +1,10 @@
title: Scale testing
description: Plan and run scale tests to make sure your Coder deployment can handle your organization's load.
path: ./install/validate/scale-testing.md
children:
- title: Scale tests and utilities
description: Use Coder's built-in scale-testing utility to benchmark and load-test your deployment.
path: ./install/validate/scale-testing/utility.md
- title: Scale Coder
description: Best practices for preparing and tuning a Coder deployment so it scales to many users.
path: ./tutorials/best-practices/scale-coder.md
+18
View File
@@ -0,0 +1,18 @@
title: Reference
description: Reference for automating Coder through the REST API, command-line interface, and Agent API.
path: ./reference/index.md
icon_path: ./images/icons/notes.svg
children:
- title: Glossary
description: Definitions of Coder terms and product names
path: ./reference/glossary.md
- title: Releases
description: Learn about Coder's release channels, versioning, and schedule so you can plan upgrades.
path: ./reference/releases.md
icon_path: ./images/icons/star.svg
- title: Feature stages
description: Understand Coder's feature stages, including early access, beta, and general availability.
path: ./reference/feature-stages.md
- include: reference/api.yml
- include: reference/cli.yml
- include: reference/agent-api.yml
+9
View File
@@ -0,0 +1,9 @@
title: Agent API
description: Reference for the Coder Agent API used by workspace agents to communicate with the control plane.
path: ./reference/agent-api/index.md
icon_path: ./images/icons/api.svg
children:
- title: Debug
path: ./reference/agent-api/debug.md
- title: Schemas
path: ./reference/agent-api/schemas.md
+10
View File
@@ -0,0 +1,10 @@
title: REST API
description: Reference for the Coder REST API, including endpoints, authentication, and schemas.
path: ./reference/api/index.md
icon_path: ./images/icons/api.svg
children_from: generated/rest-api.json
children:
- title: Agents
description: REST endpoints for the workspace agent daemon (`coder_agent`).
- title: Chats
description: REST endpoints for Coder Agents Chats API (programmatic agent sessions).
+5
View File
@@ -0,0 +1,5 @@
title: Command Line
description: Reference for the Coder command-line interface, with usage and flags for every command.
path: ./reference/cli/index.md
icon_path: ./images/icons/terminal.svg
children_from: generated/cli.json
+73
View File
@@ -0,0 +1,73 @@
title: Tutorials
description: Step-by-step, employee-written guides and tutorials for deploying and administering Coder.
path: ./tutorials/index.md
icon_path: ./images/icons/generic.svg
children:
- title: Quickstart
description: Install Coder, build your first template, and launch your first workspace in this quickstart guide.
path: ./get-started/index.md
- title: Write a template from scratch
description: Learn how to write a Coder template from scratch with Terraform, step by step.
path: ./tutorials/template-from-scratch.md
- title: Use an external database
description: Configure Coder to use an external PostgreSQL database for production deployments.
path: ./tutorials/external-database.md
- title: Image management
description: Learn how to build and manage the container images that back your Coder templates.
path: ./admin/templates/managing-templates/image-management.md
- title: Configure custom claims/scopes with Okta for group/role
description: Configure custom Okta claims and scopes to drive Coder group and role sync.
path: ./tutorials/configuring-okta.md
- title: Persistent shared workspaces
description: Set up long-lived shared workspaces with service accounts and workspace sharing
path: ./tutorials/persistent-shared-workspaces.md
state: [premium]
- title: Google Cloud to AWS federation
description: Federate a Google Cloud service account to AWS so Coder can authenticate across clouds.
path: ./tutorials/gcp-to-aws.md
- title: JFrog Artifactory Integration
description: Integrate Coder with JFrog Artifactory to secure workspaces and manage packages and tokens.
path: ./admin/integrations/jfrog-artifactory.md
- title: Istio integration
description: Use the Istio service mesh to secure and control your Coder workspace traffic.
path: ./admin/integrations/istio.md
- title: Island browser integration
description: Integrate Coder with the Island Enterprise Browser for secure, policy-controlled workspace access.
path: ./admin/integrations/island.md
- title: Image pull secrets
description: Create Kubernetes ImagePullSecrets so Coder workspaces can pull images from private registries.
path: ./tutorials/image-pull-secret.md
- title: PostgreSQL SSL
description: Configure Coder to connect to a PostgreSQL database over an encrypted SSL connection.
path: ./tutorials/postgres-ssl.md
- title: Azure federation
description: Federate Coder's control plane to Azure so it can authenticate to Azure services.
path: ./tutorials/azure-federation.md
- title: Deploy Coder on Azure with an Application Gateway
description: Deploy Coder on Azure Kubernetes Service behind an Azure Application Gateway ingress controller.
path: ./install/server/kubernetes/kubernetes-azure-app-gateway.md
- title: Cloning Git repositories
description: Learn how to automatically clone Git repositories into your Coder workspaces on startup.
path: ./tutorials/cloning-git-repositories.md
- title: Test templates through CI/CD
description: Test and publish your Coder templates automatically through a CI/CD pipeline.
path: ./tutorials/testing-templates.md
- title: Apache reverse proxy
description: Configure Apache as a reverse proxy for Coder, with TLS certificates from Let's Encrypt.
path: ./tutorials/reverse-proxy-apache.md
- title: Caddy
description: Configure Caddy as a reverse proxy for Coder, with automatic HTTPS certificates.
path: ./tutorials/reverse-proxy-caddy.md
- title: NGINX reverse proxy
description: Configure NGINX as a reverse proxy for Coder, with TLS certificates from Let's Encrypt.
path: ./tutorials/reverse-proxy-nginx.md
- title: Pre-install JetBrains IDEs
description: Pre-install JetBrains IDE backends in your template for faster first-time connections.
path: ./admin/templates/extending-templates/jetbrains-preinstall.md
- title: JetBrains IDEs in an air-gapped environment
description: Configure JetBrains IDEs to work in air-gapped Coder deployments without internet access.
path: ./admin/templates/extending-templates/jetbrains-airgapped.md
- title: FAQs
description: Answers to frequently asked questions about Coder OSS and licensed deployments.
path: ./tutorials/faqs.md
- include: tutorials/best-practices.yml
@@ -0,0 +1,16 @@
title: Best practices
description: Best-practice guides to help you get the most out of your Coder deployment.
path: ./tutorials/best-practices/index.md
children:
- title: Organizations - best practices
description: Best practices for structuring and using Coder organizations effectively.
path: ./tutorials/best-practices/organizations.md
- title: Scale Coder
description: Best practices for preparing and tuning a Coder deployment so it scales to many users.
path: ./tutorials/best-practices/scale-coder.md
- title: Security - best practices
description: Follow security best practices to harden your Coder deployment against common risks.
path: ./tutorials/best-practices/security-best-practices.md
- title: Speed up your workspaces
description: Speed up Coder template builds and workspace startup with practical optimizations.
path: ./tutorials/best-practices/speed-up-templates.md
+32
View File
@@ -0,0 +1,32 @@
title: User guides
description: Guides for Coder end users on accessing, managing, and personalizing their workspaces.
path: ./user-guides/index.md
icon_path: ./images/icons/users.svg
children:
- include: user-guides/workspace-access.yml
- include: user-guides/desktop.yml
- title: Manage workspaces
description: Create, start, stop, update, and delete your Coder workspaces from the dashboard or CLI.
path: ./user-guides/workspace-management.md
icon_path: ./images/icons/generic.svg
- title: Shared workspaces
description: Let multiple users securely connect to a single Coder workspace to program and debug together.
path: ./user-guides/shared-workspaces.md
icon_path: ./images/icons/generic.svg
- title: Manage workspace schedules
description: Control cloud costs by scheduling when your Coder workspaces automatically start and stop.
path: ./user-guides/workspace-scheduling.md
icon_path: ./images/icons/stopwatch.svg
- title: Workspace lifecycle
description: A guide to the workspace lifecycle, from creation and status through stopping and deletion.
path: ./user-guides/workspace-lifecycle.md
icon_path: ./images/icons/circle-dot.svg
- include: user-guides/devcontainers.yml
- title: Dotfiles
description: Personalize your Coder workspaces by applying your dotfiles repository with the coder dotfiles command.
path: ./user-guides/workspace-dotfiles.md
icon_path: ./images/icons/art-pad.svg
- title: User secrets
description: Store secret values in Coder and automatically inject them into workspaces
path: ./user-guides/user-secrets.md
icon_path: ./images/icons/secrets.svg
+8
View File
@@ -0,0 +1,8 @@
title: Coder Desktop
description: Transform remote workspaces into seamless local development environments with no port forwarding required
path: ./user-guides/desktop/index.md
icon_path: ./images/icons/computer-code.svg
children:
- title: Coder Desktop Connect and sync
description: Use Coder Desktop to connect to workspaces and sync their code and files to your local machine.
path: ./user-guides/desktop/desktop-connect-sync.md
@@ -0,0 +1,14 @@
title: Dev Containers
description: Run containerized development environments in your Coder workspace using the dev containers specification.
path: ./user-guides/devcontainers/index.md
icon_path: ./images/icons/container.svg
children:
- title: Work with dev containers
description: Access and work inside dev containers in your Coder workspace over SSH, your IDE, or the web terminal.
path: ./user-guides/devcontainers/working-with-dev-containers.md
- title: Customizing dev containers
description: Configure custom agent names, apps, and display options in devcontainer.json.
path: ./user-guides/devcontainers/customizing-dev-containers.md
- title: Troubleshooting dev containers
description: Diagnose and resolve common issues with dev containers in your Coder workspace.
path: ./user-guides/devcontainers/troubleshooting-dev-containers.md
@@ -0,0 +1,42 @@
title: Workspace access
description: Connect to your Coder workspace using SSH, your IDE, a web terminal, remote desktop, and more.
path: ./user-guides/workspace-access/index.md
icon_path: ./images/icons/access.svg
children:
- title: Visual Studio Code
description: Develop in your Coder workspace remotely with VS Code, using the desktop app or the browser.
path: ./user-guides/workspace-access/vscode.md
- title: Web terminal
description: Use the browser-based web terminal to run commands in your workspace without any local setup.
path: ./user-guides/workspace-access/web-terminal.md
- include: user-guides/workspace-access/jetbrains.yml
- title: Remote desktops
description: Connect to a GUI-based desktop in your Coder workspace using RDP, including Windows workspaces.
path: ./user-guides/workspace-access/remote-desktops.md
- title: Emacs TRAMP
description: Use Emacs TRAMP to edit files and run commands in your Coder workspace over SSH.
path: ./user-guides/workspace-access/emacs-tramp.md
- title: Workspace ports
description: Securely access ports and processes running inside your Coder workspace from your local machine.
path: ./user-guides/workspace-access/port-forwarding.md
- title: File browser
description: Upload, download, and manage files in your Coder workspace from the browser with File Browser.
path: ./user-guides/workspace-access/filebrowser.md
- title: Web IDEs
description: Access your Coder workspace through web-based IDEs that run in the browser, with no local install.
path: ./user-guides/workspace-access/web-ides.md
- title: code-server
description: Access your Coder workspace in the browser with code-server, the VS Code experience over the web.
path: ./user-guides/workspace-access/code-server.md
- title: Zed
description: Access your Coder workspace with the Zed collaborative code editor over SSH.
path: ./user-guides/workspace-access/zed.md
- title: Cursor
description: Access your Coder workspace with Cursor, the AI-powered code editor, over SSH.
path: ./user-guides/workspace-access/cursor.md
- title: Devin Desktop
description: Access your Coder workspace with Devin Desktop (formerly Windsurf), the AI-powered code editor, over SSH.
path: ./user-guides/workspace-access/devin-desktop.md
- title: Antigravity
description: Access your Coder workspace with the Antigravity agentic code editor over SSH.
path: ./user-guides/workspace-access/antigravity.md
@@ -0,0 +1,11 @@
title: JetBrains IDEs
description: Connect JetBrains IDEs to Coder workspaces using JetBrains Toolbox or Gateway.
path: ./user-guides/workspace-access/jetbrains/index.md
children:
- title: JetBrains Gateway
description: Use JetBrains Gateway to open and work in your Coder workspace from a full JetBrains IDE.
path: ./user-guides/workspace-access/jetbrains/gateway.md
- title: JetBrains Toolbox
description: Connect to and manage your Coder workspaces from the JetBrains Toolbox app.
path: ./user-guides/workspace-access/jetbrains/toolbox.md
state: [beta]
+9 -8
View File
@@ -41,17 +41,18 @@ be omitted.
## Set up the routes
Once you've written your guide, you'll need to add its route to
`docs/manifest.json` under `Guides` > `"children"` at the bottom:
`docs/manifest/tutorials.yml` under `children`:
```json
{
// Overrides the "# Guide Title" at the top of this file
"title": "Contributing to Guides",
"description": "How to add a guide",
"path": "./guides/my-guide-file.md"
},
```yaml
# The title overrides the "# Guide Title" at the top of this file.
- title: Contributing to Guides
description: How to add a guide
path: ./tutorials/my-guide-file.md
```
Then run `make gen/docs-manifest` to format the sidebar sources and rebuild
`docs/manifest.json`.
## Format before push
Before pushing your guide to github, run `make fmt` to format the files with
+20 -29
View File
@@ -151,23 +151,27 @@ func prepareDocsDirectory() error {
func writeDocs(sections [][]byte) error {
log.Println("Write docs to destination")
manifestPath := path.Join(docsDirectory, "manifest.json")
m, err := docgenenv.LoadManifest(manifestPath)
sourcesDir := path.Join(docsDirectory, docgenenv.ManifestSourcesDir)
m, err := docgenenv.LoadManifestSources(sourcesDir)
if err != nil {
return err
}
// Resolve the REST API route once. Both the page front matter and the
// regenerated manifest routes read from this single traversal, so the
// regenerated sidebar fragment read from this single traversal, so the
// metadata source and the rewrite target can't drift apart.
restAPI := m.FindRoute("Reference", "REST API")
if restAPI == nil {
return xerrors.Errorf("could not find REST API route in manifest %q", manifestPath)
return xerrors.Errorf("could not find REST API route in sidebar sources %q", sourcesDir)
}
if restAPI.ChildrenFrom == "" {
return xerrors.Errorf("REST API route in sidebar sources %q must set children_from", sourcesDir)
}
// Index existing REST API child routes by title so their curated metadata
// (description, state, icon_path) flows into both the page front matter and
// the regenerated manifest routes.
// The REST API route's children in the sources are curated metadata
// overlays (description, state, icon_path) keyed by title. Index them so
// that metadata flows into the page front matter; docsmanifestgen applies
// the same overlays to the sidebar.
existingByTitle := make(map[string]docgenenv.Route)
for _, child := range restAPI.Children {
existingByTitle[child.Title] = child
@@ -226,34 +230,21 @@ func writeDocs(sections [][]byte) error {
return slices.IsSorted([]string{mdFiles[i].title, mdFiles[j].title})
})
// Update manifest.json. Generated routes overwrite Title and Path;
// existing state/description/icon_path are preserved (keyed by title) so
// callouts like `state: ["experimental"]` survive regeneration. restAPI
// aliases m, so replacing its children updates the manifest in place.
// Write the generated routes to the sidebar fragment the sources name in
// children_from. The fragment carries only structure (title and path);
// curated metadata stays in the sources as overlays.
var children []docgenenv.Route
for _, mdf := range mdFiles {
docRoute := docgenenv.Route{
children = append(children, docgenenv.Route{
Title: mdf.title,
Path: mdf.path,
}
if existing, ok := existingByTitle[mdf.title]; ok {
docRoute.State = existing.State
docRoute.Description = existing.Description
docRoute.IconPath = existing.IconPath
}
children = append(children, docRoute)
})
}
restAPI.Children = children
manifestFile, err := m.Marshal()
if err != nil {
return xerrors.Errorf("json.Marshal failed: %w", err)
fragment := path.Join(sourcesDir, restAPI.ChildrenFrom)
if err := docgenenv.WriteRouteFragment(fragment, children); err != nil {
return err
}
if err := atomicwrite.File(manifestPath, manifestFile); err != nil {
return xerrors.Errorf("can't write manifest file: %w", err)
}
log.Printf("Write manifest file: %dB", len(manifestFile))
log.Printf("Write sidebar fragment: %s", fragment)
return nil
}
+15 -20
View File
@@ -6,7 +6,6 @@ import (
"path/filepath"
"github.com/coder/coder/v2/enterprise/cli"
"github.com/coder/coder/v2/scripts/atomicwrite"
"github.com/coder/coder/v2/scripts/docgenenv"
"github.com/coder/flog"
"github.com/coder/serpent"
@@ -42,7 +41,7 @@ func deleteEmptyDirs(dir string) error {
}
func main() {
manifestOnly := flag.Bool("manifest-only", false, "Only rebuild the \"Command Line\" section of manifest.json; do not write reference pages.")
manifestOnly := flag.Bool("manifest-only", false, "Only rebuild the \"Command Line\" sidebar fragment; do not write reference pages.")
flag.Parse()
docgenenv.Prepare()
@@ -63,17 +62,20 @@ func main() {
cliMarkdownDir = filepath.Join(docsDir, "reference/cli")
}
// Load the manifest up front so the generated index page can mirror the
// "Command Line" route's curated metadata (title/description/icon_path)
// Load the sidebar sources up front so the generated index page can mirror
// the "Command Line" route's curated metadata (title/description/icon_path)
// instead of the root command name.
manifestPath := filepath.Join(docsDir, "manifest.json")
man, err := docgenenv.LoadManifest(manifestPath)
sourcesDir := filepath.Join(docsDir, docgenenv.ManifestSourcesDir)
man, err := docgenenv.LoadManifestSources(sourcesDir)
if err != nil {
flog.Fatalf("%v", err)
}
cmdLine := man.FindRoute("Reference", "Command Line")
if cmdLine == nil {
flog.Fatalf("could not find Command Line route in manifest %q", manifestPath)
flog.Fatalf("could not find Command Line route in sidebar sources %q", sourcesDir)
}
if cmdLine.ChildrenFrom == "" {
flog.Fatalf("Command Line route in sidebar sources %q must set children_from", sourcesDir)
}
// Mirror the whole "Command Line" route (minus its nav children) so the
// index page front matter carries every current and future per-page field
@@ -88,19 +90,12 @@ func main() {
writePages(cliMarkdownDir, cmd)
}
// Rebuild the "Command Line" route's children from the command tree so
// the nav nests the same way the generated pages do. cmdLine aliases the
// manifest loaded above, so mutating it updates the manifest in place.
cmdLine.Children = cliManifestChildren(cmd)
manifestByt, err := man.Marshal()
if err != nil {
flog.Fatalf("marshaling manifest: %v", err)
}
err = atomicwrite.File(manifestPath, manifestByt)
if err != nil {
flog.Fatalf("writing manifest: %v", err)
// Write the "Command Line" route's children, built from the command tree
// so the nav nests the same way the generated pages do, to the fragment
// the sources name in children_from.
fragment := filepath.Join(sourcesDir, filepath.FromSlash(cmdLine.ChildrenFrom))
if err := docgenenv.WriteRouteFragment(fragment, cliManifestChildren(cmd)); err != nil {
flog.Fatalf("%v", err)
}
}
+34 -38
View File
@@ -3,22 +3,32 @@ package docgenenv
import (
"bytes"
"encoding/json"
"os"
"golang.org/x/xerrors"
)
// Route is an individual page object in the docs manifest.json. Per-page
// metadata (title, description, icon_path, state) is mirrored into page front
// matter by the doc generators; the structural fields (path, children) stay in
// the manifest.
//
// The same type decodes the YAML sidebar sources under docs/manifest, so the
// field order here is the key order enforced in both the sources and the
// compiled manifest.json.
type Route struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Path string `json:"path,omitempty"`
IconPath string `json:"icon_path,omitempty"`
State []string `json:"state,omitempty"`
Children []Route `json:"children,omitempty"`
Title string `json:"title,omitempty" yaml:"title,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"`
IconPath string `json:"icon_path,omitempty" yaml:"icon_path,omitempty"`
State []string `json:"state,omitempty" yaml:"state,omitempty"`
// ChildrenFrom names a generated fragment, relative to the sources
// directory, that supplies this route's children. It exists only in the
// sources; BuildManifest replaces it with the fragment's routes.
ChildrenFrom string `json:"-" yaml:"children_from,omitempty"`
// Include names another source file, relative to the sources directory,
// that holds this child route. It exists only in the sources, where an
// include entry sets no other key; the loader replaces the entry with the
// route in the named file.
Include string `json:"-" yaml:"include,omitempty"`
Children []Route `json:"children,omitempty" yaml:"children,omitempty"`
}
// Manifest describes the entire documentation index (docs/manifest.json).
@@ -27,35 +37,6 @@ type Manifest struct {
Routes []Route `json:"routes,omitempty"`
}
// LoadManifest reads and unmarshals the manifest.json at path. Its errors wrap
// the path and cause, so callers should return the error as-is rather than
// wrapping it again.
func LoadManifest(path string) (*Manifest, error) {
b, err := os.ReadFile(path)
if err != nil {
return nil, xerrors.Errorf("read manifest %q: %w", path, err)
}
var m Manifest
if err := json.Unmarshal(b, &m); err != nil {
return nil, xerrors.Errorf("unmarshal manifest %q: %w", path, err)
}
return &m, nil
}
// Marshal encodes the manifest as indented JSON with a trailing newline.
// Unlike json.MarshalIndent, it leaves &, < and > unescaped so titles such as
// "Groups & Roles" stay readable in the file. Both forms decode identically.
func (m *Manifest) Marshal() ([]byte, error) {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")
if err := enc.Encode(m); err != nil {
return nil, xerrors.Errorf("marshal manifest: %w", err)
}
return buf.Bytes(), nil
}
// FindRoute walks the manifest, following titles as a breadcrumb from the
// top-level routes, and returns a pointer to the matching route (or nil if any
// title in the path has no match). The returned pointer aliases the manifest,
@@ -85,3 +66,18 @@ func (m *Manifest) FindRoute(titles ...string) *Route {
}
return match
}
// MarshalJSON renders v as tab-indented JSON with a trailing newline. The
// Makefile runs biome over the result, so this only needs to be stable, not
// final. It leaves &, < and > unescaped so titles such as "Groups & Roles"
// stay readable in the file; both forms decode identically.
func MarshalJSON(v any) ([]byte, error) {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
if err := enc.Encode(v); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
+7 -10
View File
@@ -1,8 +1,7 @@
package docgenenv_test
import (
"os"
"path/filepath"
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
@@ -40,23 +39,21 @@ func TestManifestFindRoute(t *testing.T) {
require.Nil(t, m.FindRoute("REST API")) // Not a top-level route.
}
func TestManifestMarshal(t *testing.T) {
func TestMarshalJSON(t *testing.T) {
t.Parallel()
m := &docgenenv.Manifest{
Routes: []docgenenv.Route{{Title: "Groups & Roles <beta>", Path: "./a.md"}},
}
b, err := m.Marshal()
b, err := docgenenv.MarshalJSON(m)
require.NoError(t, err)
require.Contains(t, string(b), `"title": "Groups & Roles <beta>"`)
require.NotContains(t, string(b), `\u00`)
require.Equal(t, byte('\n'), b[len(b)-1])
// Round-trips through the loader unchanged.
path := filepath.Join(t.TempDir(), "manifest.json")
require.NoError(t, os.WriteFile(path, b, 0o600))
got, err := docgenenv.LoadManifest(path)
require.NoError(t, err)
require.Equal(t, m, got)
// Decodes back to the same manifest.
var got docgenenv.Manifest
require.NoError(t, json.Unmarshal(b, &got))
require.Equal(t, m, &got)
}
+425
View File
@@ -0,0 +1,425 @@
package docgenenv
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"slices"
"strings"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
"github.com/coder/coder/v2/scripts/atomicwrite"
)
const (
// ManifestSourcesDir is the directory, relative to the docs directory,
// that holds the hand-edited YAML sidebar sources compiled into
// manifest.json.
ManifestSourcesDir = "manifest"
// ManifestIndexFile is the sources file that lists the manifest versions
// and the top-level section files in sidebar order.
ManifestIndexFile = "index.yml"
)
// ManifestIndex is the decoded ManifestIndexFile. Its field order is the key
// order enforced in the source file.
type ManifestIndex struct {
Versions []string `yaml:"versions"`
Sections []string `yaml:"sections"`
}
// LoadManifestSources reads the sidebar sources in dir: the index plus one
// top-level route per section file, with every include resolved. Routes that
// set children_from are returned unresolved, so their Children hold only the
// curated metadata overlays. The doc generators use this to read curated
// metadata without depending on the generated fragments they are about to
// rewrite.
func LoadManifestSources(dir string) (*Manifest, error) {
m, _, err := loadSources(dir)
return m, err
}
// BuildManifest reads the sidebar sources in dir, splices every children_from
// fragment into its route, and validates the result. When docsDir is not
// empty, every route path must name an existing file under it. It fails on any
// file in dir that nothing references, so a section can't silently drop out
// of the sidebar.
func BuildManifest(dir, docsDir string) (*Manifest, error) {
m, used, err := loadSources(dir)
if err != nil {
return nil, err
}
var errs []error
m.Routes = resolveRoutes(dir, m.Routes, nil, used, &errs)
if docsDir != "" {
checkPaths(docsDir, m.Routes, nil, &errs)
}
errs = append(errs, unreferencedFiles(dir, used)...)
if len(errs) > 0 {
return nil, errors.Join(errs...)
}
return m, nil
}
// WriteRouteFragment writes routes to the generated fragment at path, as YAML
// when the extension is .yml or .yaml and as JSON otherwise.
func WriteRouteFragment(path string, routes []Route) error {
var (
b []byte
err error
)
if isYAMLFile(path) {
b, err = MarshalYAML(routes)
} else {
b, err = MarshalJSON(routes)
}
if err != nil {
return xerrors.Errorf("marshal fragment %q: %w", path, err)
}
if err := atomicwrite.File(path, b); err != nil {
return xerrors.Errorf("write fragment %q: %w", path, err)
}
return nil
}
// MarshalYAML renders v as YAML with two-space indentation.
func MarshalYAML(v any) ([]byte, error) {
var buf bytes.Buffer
enc := yaml.NewEncoder(&buf)
enc.SetIndent(2)
if err := enc.Encode(v); err != nil {
return nil, err
}
if err := enc.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func loadSources(dir string) (*Manifest, map[string]bool, error) {
used := map[string]bool{ManifestIndexFile: true}
var idx ManifestIndex
if err := DecodeSourceFile(filepath.Join(dir, ManifestIndexFile), &idx); err != nil {
return nil, nil, err
}
var errs []error
if len(idx.Versions) == 0 {
errs = append(errs, xerrors.Errorf("%s: versions must list at least one version", ManifestIndexFile))
}
if len(idx.Sections) == 0 {
errs = append(errs, xerrors.Errorf("%s: sections must list at least one section file", ManifestIndexFile))
}
m := &Manifest{Versions: idx.Versions}
for _, section := range idx.Sections {
name, err := sourceRel(section)
if err != nil {
errs = append(errs, xerrors.Errorf("%s: section %q: %w", ManifestIndexFile, section, err))
continue
}
if !isYAMLFile(name) {
errs = append(errs, xerrors.Errorf("%s: section %q must be a .yml file", ManifestIndexFile, section))
continue
}
if used[name] {
errs = append(errs, xerrors.Errorf("%s: section %q is listed more than once", ManifestIndexFile, section))
continue
}
used[name] = true
if r, ok := loadRouteFile(dir, name, nil, used, &errs); ok {
m.Routes = append(m.Routes, r)
}
}
if len(errs) > 0 {
return nil, nil, errors.Join(errs...)
}
return m, used, nil
}
// loadRouteFile decodes the route in the source file name and replaces each
// include entry among its children with the route loaded from the named file.
// A source file holds one route and one level of children, so a child with
// children or children_from of its own must live in its own file.
func loadRouteFile(dir, name string, crumb []string, used map[string]bool, errs *[]error) (Route, bool) {
var r Route
if err := DecodeSourceFile(filepath.Join(dir, name), &r); err != nil {
*errs = append(*errs, err)
return Route{}, false
}
crumb = append(slices.Clip(crumb), r.Title)
where := name + ": " + breadcrumb(crumb)
checkSourceRoute(where, r, errs)
if r.Include != "" {
*errs = append(*errs, xerrors.Errorf("%s: include is allowed only on a child entry", where))
}
if r.ChildrenFrom != "" {
checkOverlays(where, r, errs)
return r, true
}
for i, c := range r.Children {
if c.Include == "" {
cw := where + " > " + c.Title
checkSourceRoute(cw, c, errs)
if len(c.Children) > 0 || c.ChildrenFrom != "" {
*errs = append(*errs, xerrors.Errorf("%s: a source file holds one level of children; move this route into its own file and include it", cw))
}
continue
}
iw := fmt.Sprintf("%s > include %q", where, c.Include)
if c.Title != "" || c.Description != "" || c.Path != "" || c.IconPath != "" || len(c.State) > 0 || c.ChildrenFrom != "" || len(c.Children) > 0 {
*errs = append(*errs, xerrors.Errorf("%s: an include entry may set only include; put the route's keys in the included file", iw))
continue
}
inc, err := sourceRel(c.Include)
switch {
case err != nil:
*errs = append(*errs, xerrors.Errorf("%s: %w", iw, err))
continue
case !isYAMLFile(inc):
*errs = append(*errs, xerrors.Errorf("%s: must be a .yml file", iw))
continue
case used[inc]:
*errs = append(*errs, xerrors.Errorf("%s: file is already listed in %s or included elsewhere", iw, ManifestIndexFile))
continue
}
used[inc] = true
if child, ok := loadRouteFile(dir, inc, crumb, used, errs); ok {
r.Children[i] = child
}
}
return r, true
}
// checkSourceRoute checks the keys every hand-edited route needs.
func checkSourceRoute(where string, r Route, errs *[]error) {
if r.Title == "" {
*errs = append(*errs, xerrors.Errorf("%s: route is missing a title", where))
}
if r.Path == "" {
*errs = append(*errs, xerrors.Errorf("%s: route is missing a path", where))
}
}
// checkOverlays checks a children_from route before its fragment is resolved.
func checkOverlays(where string, r Route, errs *[]error) {
if _, err := sourceRel(r.ChildrenFrom); err != nil {
*errs = append(*errs, xerrors.Errorf("%s: children_from %q: %w", where, r.ChildrenFrom, err))
}
// With children_from, children are metadata overlays matched by title
// onto the generated routes, so they can't carry structure of their own.
for _, o := range r.Children {
ow := where + " > " + o.Title
switch {
case o.Title == "":
*errs = append(*errs, xerrors.Errorf("%s: overlay is missing a title", where))
case o.Path != "" || len(o.Children) > 0 || o.ChildrenFrom != "" || o.Include != "":
*errs = append(*errs, xerrors.Errorf("%s: overlays under children_from may set only title, description, icon_path, and state", ow))
}
}
}
// resolveRoutes returns routes with every children_from fragment spliced in
// and its overlays applied.
func resolveRoutes(dir string, routes []Route, crumb []string, used map[string]bool, errs *[]error) []Route {
out := slices.Clone(routes)
for i := range out {
r := &out[i]
c := append(slices.Clip(crumb), r.Title)
if r.ChildrenFrom == "" {
r.Children = resolveRoutes(dir, r.Children, c, used, errs)
continue
}
name, _ := sourceRel(r.ChildrenFrom) // Validated by loadSources.
used[name] = true
var generated []Route
if err := DecodeSourceFile(filepath.Join(dir, name), &generated); err != nil {
*errs = append(*errs, xerrors.Errorf("%s: %w", breadcrumb(c), err))
continue
}
validateFragment(name, generated, nil, errs)
r.Children = applyOverlays(name, generated, r.Children, breadcrumb(c), errs)
r.ChildrenFrom = ""
}
return out
}
func validateFragment(file string, routes []Route, crumb []string, errs *[]error) {
for _, r := range routes {
c := append(slices.Clip(crumb), r.Title)
switch {
case r.Title == "":
*errs = append(*errs, xerrors.Errorf("%s: %s: route is missing a title", file, breadcrumb(c)))
case r.Path == "":
*errs = append(*errs, xerrors.Errorf("%s: %s: route is missing a path", file, breadcrumb(c)))
case r.ChildrenFrom != "" || r.Include != "":
*errs = append(*errs, xerrors.Errorf("%s: %s: fragments can't set children_from or include", file, breadcrumb(c)))
}
validateFragment(file, r.Children, c, errs)
}
}
// applyOverlays fills empty metadata on the generated routes from the curated
// overlays with the same title. A field set on both sides must match, so the
// manifest and the generated page front matter can't disagree. An overlay
// that matches no generated route is an error rather than silently dropped
// metadata.
func applyOverlays(file string, generated, overlays []Route, where string, errs *[]error) []Route {
byTitle := make(map[string]Route, len(overlays))
for _, o := range overlays {
if _, dup := byTitle[o.Title]; dup {
*errs = append(*errs, xerrors.Errorf("%s: overlay %q is listed more than once", where, o.Title))
}
byTitle[o.Title] = o
}
matched := make(map[string]bool, len(overlays))
out := slices.Clone(generated)
for i := range out {
g := &out[i]
o, ok := byTitle[g.Title]
if !ok {
continue
}
matched[g.Title] = true
ow := where + " > " + g.Title
fill := func(field string, dst *string, src string) {
switch {
case src == "":
case *dst == "":
*dst = src
case *dst != src:
*errs = append(*errs, xerrors.Errorf("%s: overlay %s %q conflicts with generated %q in %s", ow, field, src, *dst, file))
}
}
fill("description", &g.Description, o.Description)
fill("icon_path", &g.IconPath, o.IconPath)
switch {
case len(o.State) == 0:
case len(g.State) == 0:
g.State = o.State
case !slices.Equal(g.State, o.State):
*errs = append(*errs, xerrors.Errorf("%s: overlay state %q conflicts with generated %q in %s", ow, o.State, g.State, file))
}
}
for _, o := range overlays {
if !matched[o.Title] {
*errs = append(*errs, xerrors.Errorf("%s: overlay %q matches no route in %s; rename or remove it", where, o.Title, file))
}
}
return out
}
func checkPaths(docsDir string, routes []Route, crumb []string, errs *[]error) {
for _, r := range routes {
c := append(slices.Clip(crumb), r.Title)
info, err := os.Stat(filepath.Join(docsDir, filepath.FromSlash(r.Path)))
if err != nil || !info.Mode().IsRegular() {
*errs = append(*errs, xerrors.Errorf("%s: path %q does not exist under %s", breadcrumb(c), r.Path, docsDir))
}
checkPaths(docsDir, r.Children, c, errs)
}
}
func unreferencedFiles(dir string, used map[string]bool) []error {
var errs []error
err := filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() || strings.HasPrefix(d.Name(), ".") {
return nil
}
rel, err := filepath.Rel(dir, path)
if err != nil {
return err
}
if rel = filepath.ToSlash(rel); !used[rel] {
errs = append(errs, xerrors.Errorf("%s: not listed in %s sections, any include, or any children_from", rel, ManifestIndexFile))
}
return nil
})
if err != nil {
errs = append(errs, xerrors.Errorf("walk %q: %w", dir, err))
}
return errs
}
// DecodeSourceFile strictly decodes one sidebar source or fragment into v:
// YAML for .yml and .yaml files and JSON otherwise. Unknown keys, extra
// documents, and trailing data are errors. In YAML, a comment on the same line
// as a title or description is rejected, because an unquoted " #" there
// silently truncates the value.
func DecodeSourceFile(path string, v any) error {
b, err := os.ReadFile(path)
if err != nil {
return xerrors.Errorf("read %q: %w", path, err)
}
name := filepath.Base(path)
if !isYAMLFile(path) {
dec := json.NewDecoder(bytes.NewReader(b))
dec.DisallowUnknownFields()
if err := dec.Decode(v); err != nil {
return xerrors.Errorf("%s: %w", name, err)
}
if _, err := dec.Token(); !errors.Is(err, io.EOF) {
return xerrors.Errorf("%s: unexpected data after the top-level value", name)
}
return nil
}
dec := yaml.NewDecoder(bytes.NewReader(b))
dec.KnownFields(true)
if err := dec.Decode(v); err != nil {
if errors.Is(err, io.EOF) {
return xerrors.Errorf("%s: file is empty", name)
}
return xerrors.Errorf("%s: %w", name, err)
}
var extra yaml.Node
if err := dec.Decode(&extra); !errors.Is(err, io.EOF) {
return xerrors.Errorf("%s: file must contain a single YAML document", name)
}
var doc yaml.Node
if err := yaml.Unmarshal(b, &doc); err != nil {
return xerrors.Errorf("%s: %w", name, err)
}
var errs []error
checkProseComments(name, &doc, &errs)
return errors.Join(errs...)
}
func checkProseComments(file string, n *yaml.Node, errs *[]error) {
if n.Kind == yaml.MappingNode {
for i := 0; i+1 < len(n.Content); i += 2 {
k, v := n.Content[i], n.Content[i+1]
if (k.Value == "title" || k.Value == "description") && v.Kind == yaml.ScalarNode && (k.LineComment != "" || v.LineComment != "") {
*errs = append(*errs, xerrors.Errorf("%s: line %d: %s has a trailing comment; if the value contains \" #\", quote it", file, v.Line, k.Value))
}
}
}
for _, c := range n.Content {
checkProseComments(file, c, errs)
}
}
// sourceRel validates a sources-relative file name and returns it in slash
// form.
func sourceRel(name string) (string, error) {
clean := filepath.Clean(filepath.FromSlash(name))
if name == "" || !filepath.IsLocal(clean) {
return "", xerrors.New("must be a relative path inside the sources directory")
}
return filepath.ToSlash(clean), nil
}
func isYAMLFile(path string) bool {
ext := filepath.Ext(path)
return ext == ".yml" || ext == ".yaml"
}
func breadcrumb(crumb []string) string {
return strings.Join(crumb, " > ")
}
+317
View File
@@ -0,0 +1,317 @@
package docgenenv_test
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/scripts/docgenenv"
)
// writeTree writes files (sources-relative name to content) under a new docs
// directory's manifest sources and returns the docs and sources directories.
// Every route path used by the tests exists as a page under the docs dir.
func writeTree(t *testing.T, files map[string]string) (docsDir, sourcesDir string) {
t.Helper()
docsDir = t.TempDir()
sourcesDir = filepath.Join(docsDir, docgenenv.ManifestSourcesDir)
for _, page := range []string{"index.md", "ref/index.md", "ref/api/index.md", "ref/api/general.md", "ref/api/users.md"} {
p := filepath.Join(docsDir, page)
require.NoError(t, os.MkdirAll(filepath.Dir(p), 0o755))
require.NoError(t, os.WriteFile(p, []byte("# page\n"), 0o600))
}
for name, content := range files {
p := filepath.Join(sourcesDir, name)
require.NoError(t, os.MkdirAll(filepath.Dir(p), 0o755))
require.NoError(t, os.WriteFile(p, []byte(content), 0o600))
}
return docsDir, sourcesDir
}
const (
testIndex = "versions: [main]\nsections:\n - home.yml\n - ref.yml\n"
testHome = "title: Home\npath: ./index.md\n"
testRef = `title: Reference
path: ./ref/index.md
children:
- include: ref/api.yml
`
testRefAPI = `title: REST API
path: ./ref/api/index.md
children_from: generated/api.json
children:
- title: Users
description: Manage users.
state: [beta]
`
testAPI = `[{"title": "General", "path": "./ref/api/general.md"}, {"title": "Users", "path": "./ref/api/users.md"}]`
)
func validTree() map[string]string {
return map[string]string{
"index.yml": testIndex,
"home.yml": testHome,
"ref.yml": testRef,
"ref/api.yml": testRefAPI,
"generated/api.json": testAPI,
}
}
func TestBuildManifest(t *testing.T) {
t.Parallel()
docsDir, sourcesDir := writeTree(t, validTree())
m, err := docgenenv.BuildManifest(sourcesDir, docsDir)
require.NoError(t, err)
require.Equal(t, []string{"main"}, m.Versions)
require.Len(t, m.Routes, 2)
api := m.FindRoute("Reference", "REST API")
require.NotNil(t, api)
require.Empty(t, api.ChildrenFrom)
// Generated routes keep their order; the overlay fills in metadata.
require.Equal(t, []docgenenv.Route{
{Title: "General", Path: "./ref/api/general.md"},
{Title: "Users", Description: "Manage users.", Path: "./ref/api/users.md", State: []string{"beta"}},
}, api.Children)
// Keys follow the struct order and children_from never reaches the JSON.
b, err := docgenenv.MarshalJSON(api)
require.NoError(t, err)
require.NotContains(t, string(b), "children_from")
require.Regexp(t, `(?s)"title": "Users",\s*"description".*"path".*"state"`, string(b))
}
func TestBuildManifestYAMLFragment(t *testing.T) {
t.Parallel()
files := validTree()
delete(files, "generated/api.json")
files["ref/api.yml"] = `title: REST API
path: ./ref/api/index.md
children_from: generated/api.yml
`
files["generated/api.yml"] = "- title: General\n path: ./ref/api/general.md\n"
docsDir, sourcesDir := writeTree(t, files)
m, err := docgenenv.BuildManifest(sourcesDir, docsDir)
require.NoError(t, err)
require.Equal(t, []docgenenv.Route{{Title: "General", Path: "./ref/api/general.md"}}, m.FindRoute("Reference", "REST API").Children)
}
func TestLoadManifestSourcesLeavesOverlaysUnresolved(t *testing.T) {
t.Parallel()
_, sourcesDir := writeTree(t, validTree())
m, err := docgenenv.LoadManifestSources(sourcesDir)
require.NoError(t, err)
api := m.FindRoute("Reference", "REST API")
require.NotNil(t, api)
require.Equal(t, "generated/api.json", api.ChildrenFrom)
require.Equal(t, []docgenenv.Route{{Title: "Users", Description: "Manage users.", State: []string{"beta"}}}, api.Children)
}
func TestBuildManifestErrors(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
edit func(files map[string]string)
wantErr string
}{
{
name: "UnknownKey",
edit: func(f map[string]string) { f["home.yml"] = "title: Home\ntitel: typo\npath: ./index.md\n" },
wantErr: "field titel not found",
},
{
name: "UnknownFragmentKey",
edit: func(f map[string]string) { f["generated/api.json"] = `[{"title": "General", "paht": "x"}]` },
wantErr: `unknown field "paht"`,
},
{
name: "MissingPage",
edit: func(f map[string]string) { f["home.yml"] = "title: Home\npath: ./nope.md\n" },
wantErr: `Home: path "./nope.md" does not exist`,
},
{
name: "MissingPath",
edit: func(f map[string]string) { f["home.yml"] = "title: Home\n" },
wantErr: "home.yml: Home: route is missing a path",
},
{
name: "UnreferencedFile",
edit: func(f map[string]string) { f["orphan.yml"] = testHome },
wantErr: "orphan.yml: not listed",
},
{
name: "DuplicateSection",
edit: func(f map[string]string) { f["index.yml"] = testIndex + " - home.yml\n" },
wantErr: `section "home.yml" is listed more than once`,
},
{
name: "SectionOutsideSources",
edit: func(f map[string]string) { f["index.yml"] = "versions: [main]\nsections:\n - ../home.yml\n" },
wantErr: "must be a relative path inside the sources directory",
},
{
name: "UnmatchedOverlay",
edit: func(f map[string]string) {
f["generated/api.json"] = `[{"title": "General", "path": "./ref/api/general.md"}]`
},
wantErr: `overlay "Users" matches no route in generated/api.json`,
},
{
name: "ConflictingOverlay",
edit: func(f map[string]string) {
f["generated/api.json"] = `[{"title": "Users", "description": "Generated.", "path": "./ref/api/users.md"}]`
},
wantErr: `overlay description "Manage users." conflicts with generated "Generated."`,
},
{
name: "OverlayWithPath",
edit: func(f map[string]string) {
f["ref/api.yml"] = `title: REST API
path: ./ref/api/index.md
children_from: generated/api.json
children:
- title: Users
path: ./ref/api/users.md
`
},
wantErr: "overlays under children_from may set only",
},
{
name: "GrandchildrenInOneFile",
edit: func(f map[string]string) {
delete(f, "ref/api.yml")
f["ref.yml"] = `title: Reference
path: ./ref/index.md
children:
- title: REST API
path: ./ref/api/index.md
children:
- title: General
path: ./ref/api/general.md
`
},
wantErr: "ref.yml: Reference > REST API: a source file holds one level of children; move this route into its own file and include it",
},
{
name: "ChildWithChildrenFromInOneFile",
edit: func(f map[string]string) {
delete(f, "ref/api.yml")
f["ref.yml"] = `title: Reference
path: ./ref/index.md
children:
- title: REST API
path: ./ref/api/index.md
children_from: generated/api.json
`
},
wantErr: "move this route into its own file and include it",
},
{
name: "IncludeWithOtherKeys",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " title: REST API\n" },
wantErr: `include "ref/api.yml": an include entry may set only include`,
},
{
name: "IncludedTwice",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " - include: ref/api.yml\n" },
wantErr: `include "ref/api.yml": file is already listed in index.yml or included elsewhere`,
},
{
name: "IncludeSection",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " - include: home.yml\n" },
wantErr: `include "home.yml": file is already listed`,
},
{
name: "IncludeOutsideSources",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " - include: ../api.yml\n" },
wantErr: "must be a relative path inside the sources directory",
},
{
name: "IncludeNotYAML",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " - include: generated/api.json\n" },
wantErr: `include "generated/api.json": must be a .yml file`,
},
{
name: "IncludeMissingFile",
edit: func(f map[string]string) { f["ref.yml"] = testRef + " - include: ref/nope.yml\n" },
wantErr: "no such file or directory",
},
{
name: "IncludeOnFileRoute",
edit: func(f map[string]string) { f["home.yml"] = testHome + "include: ref/api.yml\n" },
wantErr: "home.yml: Home: include is allowed only on a child entry",
},
{
name: "MissingPathInIncludedFile",
edit: func(f map[string]string) { f["ref/api.yml"] = "title: REST API\n" },
wantErr: "ref/api.yml: Reference > REST API: route is missing a path",
},
{
name: "UnreferencedNestedFile",
edit: func(f map[string]string) { f["ref/orphan.yml"] = testHome },
wantErr: "ref/orphan.yml: not listed",
},
{
name: "IncludeInFragment",
edit: func(f map[string]string) {
f["generated/api.json"] = `[{"title": "General", "path": "./ref/api/general.md", "include": "x.yml"}]`
},
wantErr: `unknown field "include"`,
},
{
name: "IncludeInYAMLFragment",
edit: func(f map[string]string) {
delete(f, "generated/api.json")
f["ref/api.yml"] = "title: REST API\npath: ./ref/api/index.md\nchildren_from: generated/api.yml\n"
f["generated/api.yml"] = "- title: General\n path: ./ref/api/general.md\n include: x.yml\n"
},
wantErr: "generated/api.yml: General: fragments can't set children_from or include",
},
{
name: "TrailingCommentOnDescription",
edit: func(f map[string]string) {
f["home.yml"] = "title: Home\ndescription: Use #tags here\npath: ./index.md\n"
},
wantErr: "home.yml: line 2: description has a trailing comment",
},
{
name: "MultipleDocuments",
edit: func(f map[string]string) { f["home.yml"] = testHome + "---\n" + testHome },
wantErr: "single YAML document",
},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
files := validTree()
tc.edit(files)
docsDir, sourcesDir := writeTree(t, files)
_, err := docgenenv.BuildManifest(sourcesDir, docsDir)
require.ErrorContains(t, err, tc.wantErr)
})
}
}
func TestWriteRouteFragmentRoundTrips(t *testing.T) {
t.Parallel()
routes := []docgenenv.Route{
{Title: "Groups & Roles", Path: "./a.md", Children: []docgenenv.Route{{Title: "b", Path: "./b.md", State: []string{"premium"}}}},
}
dir := t.TempDir()
for _, name := range []string{"frag.json", "frag.yml"} {
p := filepath.Join(dir, name)
require.NoError(t, docgenenv.WriteRouteFragment(p, routes))
var got []docgenenv.Route
require.NoError(t, docgenenv.DecodeSourceFile(p, &got), name)
require.Equal(t, routes, got, name)
}
b, err := os.ReadFile(filepath.Join(dir, "frag.json"))
require.NoError(t, err)
require.Contains(t, string(b), `Groups & Roles`)
}
+237
View File
@@ -0,0 +1,237 @@
package main
import (
"bytes"
"errors"
"os"
"path/filepath"
"slices"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
"github.com/coder/coder/v2/scripts/atomicwrite"
"github.com/coder/coder/v2/scripts/docgenenv"
)
// routeKeyOrder and indexKeyOrder are the canonical key orders for source
// routes and the index file. They match the field order of docgenenv.Route
// and docgenenv.ManifestIndex, which TestKeyOrderMatchesStructs enforces.
var (
routeKeyOrder = []string{"title", "description", "path", "icon_path", "state", "children_from", "include", "children"}
indexKeyOrder = []string{"versions", "sections"}
)
// formattedFile is a source file whose canonical form differs from its
// contents on disk.
type formattedFile struct {
rel string // Sources-relative name, for messages.
path string
out []byte // Canonical contents.
}
// unformattedSources returns every YAML file under dir whose contents differ
// from its canonical form, without modifying anything.
func unformattedSources(dir string) ([]formattedFile, error) {
var (
changed []formattedFile
errs []error
)
err := filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() || !isYAML(path) {
return nil
}
rel, err := filepath.Rel(dir, path)
if err != nil {
return err
}
rel = filepath.ToSlash(rel)
in, err := os.ReadFile(path)
if err != nil {
return err
}
out, err := formatFile(rel, in)
if err != nil {
errs = append(errs, xerrors.Errorf("%s: %w", rel, err))
return nil
}
if !bytes.Equal(in, out) {
changed = append(changed, formattedFile{rel: rel, path: path, out: out})
}
return nil
})
if err != nil {
errs = append(errs, xerrors.Errorf("format %q: %w", dir, err))
}
return changed, errors.Join(errs...)
}
// formatSources rewrites every YAML file under dir in its canonical form.
func formatSources(dir string) error {
changed, err := unformattedSources(dir)
if err != nil {
return err
}
for _, f := range changed {
if err := atomicwrite.File(f.path, f.out); err != nil {
return xerrors.Errorf("write %s: %w", f.rel, err)
}
}
return nil
}
// formatFile returns the canonical form of one source file: keys in struct
// order, two-space indentation, string lists such as state inline, and every
// scalar plain unless quoting is needed to keep it a string. Comments are
// preserved and move with the key they are attached to.
func formatFile(rel string, in []byte) ([]byte, error) {
var doc yaml.Node
if err := yaml.Unmarshal(in, &doc); err != nil {
return nil, err
}
if doc.Kind != yaml.DocumentNode || len(doc.Content) != 1 {
return nil, xerrors.New("file must contain a single YAML document")
}
root := doc.Content[0]
var err error
switch {
case rel == docgenenv.ManifestIndexFile:
err = formatIndex(root)
case root.Kind == yaml.MappingNode:
err = formatRoute(root)
case root.Kind == yaml.SequenceNode:
err = formatRouteList(root)
default:
err = xerrors.New("top level must be a route or a list of routes")
}
if err != nil {
return nil, err
}
return docgenenv.MarshalYAML(&doc)
}
func formatIndex(n *yaml.Node) error {
if err := sortMapping(n, indexKeyOrder); err != nil {
return err
}
for i := 0; i+1 < len(n.Content); i += 2 {
v := n.Content[i+1]
style := yaml.Style(0)
if n.Content[i].Value == "versions" {
style = yaml.FlowStyle
}
if err := formatStringList(v, style); err != nil {
return xerrors.Errorf("%s: %w", n.Content[i].Value, err)
}
}
return nil
}
func formatRouteList(n *yaml.Node) error {
if n.Kind != yaml.SequenceNode {
return xerrors.Errorf("line %d: expected a list of routes", n.Line)
}
n.Style = 0
for _, c := range n.Content {
if err := formatRoute(c); err != nil {
return err
}
}
return nil
}
func formatRoute(n *yaml.Node) error {
if n.Kind != yaml.MappingNode {
return xerrors.Errorf("line %d: expected a route", n.Line)
}
n.Style = 0
if err := sortMapping(n, routeKeyOrder); err != nil {
return err
}
for i := 0; i+1 < len(n.Content); i += 2 {
k, v := n.Content[i], n.Content[i+1]
var err error
switch k.Value {
case "state":
err = formatStringList(v, yaml.FlowStyle)
case "children":
err = formatRouteList(v)
default:
err = formatString(v)
}
if err != nil {
return xerrors.Errorf("%s: %w", k.Value, err)
}
}
return nil
}
// sortMapping reorders a mapping's key/value pairs into order. Unknown and
// duplicate keys are errors.
func sortMapping(n *yaml.Node, order []string) error {
if n.Kind != yaml.MappingNode {
return xerrors.Errorf("line %d: expected a mapping", n.Line)
}
type pair struct{ k, v *yaml.Node }
pairs := make([]pair, 0, len(n.Content)/2)
seen := map[string]bool{}
for i := 0; i+1 < len(n.Content); i += 2 {
k := n.Content[i]
if !slices.Contains(order, k.Value) {
return xerrors.Errorf("line %d: unknown key %q", k.Line, k.Value)
}
if seen[k.Value] {
return xerrors.Errorf("line %d: duplicate key %q", k.Line, k.Value)
}
seen[k.Value] = true
if err := formatString(k); err != nil {
return err
}
pairs = append(pairs, pair{k, n.Content[i+1]})
}
slices.SortStableFunc(pairs, func(a, b pair) int {
return slices.Index(order, a.k.Value) - slices.Index(order, b.k.Value)
})
n.Content = n.Content[:0]
for _, p := range pairs {
n.Content = append(n.Content, p.k, p.v)
}
return nil
}
func formatStringList(n *yaml.Node, style yaml.Style) error {
if n.Kind != yaml.SequenceNode {
return xerrors.Errorf("line %d: expected a list", n.Line)
}
n.Style = style
for _, c := range n.Content {
if err := formatString(c); err != nil {
return err
}
}
return nil
}
// formatString makes n a string scalar that is plain when the plain form reads
// back as the same string, and double-quoted otherwise. That quotes values
// YAML would read as another type (no, 123, null) or change (": ", " #").
func formatString(n *yaml.Node) error {
if n.Kind != yaml.ScalarNode {
return xerrors.Errorf("line %d: expected a string", n.Line)
}
n.Tag = "!!str"
n.Style = 0
var got any
if err := yaml.Unmarshal([]byte(n.Value), &got); err != nil || got != n.Value {
n.Style = yaml.DoubleQuotedStyle
}
return nil
}
func isYAML(path string) bool {
ext := filepath.Ext(path)
return ext == ".yml" || ext == ".yaml"
}
+182
View File
@@ -0,0 +1,182 @@
package main
import (
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/scripts/docgenenv"
)
func yamlKeys(t reflect.Type) []string {
var keys []string
for i := range t.NumField() {
keys = append(keys, strings.Split(t.Field(i).Tag.Get("yaml"), ",")[0])
}
return keys
}
func TestKeyOrderMatchesStructs(t *testing.T) {
t.Parallel()
require.Equal(t, yamlKeys(reflect.TypeOf(docgenenv.Route{})), routeKeyOrder)
require.Equal(t, yamlKeys(reflect.TypeOf(docgenenv.ManifestIndex{})), indexKeyOrder)
}
func TestFormatFile(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
rel string
in string
want string
}{
{
name: "ReordersKeysAndMovesCommentsWithThem",
rel: "section.yml",
in: `children:
- path: ./b.md
title: B
path: ./a.md
# Above title.
title: A
`,
want: `# Above title.
title: A
path: ./a.md
children:
- title: B
path: ./b.md
`,
},
{
name: "KeepsCommentsInPlace",
rel: "section.yml",
in: `# Header.
title: A
path: ./a.md
children:
# Above B.
- title: B
path: ./b.md
- title: C
# Above path.
path: ./c.md # trailing
`,
want: `# Header.
title: A
path: ./a.md
children:
# Above B.
- title: B
path: ./b.md
- title: C
# Above path.
path: ./c.md # trailing
`,
},
{
name: "NormalizesQuotingAndLists",
rel: "section.yml",
in: `title: "Plain"
description: 'Needs: quotes'
path: ./a.md
state:
- beta
- early access
children:
- title: "123"
path: ./b.md
- title: "true"
path: ./c.md
- title: "a #b"
path: ./d.md
`,
want: `title: Plain
description: "Needs: quotes"
path: ./a.md
state: [beta, early access]
children:
- title: "123"
path: ./b.md
- title: "true"
path: ./c.md
- title: "a #b"
path: ./d.md
`,
},
{
name: "Include",
rel: "section.yml",
in: "title: A\npath: ./a.md\nchildren:\n - {include: \"section/b.yml\"}\n",
want: "title: A\npath: ./a.md\nchildren:\n - include: section/b.yml\n",
},
{
name: "Index",
rel: docgenenv.ManifestIndexFile,
in: "# Header.\n\nsections: [a.yml, b.yml]\nversions:\n - main\n",
want: "# Header.\n\nversions: [main]\nsections:\n - a.yml\n - b.yml\n",
},
{
name: "Fragment",
rel: "generated/frag.yml",
in: "- path: ./a.md\n title: A\n",
want: "- title: A\n path: ./a.md\n",
},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got, err := formatFile(tc.rel, []byte(tc.in))
require.NoError(t, err)
require.Equal(t, tc.want, string(got))
// Formatting is idempotent.
again, err := formatFile(tc.rel, got)
require.NoError(t, err)
require.Equal(t, string(got), string(again))
})
}
}
func TestFormatFileErrors(t *testing.T) {
t.Parallel()
_, err := formatFile("section.yml", []byte("title: A\ntitel: B\n"))
require.ErrorContains(t, err, `line 2: unknown key "titel"`)
_, err = formatFile("section.yml", []byte("title: A\ntitle: B\n"))
require.Error(t, err)
_, err = formatFile("section.yml", []byte("title: [A]\n"))
require.ErrorContains(t, err, "expected a string")
}
func TestCheckReportsUnformattedFiles(t *testing.T) {
t.Parallel()
docsDir := t.TempDir()
sources := filepath.Join(docsDir, docgenenv.ManifestSourcesDir)
require.NoError(t, os.MkdirAll(sources, 0o755))
require.NoError(t, os.WriteFile(filepath.Join(docsDir, "index.md"), []byte("# page\n"), 0o600))
require.NoError(t, os.WriteFile(filepath.Join(sources, docgenenv.ManifestIndexFile), []byte("versions: [main]\nsections:\n - home.yml\n"), 0o600))
require.NoError(t, os.WriteFile(filepath.Join(sources, "home.yml"), []byte("path: ./index.md\ntitle: Home\n"), 0o600))
err := run([]string{"check", "-docs", docsDir})
require.ErrorContains(t, err, "home.yml: not formatted")
require.NoError(t, run([]string{"fmt", "-docs", docsDir}))
require.NoError(t, run([]string{"check", "-docs", docsDir}))
out := filepath.Join(t.TempDir(), "manifest.json")
require.NoError(t, run([]string{"build", "-docs", docsDir, "-out", out}))
b, err := os.ReadFile(out)
require.NoError(t, err)
require.JSONEq(t, `{"versions": ["main"], "routes": [{"title": "Home", "path": "./index.md"}]}`, string(b))
}
+76
View File
@@ -0,0 +1,76 @@
// Command docsmanifestgen compiles the YAML sidebar sources under
// docs/manifest into docs/manifest.json, formats those sources, and checks
// them.
//
// Usage:
//
// docsmanifestgen build [-docs docs] [-out docs/manifest.json]
// docsmanifestgen fmt [-docs docs]
// docsmanifestgen check [-docs docs]
package main
import (
"errors"
"flag"
"fmt"
"os"
"path/filepath"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/scripts/atomicwrite"
"github.com/coder/coder/v2/scripts/docgenenv"
)
func main() {
if err := run(os.Args[1:]); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run(args []string) error {
if len(args) == 0 {
return xerrors.New("usage: docsmanifestgen <build|fmt|check> [flags]")
}
fs := flag.NewFlagSet("docsmanifestgen "+args[0], flag.ContinueOnError)
docsDir := fs.String("docs", "docs", "Docs directory. Sources are read from its manifest subdirectory.")
out := fs.String("out", "", "Output path for build. Defaults to manifest.json in the docs directory.")
if err := fs.Parse(args[1:]); err != nil {
return err
}
sourcesDir := filepath.Join(*docsDir, docgenenv.ManifestSourcesDir)
switch args[0] {
case "build":
m, err := docgenenv.BuildManifest(sourcesDir, *docsDir)
if err != nil {
return err
}
b, err := docgenenv.MarshalJSON(m)
if err != nil {
return err
}
if *out == "" {
*out = filepath.Join(*docsDir, "manifest.json")
}
return atomicwrite.File(*out, b)
case "fmt":
return formatSources(sourcesDir)
case "check":
var errs []error
if _, err := docgenenv.BuildManifest(sourcesDir, *docsDir); err != nil {
errs = append(errs, err)
}
unformatted, err := unformattedSources(sourcesDir)
if err != nil {
errs = append(errs, err)
}
for _, f := range unformatted {
errs = append(errs, xerrors.Errorf("%s: not formatted; run make fmt/docs-manifest", f.rel))
}
return errors.Join(errs...)
default:
return xerrors.Errorf("unknown subcommand %q: want build, fmt, or check", args[0])
}
}