docspire
v0.0.10
Published
Focus on your product, not its docs
Readme
Docspire
Think about your product, not its docs. A hands-off documentation generator, based on 11ty.
[!NOTE] This is heavily experimental and not currently licensed. Move along, nothing to see here yet.
Features
Everything below works out of the box and is configurable.
- Navigation: sidebar, page contents, heading anchors, breadcrumbs, next/previous page
- Search: ⌘K palette over an index built from your content, no service required
- Syntax highlighting and copyable code snippets
- Callouts
- Edit on GitHub link, last updated date
- Light/dark color scheme
Opt-in plugins: landing (landing page layout), code-demo (live code demos).
Usage
npm install docspire -D
npx docspire --serveCo-locating docs with source
Docs don't have to live in docs/. The import option publishes files from anywhere in the repo,
which lets each component, package, or plugin keep its documentation next to its code, as a
README.md that also renders on GitHub:
// docspire.config.js
export default {
import: "elements/:name/README.md",
};Each entry says treat this path as if it were that one. Both sides are file paths: the key is
relative to the project root, the value relative to your input directory. :name and friends are
named placeholders that carry across; use the same name twice and both have to match the same text.
Written out in full, the example above is:
import: {
"elements/:name/README.md": "elements/:name/README.md",
},— and since that is the common case, the value can be left off entirely, as in the first form.
An imported file behaves exactly as if you had written it at that path in the first place. So
elements/button-group/README.md publishes at /elements/button-group/, because that is where a
README.md publishes; permalink in its front matter still wins if you set one. Point it somewhere
else by naming the path you want:
import: {
"CHANGELOG.md": "changelog.md", // -> /changelog/
"packages/:pkg/README.md": "api/:pkg.md", // -> /api/<pkg>/
},Imported pages are not second-class: "Edit this page" points at the real file on GitHub, and the last updated date comes from its actual git history.
Renaming Docspire's directories
Docspire reads components/ at the project root as the site's components. A site that registers
itself as a plugin (plugins: [{ url: import.meta.url }]) also has its root templates/ and
assets/ read.
When one of these names already means something else in your project, rename Docspire's.
For example, a component library has a components/ of its own, which is not Docspire's:
// docspire.config.js
export default {
dirNames: { components: "docspire-components" },
};Docspire now reads the site's components from docspire-components/ and leaves components/ alone.
The keys are components, templates and assets. Names you leave out keep their defaults.
Plugins keep their own directory names.
A component's sub-components stay in its own components/ folder, e.g.
docspire-components/my-card/components/my-card-title/.
To serve the library's files, copy them as you would any other file, e.g. with
config.addPassthroughCopy() in a plugin.
