Skip to content
Myr

manual.html.j2

This file

Path

docs/templates/manual.html.j2

121 lines · 6.0 KiB

Last changed by

Update jq documentation for jq 1.8.0 release (#3333)itchynybefore adoption62cafa2

History of this file

Take it

1<!DOCTYPE html>2<html lang="en">3{% include "shared/_head.html.j2" %}45  <body>6{% include "shared/_navbar.html.j2" %}78    <div class="container-lg row align-items-start mx-auto p-3">910      <button type="button" class="d-md-none w-auto position-fixed bottom-0 end-0 p-2 m-3 bg-body-secondary border-0 text-body d-print-none"11        data-bs-toggle="offcanvas" data-bs-target="#contents" aria-controls="contents" aria-expanded="false" aria-label="Toggle table of contents">12        <span class="bi bi-list" aria-hidden="true"></span>13      </button>14      <nav id="contents" class="col-md-3 sticky-md-top p-3 overflow-y-auto offcanvas-md offcanvas-end d-print-none" style="top:4.5rem; height:calc(100dvh - 5.5rem);" aria-label="Table of contents">15        <div class="d-flex justify-content-between">16          <h4>Contents</h4>17          <button type="button" class="btn-close d-md-none" data-bs-dismiss="offcanvas" data-bs-target="#contents" aria-label="Close table of contents"></button>18        </div>19        <ul class="offcanvas-md-body nav nav-pills flex-column">20          {%- for section in sections %}21          <li class="nav-item" data-bs-dismiss="offcanvas" data-bs-target="#contents">22            <a class="nav-link" href="#{{ section.title | section_id }}">{{ section.title }}</a>23          </li>24          {%- endfor %}25        </ul>26      </nav>27      {%- set section_ids = {} %}28      {%- macro check_section_id(id) -%}29        {%- if section_ids.__contains__(id) %}30          {{- raise('Duplicate section id: ' ~ id) }}31        {%- endif %}32        {%- set _ = section_ids.__setitem__(id, true) %}33      {%- endmacro %}34      <main id="main" class="col-md-9" data-bs-spy="scroll" data-bs-target="#contents" data-bs-threshold="0,1" data-bs-root-margin="-30% 0% -70%">35        <h1>{{ headline }}</h1>36        <p>37          <em>38            For other versions, see39            <a href="/manual/v1.8/">1.8</a>,40            <a href="/manual/v1.7/">1.7</a>,41            <a href="/manual/v1.6/">1.6</a>,42            <a href="/manual/v1.5/">1.5</a>,43            <a href="/manual/v1.4/">1.4</a>,44            <a href="/manual/v1.3/">1.3</a> or45            <a href="/manual/dev/">development version</a>.46          </em>47        </p>48        {{ body | markdownify }}49        {%- for section in sections %}50        <section id="{{ section.title | section_id }}">{{ check_section_id(section.title | section_id) }}51          <h2>{{ section.title }} <a href="#{{ section.title | section_id }}" class="icon-link" aria-label="Link to this section: {{ section.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a></h2>52          {{ section.body | markdownify if section.body }}53          {%- for entry in section.entries %}54          <section id="{{ entry.title | entry_id }}">{{ check_section_id(entry.title | entry_id) }}55            <h3>56              {{ entry.title | markdownify | no_paragraph }}57              <a href="#{{ entry.title | entry_id }}" class="icon-link" aria-label="Link to this section: {{ entry.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a>58            </h3>59            {{ entry.body | markdownify }}60            {%- if entry.examples %}61            <div class="pb-3">62              {%- set exampleID = unique_id() %}63              <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-transparent link-body-emphasis border-0" data-bs-toggle="collapse" data-bs-target="#example{{ exampleID }}" aria-expanded="false" aria-controls="example{{ exampleID }}">64                <span class="me-1 d-print-none" aria-hidden="true"><span class="bi bi-chevron-right"></span><span class="bi bi-chevron-down"></span></span>Example{% if entry.examples | length > 1 %}s{% endif %}65              </button>66              <div id="example{{ exampleID }}" class="collapse mx-3 small d-print-block">67                {%- for example in entry.examples %}68                <table class="table table-borderless table-sm w-auto">69                  <tr>70                    <th class="pe-3">Command</th>71                    <td class="font-monospace">jq '{{ example.program }}'</td>72                  </tr>73                  <tr>74                    <th>Input</th>75                    <td class="font-monospace">{{ example.input }}</td>76                  </tr>77                  {%- if not example.output[0] %}78                  <tr>79                    <th>Output</th>80                    <td class="fst-italic">none</td>81                  </tr>82                  {%- endif %}83                  {%- for output in example.output %}84                  <tr>85                    <th>{% if loop.first %}Output{% endif %}</th>86                    <td class="font-monospace">{{ output }}</td>87                  </tr>88                  {%- endfor %}89                  <tr class="d-print-none">90                    <th><a href="https://play.jqlang.org/?q={{ example.program | urlencode }}&j={{ example.input | urlencode }}" class="btn btn-outline-primary btn-sm" target="_blank" rel="noopener">Run<span class="bi bi-box-arrow-up-right ms-2" aria-hidden="true"></span></a></th>91                    <td></td>92                  </tr>93                </table>94                {%- endfor %}95              </div>96            </div>97            {%- endif %}98          </section>99          {%- endfor %}100        </section>101        {%- endfor %}102      </main>103104    </div>105106{% include "shared/_footer.html.j2" %}107    <script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"108      integrity="sha384-xbzjoN6H5XHmAqoSSR42hZVRninPGx85y+XZQGlWxVu2y91lTmr/oD80i5cjeUBv" crossorigin="anonymous"></script>109    <script id="section-ids" type="application/json">110      {111        {%- for section in sections %}112        {%- for entry in section.entries %}113        {{ entry.title | search_id | tojson }}: {{ entry.title | entry_id | tojson }},114        {%- endfor %}115        {{ section.title | search_id | tojson }}: {{ section.title | section_id | tojson }}{{ "," if not loop.last }}116        {%- endfor %}117      }118    </script>119    <script src="/js/manual-search.js"></script>120  </body>121</html>