What is TUT?

TUT is a data-driven documentation generator that converts JSON definitions into HTML documentation. It supports two document types: guides (step-by-step tutorials) and reference docs (scrollable topic-based documentation).

Guide

Step-by-step interactive tutorials with terminal simulation

Reference

Scrollable topic-based docs with sidebar navigation

Quick Start

Get started generating documentation in seconds.

# List available sources
tut get sources

# Build a document
tut build my-ref

# Generate landing page
tut index

# Preview in browser
tut serve

Environment

TUT uses two environment variables for paths.

Variable Purpose Example
TUT_SRC Source files (JSON, templates) $TETRA_SRC/bash/tut
TUT_DIR Output directory $TETRA_DIR/tut

Run tut doctor to verify your environment is configured correctly.

tut build

Build documentation from JSON source files.

tut build [--type guide|reference] [--no-bump] [--all]

Builds HTML documentation from a JSON source file. Type is auto-detected from JSON structure.

Parameters
name string
Source name (without .json extension)
--type string
Force document type (guide or reference)
--no-bump flag
Skip version bump prompt
--all flag
Build all sources in available/
Returns

file - Generated HTML in $TUT_DIR/generated/

Example
tut build nh-ref --no-bump

tut init

Create a new document from template.

tut init [--type guide|reference]

Creates a new JSON template in the available/ directory.

Parameters
name string
Document name (becomes filename)
--type string
Document type (default: reference)
Example
tut init my-project-ref --type reference

tut serve

Start a local server and preview documentation.

tut serve [file] [--port N] [--stop] [--status]

Starts an HTTP server via TSM and opens the browser. Uses the tut service for process management.

Parameters
file string
Specific file to open in browser
--port number
Server port (default: auto-assigned)
--stop flag
Stop the server
--status flag
Show server status
Example
tut serve tut-reference.html

tut index

Generate a landing page for all documents.

tut index

Scans $TUT_DIR/generated/ for HTML files and creates an index.html landing page with cards linking to each document.

Example
tut index

The index page extracts metadata (title, version, type) from each document's meta tags and displays them in a card grid.

tut get

Query sources and generated documents.

Other Commands

paragraph

Simple text block.

{
  "type": "paragraph",
  "text": "Your text content here."
}

command-list

List of commands with descriptions. Ideal for CLI reference.

{
  "type": "command-list",
  "commands": [
    { "code": "cmd arg", "description": "What it does" },
    { "code": "cmd --flag", "description": "Another command" }
  ]
}

Renders as:

code-block

Fenced code with optional language. Click-to-copy is automatic.

{
  "type": "code-block",
  "language": "bash",
  "code": "echo 'Hello World'"
}

module-grid

Grid of cards for displaying modules, features, or options.

{
  "type": "module-grid",
  "modules": [
    { "name": "Module A", "description": "Does X" },
    { "name": "Module B", "description": "Does Y" }
  ]
}

Renders as:

Module A

Does X

Module B

Does Y

list

Ordered or unordered list.

{
  "type": "list",
  "ordered": false,
  "items": ["First item", "Second item", "Third item"]
}

table

Data table with headers and rows.

{
  "type": "table",
  "headers": ["Name", "Type", "Description"],
  "rows": [
    ["id", "string", "Unique identifier"],
    ["title", "string", "Display title"]
  ]
}

Renders as:

Name Type Description
id string Unique identifier
title string Display title

api-endpoint

REST API endpoint documentation with method, path, parameters, and responses.

POST /api/users

Create a new user account

Parameters
NameTypeRequiredDescription
emailstringrequiredUser email address
namestringrequiredDisplay name
Request Body
{
  "email": "user@example.com",
  "name": "John Doe"
}
Responses
201 User created successfully
400 Invalid request body

api-function

Function/method documentation with signature, parameters, returns, and example.

_tut_build [--type] [--no-bump]

Internal function that builds a single document.

Parameters
name string
Source file name
--type string
Force guide or reference
--no-bump flag
Skip version prompt
Returns

file - HTML file in generated/

Example
_tut_build nh-ref --no-bump

Reference Structure

Reference documents are organized into groups containing topics.

{
  "metadata": {
    "title": "My Docs",
    "tagline": "Optional subtitle",
    "version": "1.0.0"
  },
  "groups": [
    {
      "id": "getting-started",
      "title": "Getting Started",
      "topics": [
        {
          "id": "install",
          "title": "Installation",
          "description": "How to install...",
          "content": [ ... ]
        }
      ]
    }
  ]
}

Guide Structure

Guides are linear step-by-step tutorials with terminal simulation.

{
  "metadata": {
    "title": "My Guide",
    "difficulty": "beginner",
    "estimatedTime": 15
  },
  "steps": [
    {
      "id": "step-1",
      "title": "Step 1",
      "content": [ ... ],
      "terminal": [
        { "type": "prompt", "content": "$ " },
        { "type": "command", "content": "echo hello" },
        { "type": "output", "content": "hello" }
      ]
    }
  ]
}

File Organization

Path Purpose
$TUT_SRC/tut.sh Main CLI entry point
$TUT_SRC/includes.sh Module loader
$TUT_SRC/tut_reference.sh Reference doc renderer
$TUT_SRC/tut_complete.sh Tab completion
$TUT_SRC/core/output.sh Output helpers (colors, formatting)
$TUT_SRC/core/validators.sh JSON validation
$TUT_SRC/renderers/html.sh Guide HTML renderer
$TUT_SRC/templates/ HTML/CSS/JS templates
$TUT_SRC/available/ Source JSON files
$TUT_DIR/generated/ Output HTML files

Design Tokens

TUT uses CSS custom properties for theming. Access the design token editor by adding ?design=true to any document URL.

Token Default Purpose
--bg-primary #1a1a2e Page background
--bg-secondary #16213e Sections, sidebar
--bg-tertiary #0d1b2a Code blocks, cards
--text-title #eaeaea Titles, headings
--text-primary #c0c0d0 Body text
--text-secondary #8a8aa0 Muted text
--text-code #ff6b6b Code block text
--accent-primary #e94560 Links, highlights
--border #2a2a4a Borders, dividers

Design Token Editor

The FAB (Floating Action Button) provides real-time theme editing.

Themes are saved to localStorage and persist across sessions.

Google Fonts

Add custom fonts by pasting the Google Fonts embed code.

  1. Go to fonts.google.com and select fonts
  2. Click 'Get embed code'
  3. Paste the full embed code into the font input
  4. Multi-font suites are supported
  5. Mono fonts auto-assign to Code, sans fonts to Heading/Body
Design Tokens ×
Theme Switcher
Theme Metadata
Colors
Background
--bg-primary
#1a1a2e
--bg-secondary
#16213e
--bg-tertiary
#0d1b2a
Text
--text-title
#eaeaea
--text-primary
#c0c0d0
--text-secondary
#8a8aa0
--text-code
#ff6b6b
Accent
--accent-primary
#e94560
--accent-secondary
#3b82c4
Status
--success
#3fb950
--warning
#d29922
--error
#f85149
Border
--border
#2a2a4a
Layout
Section Style
Sharp 8px Round