Skip to content
selfdoc
On this page

selfdoc

Your code is the documentation.

Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in

Code-Aware Directives

Embed live API references, schemas, tests, and CLI help directly from source code. Content stays in sync automatically.

Multi-Language Support

Extractors for Go, Python, TypeScript, Svelte, Zig, Dart, Kotlin, Swift and SQL feed the same directive vocabulary, so one template works across a polyglot repository.

One Static Binary

Written in Go and distributed as a single executable. No runtime, no virtualenv, no JavaScript toolchain -- `go install` it, or download the archive for your platform from the GitHub Release, and run it.

SEO & AI Optimized

Structured data, meta tags, sitemaps, llms.txt, Atom feeds, and 50+ SEO best practices built into every generated page.

Themeable & Accessible

Every built-in theme ships dark mode, WCAG AA contrast, print stylesheets, and full keyboard navigation.

selfdoc builds documentation websites from your Markdown files and source code. Write docs in Markdown, reference your actual code with directives, and selfdoc keeps everything in sync -- when your code changes, your docs update automatically.

#How it works

#1. Write Markdown with directives

Create a Markdown file in your .stricttools/docs/ folder. Use directive markers to reference modules, functions, classes, schemas, and CLI definitions in your source code. selfdoc resolves each directive at build time, extracting live content so your documentation always matches the actual implementation:

M markdown
# API Reference

:-: ref path="mypackage.core"

That :-: ref line tells selfdoc to grab the docstrings and signatures from mypackage.core and drop them right into your page. No copy-pasting, no manual updates.

#2. Configure with selfdoc.json

A config file tells selfdoc which directories hold source code and in what language, where your docs templates live, and where to write the built output. Navigation, theming, search and SEO metadata all have defaults:

{} json
{
  "source": [{"path": "mypackage/", "language": "python"}],
  "base_url": "https://myproject.example.com",
  "search_engine": "pagefind",
  "author": {"name": "Jane Doe", "url": "https://janedoe.example"},
  "versions": [{"version": "1.0.0"}],
  "locales": [{"code": "en", "label": "English", "default": true}],
  "docs": ".stricttools/docs/",
  "output": ".stricttools/docs-cache/build/"
}

selfdoc figures out the rest. It detects your project structure, builds navigation from your file layout, and applies a clean default theme.

#3. Build and deploy

Run selfdoc build and you get a full static site -- HTML, CSS, search index, sitemap, the works. Serve it locally with selfdoc serve, or deploy anywhere that hosts static files.

$_ bash
go install github.com/smm-h/selfdoc@v0
selfdoc init --base-url https://myproject.pages.dev
selfdoc build

#Before and after

Here is what a typical docs template looks like before the build, and what selfdoc turns it into after directive resolution. The Markdown file stays clean and readable while the rendered output contains the full extracted content from your source code.

Your Markdown file:

M markdown
# User Guide

Welcome to mypackage. Here is the full API:

:-: ref path="mypackage.core"

And the CLI usage:

:-: code-help path="mypackage.cli"

The rendered output: a styled HTML page with your welcome text, followed by a complete API reference (every public function, class, and docstring from mypackage.core), then a formatted CLI help section showing every command and flag from mypackage.cli. All extracted live from your source code.

Tip

You never edit the generated output. Change your code, rebuild, and the docs reflect reality.

#Features

selfdoc ships with everything you need to build, check, and deploy a documentation site, in one binary with nothing to install beside it. Here are the core capabilities that work out of the box.

Note

All of these work out of the box with zero configuration beyond the basic selfdoc.json.

  • Code-aware directives -- Embed live API references, schemas, tests, and CLI help directly from source code. Content stays in sync automatically.
  • Multi-language support -- extractors for Go, Python, TypeScript, Svelte, Zig, Dart, Kotlin, Swift and SQL, all feeding the same directive vocabulary. One project can declare several.
  • One static binary -- written in Go, with stylesheets, scripts, themes and the word list compiled in. No runtime to install, no virtual environment, no JavaScript toolchain, no configuration overhead.
  • SEO and AI optimized -- Structured data, meta tags, sitemaps, llms.txt, Atom feeds, and 50+ SEO best practices built into every generated page.
  • Themeable and accessible -- built-in themes with dark mode, WCAG AA contrast, print stylesheets, and full keyboard navigation.

#Get started

Ready to try it? Head over to the Getting Started guide for installation, project initialization, and your first documentation build. The guide walks you through creating a selfdoc.json, writing your first template with directives, and previewing the output locally with live reload.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • rlsbl Release orchestration and project scaffolding CLI that bumps versions, validates a structured JSONL changelog, tags only the commit CI verified, and publishes to npm, PyPI, Go and more
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search