# Writing the Jimp docs This is the guide for anyone adding or editing pages on the docs site (`packages/docs`). It covers where things live, how pages are structured, the tone to write in and how to check your work. The site is [Astro](https://astro.build) + [Starlight](https://starlight.astro.build) with a custom theme ("Kid Studio", plus a "Night Studio" dark mode). The look comes from the theme and components; page content stays plain Markdown/MDX. ## Where things live | Path | What it is | | ---------------------------------------- | ---------------------------------------------------------------------------- | | `src/content/docs/index.mdx` | Home page | | `src/content/docs/guides/*.mdx` | Guides: task-oriented walkthroughs | | `src/content/docs/concepts/*.mdx` | Concepts: how Jimp works | | `src/content/docs/methods/index.mdx` | The method index (sticker sheets) | | `src/content/docs/methods/.mdx` | One page per method or helper | | `src/content/docs/api/` | Generated by starlight-typedoc at build time. Never edit; it's git-ignored. | | `src/data/methods.ts` | Every method page: slug, API name, category, package. Drives the sidebar. | | `src/data/pages.ts` | Guides and concept pages, in sidebar order | | `src/data/categories.ts` | Method categories (labels and sticker colors) | | `src/sidebar.ts` | Builds the sidebar from the data files | | `src/components/playground/` | The live playground, sticker sheet and the op registry | | `src/components/playground/ops/*.ts` | Playground ops, one file per area | | `src/overrides/` | Starlight component overrides (header, sidebar, page title, TOC…) | | `src/styles/` | Design tokens and global styles | | `public/` | Static files. `dice.png` is the playground's default image. | | `src/og/`, `src/pages/og/` | Each page's Open Graph image, drawn at build time with `@jimp/layout`. `src/routeData.ts` points `og:image` at it. | ### Shared files The sidebar, data files, overrides, styles and the playground engine (`Playground.tsx`, `StickerSheet.tsx`, `Controls.tsx`, `registry.ts`, `types.ts`, `code.ts`, `images.ts`) are shared by every page. When several people are writing pages at once, don't edit them: work only in your own pages and your own `ops/*.ts` file. If you need a change to a shared file, ask for it. Every method and concept page already exists as a stub with its frontmatter filled in, and the sidebar already lists it. Replace the `{/* TODO */}` body. ## Tone - Write clear, accurate technical documentation. The personality comes from the visuals, not the prose: no jokes, puns, exclamation marks or emoji. - Use plain, direct sentences in the second person ("Pass `w` to set the width."). Prefer short sentences and one idea per paragraph. - Use the real API names, in code formatting: `image.resize()`, `Jimp.read`, `ResizeStrategy.BICUBIC`. Don't invent methods, options or defaults. - Check every claim against the source in `packages/` and `plugins/`. Option names, defaults and error messages must match the code exactly. When the source and an old doc disagree, the source wins. - Say what something does before how it works. Lead with the common case; put edge cases in **Notes**. - Use US spelling in prose (color, gray, center). Method names keep their own spelling, such as `greyscale`. ## Code samples - Every sample must be valid Jimp v1 and runnable as written (apart from file names). Import what you use: `import { Jimp } from "jimp";`. - Use the v1 API: options objects (`resize({ w: 100 })`), promises for `Jimp.read`, `getBuffer`, `getBase64` and `write`, named exports for constants (`ResizeStrategy`, `BlendMode`, `JimpMime`…). - Give code blocks a filename title so they get the sticker tab: ` ```ts title="example.ts" `. Use `sh` for shell commands. - Short continuation snippets (a few lines that build on the previous example) may skip the import and read, as long as `image` is clearly a Jimp image from the example above. - Run new samples before publishing. From `packages/docs`, a scratch file can import the workspace build: ```sh cat > scratch.mjs <<'EOF' import { Jimp } from "jimp"; const image = await Jimp.read("public/dice.png"); image.blur(5); console.log(image.width, image.height); EOF node scratch.mjs && rm scratch.mjs ``` Version notes: when an API or option is new in a release, add a **Notes** bullet "Added in 2.0." (with the version it shipped in). When behaviour changed, add "Changed in 2.0: …" and say in one clause what it did before. Don't document library bugs as intended behaviour; if you find one, note it in an `