Build a documentation site
Evin turns your Markdown or reStructuredText sources into validated,
framework-neutral page data. The everyinit npm package connects that data to
a Vite app; your app still owns the page components, visual theme, and
deployment. Work through these steps after you have created your sources in
Write project documentation.
1. Add a documentation build task
Add a task to .evin/workspace.flow. This example discovers the files in
docs/, validates their filenames and links, and writes the data package under
dist/docs-data:
stages: [Docs]
tasks:
docs-data:
stage: Docs
description: "Validate docs and generate routes and page data"
steps:
- uses: evin/docs@v1
with:
source_dir: docs
out: dist/docs-data
strict_filenames: true
Run the task from the repository root:
evin run docs-data
The action writes a manifest, one JSON file per page, a local asset map, any
rendered diagram SVGs, and a binary search index. Keep dist/ out of source
control; the site build regenerates this data from the docs sources.
2. Connect the Vite plugin
Install everyinit in the Vite app. The app also needs the Evin CLI available
to run the task you configured above:
npm install everyinit
Register the plugin in vite.config.js:
import { defineConfig } from "vite";
import evinDocs from "everyinit/vite";
export default defineConfig({
plugins: [
evinDocs({
command: ["evin", "run", "docs-data"],
cwd: ".",
watch: ["docs"],
}),
],
});
Here, Vite's project root is also the Evin workspace root. If the web app lives
in a subdirectory, set cwd to the workspace root and adjust watch to point
to the documentation source directory from there. The plugin runs the command
at startup and before a production build, then reruns it when watched docs
files change. You can set manifest if the action writes somewhere other than
dist/docs-data/manifest.json.
3. Resolve a route and render its page
Import the generated route table and page records in your app:
import docs from "virtual:evin/docs";
const route = docs.resolveRoute(window.location.pathname);
if (!route) {
// Show your app's not-found page.
} else {
const page = route.page;
const assets = docs.assets[page.id] ?? {};
const diagrams = docs.diagrams[page.id] ?? {};
// Render page.page.ast with your framework's components.
}
The route already contains its page record and the matching version and locale.
Use docs.routes to create your route list, or docs.resolveRoute(pathname)
when handling a request directly. Your renderer maps nodes in page.page.ast
to native headings, paragraphs, code blocks, images, and other components.
The package supplies data and runtime helpers, not a prebuilt documentation
theme or Markdown-to-HTML component library.
For a Diagram node, use its ID to find the generated SVG source in
diagrams[node.id] and embed that source inline in the page. Inline SVG keeps
its authored ID available to CSS. For example, a site can set
#check-build-flow { --diagram-accent: #536b51; } to customize one diagram.
For an Image node, resolve its source through the page's assets map before
rendering it.
4. Add search when the site needs it
The Vite plugin exposes the generated search index as a lazy import. Load only the index for the selected version and locale:
import { loadSearchIndex, searchDocs } from "virtual:evin/search";
const index = await loadSearchIndex(route.version, route.locale);
const results = searchDocs(index, "repository configuration", { limit: 8 });
The result records include routes and heading anchors so your app can link
readers directly to a matching section. Add locale and version selectors by
using docs.counterpart(route, version, locale) and docs.routeForPage(page)
to find the matching route when one exists.
Keep each tool in its role
Evin validates sources and generates the data. The npm package exposes routes, pages, assets, diagrams, and search to the frontend. Your app renders those records and controls its theme, navigation, and deployment. For exact action inputs and output schemas, see the documentation data action reference. For the complete package API, see the Everyinit npm package reference.
Next: deliver project artifacts or return to writing project documentation.