libspec-diataxis
Diátaxis-shaped documentation base classes for libspec feature hierarchies.
Inherit Diataxis into any libspec.Feature subclass and every feature in your
project is required to articulate itself across all four Diátaxis quadrants —
Tutorial, How-to Guide, Reference, and Explanation — before a
spec can be generated.
Installation
uv add libspec-diataxis
or
pip install libspec-diataxis
Quick Start
from libspec.diataxis import Diataxis
# Your project's domain base class
class UIFeature(Diataxis): ...
# A fully-documented feature
class AwesomeNavBar(UIFeature):
def date(self):
return "2026-08-11"
def description(self):
return "Accessible, animated navigation bar with keyboard support."
def tutorial(self):
return (
"In this tutorial we will build a minimal nav bar from scratch. "
"We will add three links, watch the highlight move between them, "
"and verify that the keyboard shortcut activates each item."
)
def how_to(self):
return (
"To highlight the active route, pass `active_index=<int>` to "
"AwesomeNavBar(). To add keyboard support, ensure the parent "
"element has `tabindex=0` and attach the provided `on_keydown` handler."
)
def reference(self):
return (
"AwesomeNavBar(items: list[str], active_index: int = 0,\n"
" on_change: Callable[[int], None] | None = None)\n"
" items — ordered list of label strings\n"
" active_index — zero-based index of the selected item\n"
" on_change — optional callback invoked on selection change"
)
def explanation(self):
return (
"The nav bar uses a slot-based model so items remain decoupled from "
"routing logic. Active state is passed in, making the component "
"purely presentational and trivially testable."
)
The Four Quadrants
Diátaxis (diataxis.fr) organises documentation around two orthogonal dimensions of craft — action ↔ cognition × acquisition ↔ application — yielding four necessary and sufficient quadrants:
| Acquisition (study) | Application (work) | |
|---|---|---|
| Action (practical) | Tutorial | How-to Guide |
| Cognition (theory) | Explanation | Reference |
Each quadrant maps to a required method on Diataxis:
| Method | Quadrant | Purpose |
|---|---|---|
tutorial() |
action×study | Learning-oriented narrative; leads the learner by hand |
how_to() |
action×work | Goal-oriented directions for the already-competent user |
reference() |
cognition×work | Neutral, complete, authoritative description |
explanation() |
cognition×study | Context, background, the reasoning behind decisions |
All four methods are mandatory. Omitting any one raises
libspec.UnimplementedMethodError at spec-generation time.
How It Works
Diataxis subclasses libspec.Feature, which subclasses libspec.Ctx. The
Ctx machinery collects zero-argument methods as template variables and injects
them into the class docstring (a Jinja2 template). libspec.Spec then renders
and serialises the result to XML or Component dataclasses.
The class docstring template:
Feature Specification: {{feature_name}}
{{description}}
## Tutorial
{{tutorial}}
## How-to Guide
{{how_to}}
## Reference
{{reference}}
## Explanation
{{explanation}}
Namespace Extension
libspec-diataxis ships a .pth + startup hook that appends src/libspec/ to
libspec.__path__ at interpreter startup, enabling from libspec.diataxis import Diataxis even though libspec is a regular (non-namespace) package. No
modifications to libspec are required.
License
Apache 2.0. See LICENSE.
Diátaxis is the work of Daniele Procida. See diataxis.fr.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libspec_diataxis-0.1.0.tar.gz.
File metadata
- Download URL: libspec_diataxis-0.1.0.tar.gz
- Upload date:
- Size: 44.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6a75a0b9cb05cd7c07f3373a1421ed0f02c033c185748d151679d3e6b599288
|
|
| MD5 |
03b92c17dc7d1cab4241a3ec523aaa2c
|
|
| BLAKE2b-256 |
6f417a58eab7e6ec47fcc6d3dc979f1a4271de3fa72343616d318b0aa61e5ef2
|
File details
Details for the file libspec_diataxis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: libspec_diataxis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71a8ad991b25312a5a41e5eaeff8c7cc9038e32e284e3a7340efa5dd3f1d02b4
|
|
| MD5 |
38dc702d9b50d4e0b25265104400dde2
|
|
| BLAKE2b-256 |
c79b3ed10f5e6968d85f030b2aafad8d4c8f77db094b57d432f0519c71167a1e
|