cookcli 0.36.0

A command-line interface for managing and working with Cooklang recipes
Documentation
{% extends "base.html" %}

{% block title %}Server API - Cook{% endblock %}

{% block content %}
<div class="max-w-5xl">
    <h1 class="text-display font-bold text-text mb-2">Server API</h1>
    <p class="text-muted mb-6">
        {{ preamble.intro }}
    </p>

    <!-- Ground rules -->
    <div class="card p-6 border-l-[3px] border-l-accent mb-8">
        <h2 class="text-title font-semibold mb-3 text-text">Before you start</h2>
        <div class="text-sm space-y-2 text-text">
            <div>
                <span class="font-medium">Base URL:</span>
                <code class="ml-2 px-2 py-0.5 rounded bg-sunk font-mono">{{ base_url }}</code>
            </div>
            {% for n in preamble.notes %}
            <div>
                <span class="font-medium">{{ n.label }}:</span>
                <span class="ml-2">{{ n.text|inline_code|safe }}</span>
            </div>
            {% endfor %}
        </div>
    </div>

    <!-- Errors -->
    <div class="card p-6 mb-8">
        <h2 class="text-title font-semibold mb-3 text-text">Errors</h2>
        <p class="text-sm text-text mb-3">
            {{ preamble.error_intro }}
        </p>
        <pre class="bg-sunk border border-line rounded-[var(--radius-control)] p-3 text-xs overflow-x-auto font-mono">{{ preamble.error_example }}</pre>
        <ul class="mt-3 text-sm space-y-1 text-text">
            {% for c in preamble.error_codes %}
            <li><span class="font-mono font-medium">{{ c.label }}</span> — {{ c.text|inline_code|safe }}</li>
            {% endfor %}
        </ul>
    </div>

    <!-- Contents -->
    <div class="card p-6 mb-8">
        <h2 class="text-title font-semibold mb-3 text-text">Contents</h2>
        <div class="flex flex-wrap gap-2">
            {% for section in sections %}
            <a href="#{{ section.id }}" class="btn btn-sm">
                {{ section.title }}
            </a>
            {% endfor %}
        </div>
    </div>

    <!-- Endpoints -->
    {% for section in sections %}
    <section id="{{ section.id }}" class="mb-10 scroll-mt-24">
        <h2 class="text-title font-bold mb-2 text-text">{{ section.title }}</h2>
        <p class="text-sm text-muted mb-4">{{ section.description|inline_code|safe }}</p>

        <div class="space-y-4">
            {% for endpoint in section.endpoints %}
            <article class="card p-5">
                <div class="flex flex-wrap items-center gap-2 mb-2">
                    <span class="px-2 py-0.5 rounded text-xs font-bold font-mono {{ endpoint.method_classes() }}">{{ endpoint.method }}</span>
                    <code class="font-mono text-sm break-all">{{ endpoint.path }}</code>
                    {% if let Some(feature) = endpoint.feature %}
                    <span class="px-2 py-0.5 rounded text-xs font-medium bg-accent-soft text-accent-text">
                        requires <span class="font-mono">{{ feature }}</span> build
                    </span>
                    {% endif %}
                </div>

                <h3 class="text-sm font-medium mb-1">{{ endpoint.summary|inline_code|safe }}</h3>
                {% if !endpoint.description.is_empty() %}
                <p class="text-sm text-muted">{{ endpoint.description|inline_code|safe }}</p>
                {% endif %}

                {% if !endpoint.params.is_empty() %}
                <div class="mt-4 overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead>
                            <tr class="text-left text-xs uppercase tracking-wide text-faint border-b border-line">
                                <th class="py-1.5 pr-4 font-medium">Name</th>
                                <th class="py-1.5 pr-4 font-medium">In</th>
                                <th class="py-1.5 pr-4 font-medium">Type</th>
                                <th class="py-1.5 font-medium">Description</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for p in endpoint.params %}
                            <tr class="border-b border-line align-top">
                                <td class="py-1.5 pr-4 font-mono whitespace-nowrap">
                                    {{ p.name }}{% if p.required %}<span class="text-danger" title="required">*</span>{% endif %}
                                </td>
                                <td class="py-1.5 pr-4 text-faint">{{ p.kind }}</td>
                                <td class="py-1.5 pr-4 font-mono text-faint whitespace-nowrap">{{ p.type_name }}</td>
                                <td class="py-1.5 text-muted">{{ p.description|inline_code|safe }}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <p class="mt-1 text-xs text-faint">
                        <span class="text-danger">*</span> required
                    </p>
                </div>
                {% endif %}

                {% if let Some(request) = endpoint.request_example %}
                <div class="mt-4">
                    <h4 class="text-xs uppercase tracking-wide text-faint mb-1">Request body</h4>
                    <pre class="bg-sunk border border-line rounded-[var(--radius-control)] p-3 text-xs overflow-x-auto font-mono">{{ request }}</pre>
                </div>
                {% endif %}

                {% if let Some(response) = endpoint.response_example %}
                <div class="mt-4">
                    <h4 class="text-xs uppercase tracking-wide text-faint mb-1">Response</h4>
                    <pre class="bg-sunk border border-line rounded-[var(--radius-control)] p-3 text-xs overflow-x-auto font-mono">{{ response }}</pre>
                </div>
                {% endif %}
            </article>
            {% endfor %}
        </div>
    </section>
    {% endfor %}
</div>
{% endblock %}