{# The API console page. `base_template` is a variable rather than a literal: the kit's shell by default, or the app's own `base.html` when `ApiDocsPlugin(base_template=…)` names it, so the docs sit inside the app's chrome without this file knowing anything about it. The layout is the shell's sidebar version, which the shell picks because the `sidebar` block below is not empty. #} {% extends base_template %} {% from "ui/button.html" import button %} {% from "ui/data.html" import caption, card, empty_state, item, item_list, link %} {% from "ui/form.html" import text_field %} {% from "ui/layout.html" import page_header, row, section, stack %} {% from "ui/nav.html" import brand %} {% from "ui/sidebar.html" import sidebar %} {% block title %}{{ operation.label if operation else (model.name if model else "API") }}{% endblock %} {% block site_title %}{{ docs_title }}{% endblock %} {# The sidebar keeps `--sidebar-width` as it comes. This page is one of several a host app serves, and a docs route that widened the chrome would make the sidebar jump on every navigation in or out of it. An app that wants a wider one sets the token once for every page it owns, and this page inherits it like the others — which is what the token is for. #} {% block sidebar %} {%- set mark %} {{ brand(docs_title, url_for(request, routes.index), icon_name="braces") }} {# The filter. Swagger has one for the same reason: an app with two hundred routes has a sidebar nobody scrolls, and the tag headings only help someone who already knows the tag. It filters on the server and swaps the list, costing one round trip per pause in typing and buying a list that is genuinely shorter — the client-side version ships all two hundred rows and hides most of them. `delay:250ms` makes it one request per pause rather than one per keystroke. The input sits outside the swapped region, so the text typed and the caret position both survive the swap. A `name` and a real URL, so this is also a GET anybody can bookmark: the page route reads the same `?q=`. No visible label: the placeholder says what it is and the sidebar has no room for a second line. `aria-label` names it for a screen reader. #} {{ text_field(query_field, value=query, type="search", placeholder="Filter operations", aria_label="Filter operations", hx_get=url_for(request, routes.nav), hx_trigger="input changed delay:250ms, search", hx_target="#" ~ ids.nav, hx_swap="outerHTML") }} {%- endset %} {# The way back out. The operation list has taken the sidebar, so without this the docs have no exit — the usual complaint about a `/docs` page bookmarked out of context. #} {%- set exit %} {% if home_url %}{{ button(home_label, variant="ghost", size="sm", href=home_url, icon_name="arrow-left") }}{% endif %} {%- endset %} {% call sidebar(header=mark, footer=exit if home_url else none, label="Operations") %} {% include "apidocs/_nav.html" %} {% endcall %} {% endblock %} {% block content %} {% call stack(gap=6) %} {# The session panel sits above the operation and stays put when one is swapped in. The page is arranged around the question Swagger cannot answer: "who am I right now". #} {% include "apidocs/_session.html" %} {% if operation %} {% include "apidocs/_operation.html" %} {% elif model %} {% include "apidocs/_model.html" %} {% else %} {# The landing state. It carries the detail panel's id so the first click on an operation has something to swap, exactly as the operation partial would. #}