Skip to main content

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.

Metadata

Release files for libspec-diataxis 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libspec-diataxis 0.1.0
File Size Uploaded
libspec_diataxis-0.1.0.tar.gz 44.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libspec-diataxis 0.1.0
File Interpreter ABI Platform
libspec_diataxis-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 49.2 kB

Release files / libspec_diataxis-0.1.0.tar.gz

Download URL libspec_diataxis-0.1.0.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d6a75a0b9cb05cd7c07f3373a1421ed0f02c033c185748d151679d3e6b599288
BLAKE2b-256 checksum
How to use checksums
6f417a58eab7e6ec47fcc6d3dc979f1a4271de3fa72343616d318b0aa61e5ef2
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / libspec_diataxis-0.1.0-py3-none-any.whl

Download URL libspec_diataxis-0.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71a8ad991b25312a5a41e5eaeff8c7cc9038e32e284e3a7340efa5dd3f1d02b4
BLAKE2b-256 checksum
How to use checksums
c79b3ed10f5e6968d85f030b2aafad8d4c8f77db094b57d432f0519c71167a1e
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page