|
| 1 | +# Writing & Publishing Documentation |
| 2 | + |
| 3 | +Follow this guide when you need to add or update markdown pages under `docs/` and preview the documentation locally. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 🧩 Prerequisites |
| 8 | + |
| 9 | +* **Python ≥ 3.10** (only for the initial virtual env – *not* required if you already have one) |
| 10 | +* `make` (GNU Make 4+) |
| 11 | +* (First-time only) **[`mkdocs-material`](https://squidfunk.github.io/mkdocs-material/)** and plugins are installed automatically by the *docs* `Makefile`. |
| 12 | +* One-time GitHub setup, e.g. [gitconfig setup](./github.md#16-personal-git-configuration-recommended) |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## ⚡ One-liner for a live preview |
| 17 | + |
| 18 | +```bash |
| 19 | +cd docs |
| 20 | +make venv # First-time only, installs dependencies into a venv under `~/.venv/mcpgateway-docs` |
| 21 | +make serve # http://localhost:8000 (auto-reload on save) |
| 22 | +``` |
| 23 | + |
| 24 | +*The `serve` target automatically creates a project-local virtual environment (under `~/.venv/mcpgateway-docs`) the first time you run it and installs all doc dependencies before starting **MkDocs** in live-reload mode.* |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## 📂 Folder layout |
| 29 | + |
| 30 | +```text |
| 31 | +repo-root/ |
| 32 | +├─ docs/ # MkDocs project (DO NOT put .md files here!) |
| 33 | +│ ├─ docs/ # <-- ────────────▶ place Markdown pages here |
| 34 | +│ │ └─ ... |
| 35 | +│ ├─ mkdocs.yml # MkDocs config & navigation |
| 36 | +│ └─ Makefile # build / serve / clean targets |
| 37 | +└─ Makefile # repo-wide helper targets (lint, spellcheck, …) |
| 38 | +``` |
| 39 | + |
| 40 | +* **Add new pages** inside `docs/docs/` – organise them in folders that make sense for navigation. |
| 41 | +* **Update navigation**: edit `.pages` for your section so your page shows up in the left-hand nav. |
| 42 | + |
| 43 | +> **Tip:** MkDocs Material auto-generates "Edit this page" links – keep file names lowercase-hyphen-case. |
| 44 | +
|
| 45 | +--- |
| 46 | + |
| 47 | +## ✏️ Editing tips |
| 48 | + |
| 49 | +1. Write in **standard Markdown**; we also support admonitions, call-outs, and Mermaid diagrams. |
| 50 | +2. Use relative links between pages: `[Gateway API](../api/index.md)`. |
| 51 | +3. For local images place them under `docs/docs/images/` and reference with ``. |
| 52 | +4. Never edit `mkdocs.yml` - all nav structure is defined in `.pages` files (one per directory). |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## ✏️ Writing docs |
| 57 | + |
| 58 | +Start each new Markdown file with a clear **`# Heading 1`** title – this becomes the visible page title and is required for proper rendering in MkDocs. |
| 59 | + |
| 60 | +Follow the conventions and layout guidelines from the official **[MkDocs Material reference](https://squidfunk.github.io/mkdocs-material/reference/)** for callouts, tables, code blocks, and more. This ensures consistent formatting across the docs. |
| 61 | + |
| 62 | +Keep file names in `lowercase-hyphen-case.md` and use relative links when referencing other docs or images. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## 🗂️ Ordering pages with `.pages` |
| 67 | + |
| 68 | +For directories that contain multiple Markdown files, we rely on the [awesome-pages](https://henrywhitaker3.github.io/mkdocs-material-dark-theme/plugins/awesome-pages/) MkDocs plugin. |
| 69 | + |
| 70 | +Creating a `.pages` file inside a folder lets you: |
| 71 | + |
| 72 | +* **Set the section title** (different from the folder name). |
| 73 | +* **Control the left‑nav order** without touching the root `mkdocs.yml`. |
| 74 | +* **Hide** specific files from the navigation. |
| 75 | + |
| 76 | +We do **not** auto-generate the `nav:` structure – you must create `.pages` manually. |
| 77 | + |
| 78 | +Example – *docs for the **development** section:* |
| 79 | + |
| 80 | +```yaml |
| 81 | +# docs/docs/development/.pages |
| 82 | +# This file affects ONLY this folder and its sub‑folders |
| 83 | + |
| 84 | +# Optional: override the title shown in the nav |
| 85 | +# title: Development Guide |
| 86 | + |
| 87 | +nav: |
| 88 | + - index.md # ➟ /development/ (landing page) |
| 89 | + - github.md # contribution workflow |
| 90 | + - building.md # local build guide |
| 91 | + - packaging.md # release packaging steps |
| 92 | +``` |
| 93 | +
|
| 94 | +Guidelines: |
| 95 | +
|
| 96 | +1. Always include `index.md` first so the folder has a clean landing URL. |
| 97 | +2. List files **in the exact order** you want them to appear; anything omitted is still built but won't show in the nav. |
| 98 | +3. You can nest `.pages` files in deeper folders – rules apply hierarchically. |
| 99 | +4. Avoid circular references: do **not** include files from *other* directories. |
| 100 | + |
| 101 | +After saving a `.pages` file, simply refresh the browser running `make serve`; MkDocs will hot‑reload and the navigation tree will update instantly. |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +## ✅ Pre-commit checklist |
| 108 | + |
| 109 | +From the **repository root** run **all** lint & QA checks before pushing: |
| 110 | + |
| 111 | +```bash |
| 112 | +make spellcheck # Spell-check the codebase |
| 113 | +make spellcheck-sort # Sort local spellcheck dictionary |
| 114 | +make markdownlint # Lint Markdown files with markdownlint (requires markdownlint-cli) |
| 115 | +make pre-commit # Run all configured pre-commit hooks |
| 116 | +``` |
| 117 | + |
| 118 | +> These targets are defined in the top-level `Makefile`. Make sure you're in the repository root when running these targets. |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## 🧹 Cleaning up |
| 123 | + |
| 124 | +```bash |
| 125 | +cd docs |
| 126 | +make clean # remove generated site/ |
| 127 | +make git-clean # remove ignored files per .gitignore |
| 128 | +make git-scrub # blow away *all* untracked files – use with care! |
| 129 | +``` |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +## 🔄 Rebuilding the static site |
| 134 | + |
| 135 | +> This is not necessary, as this will be done automatically when publishing. |
| 136 | + |
| 137 | +```bash |
| 138 | +cd docs |
| 139 | +make build # outputs HTML into docs/site/ |
| 140 | +``` |
| 141 | + |
| 142 | +The `build` target produces a fully-static site (used by CI for docs previews and by GitHub Pages). |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## 📤 Publishing (CI) |
| 147 | + |
| 148 | +Docs are tested, but not deployed automatically by GitHub Actions on every push to `main`. The workflow runs `cd docs && make build`. |
| 149 | + |
| 150 | +Publishing is done manually by repo maintainers with `make deploy` which publishes the generated site to **GitHub Pages**. |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## 🔗 Related reading |
| 155 | + |
| 156 | +* [Building Locally](building.md) – how to run the gateway itself |
0 commit comments