mirror of https://github.com/docker/docs.git
Stash computed data in a Liquid variable (#10462)
* Stash computed data in a variable To avoid computing `site.data[include.datafolder][include.datafile]` multiple times for the same context. * Revert change to hard-tab whitespace
This commit is contained in:
parent
6d1e28ad5b
commit
02d087c63a
|
@ -2,25 +2,27 @@
|
|||
{% capture dockerBaseDesc %}The base command for the Docker CLI.{% endcapture %}
|
||||
{% if include.datafolder and include.datafile %}
|
||||
|
||||
{% assign controller_data = site.data[include.datafolder][include.datafile] %}
|
||||
|
||||
## Description
|
||||
|
||||
{% if include.datafile=="docker" %}<!-- docker.yaml is textless, so override -->
|
||||
{{ dockerBaseDesc }}
|
||||
{% else %}
|
||||
{{ site.data[include.datafolder][include.datafile].short }}
|
||||
{{ controller_data.short }}
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].min_api_version %}
|
||||
{% if controller_data.min_api_version %}
|
||||
|
||||
<a href="/engine/api/v{{ site.data[include.datafolder][include.datafile].min_api_version }}/" target="_blank" class="_"><span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="Open the {{ site.data[include.datafolder][include.datafile].min_api_version }} API reference (in a new window)">API {{ site.data[include.datafolder][include.datafile].min_api_version }}+</span></a>
|
||||
<a href="/engine/api/v{{ controller_data.min_api_version }}/" target="_blank" class="_"><span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="Open the {{ controller_data.min_api_version }} API reference (in a new window)">API {{ controller_data.min_api_version }}+</span></a>
|
||||
The client and daemon API must both be at least
|
||||
<a href="/engine/api/v{{ site.data[include.datafolder][include.datafile].min_api_version }}/" target="_blank" class="_">{{ site.data[include.datafolder][include.datafile].min_api_version }}</a>
|
||||
<a href="/engine/api/v{{ controller_data.min_api_version }}/" target="_blank" class="_">{{ controller_data.min_api_version }}</a>
|
||||
to use this command. Use the `docker version` command on the client to check
|
||||
your client and daemon API versions.
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].deprecated %}
|
||||
{% if controller_data.deprecated %}
|
||||
|
||||
> This command is [deprecated](/engine/deprecated.md){: target="_blank" class="_"}.
|
||||
>
|
||||
|
@ -38,7 +40,7 @@ your client and daemon API versions.
|
|||
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].experimental %}
|
||||
{% if controller_data.experimental %}
|
||||
|
||||
> This command is experimental.
|
||||
>
|
||||
|
@ -52,7 +54,7 @@ your client and daemon API versions.
|
|||
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].experimentalcli %}
|
||||
{% if controller_data.experimentalcli %}
|
||||
|
||||
> This command is experimental on the Docker client.
|
||||
>
|
||||
|
@ -67,12 +69,12 @@ your client and daemon API versions.
|
|||
{% endif %}
|
||||
|
||||
{% capture command-orchestrator %}
|
||||
{% if site.data[include.datafolder][include.datafile].swarm %}
|
||||
{% if controller_data.swarm %}
|
||||
|
||||
<span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="This command works with the Swarm orchestrator.">Swarm</span> This command works with the Swarm orchestrator.
|
||||
|
||||
{% endif %}
|
||||
{% if site.data[include.datafolder][include.datafile].kubernetes %}
|
||||
{% if controller_data.kubernetes %}
|
||||
|
||||
<span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="This command works with the Kubernetes orchestrator.">Kubernetes</span> This command works with the Kubernetes orchestrator.
|
||||
|
||||
|
@ -80,32 +82,32 @@ your client and daemon API versions.
|
|||
{% endcapture %}{{ command-orchestrator }}
|
||||
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].usage %}
|
||||
{% if controller_data.usage %}
|
||||
|
||||
## Usage
|
||||
|
||||
```none
|
||||
{{ site.data[include.datafolder][include.datafile].usage | replace: tabChar,"" | strip }}{% if site.data[include.datafolder][include.datafile].cname %} COMMAND{% endif %}
|
||||
{{ controller_data.usage | replace: tabChar,"" | strip }}{% if controller_data.cname %} COMMAND{% endif %}
|
||||
```
|
||||
|
||||
{% endif %}
|
||||
{% unless site.data[include.datafolder][include.datafile].long == site.data[include.datafolder][include.datafile].short %}
|
||||
{% unless controller_data.long == controller_data.short %}
|
||||
|
||||
## Extended description
|
||||
|
||||
{{ site.data[include.datafolder][include.datafile].long }}
|
||||
{{ controller_data.long }}
|
||||
|
||||
{% endunless %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].examples %}
|
||||
{% if controller_data.examples %}
|
||||
For example uses of this command, refer to the [examples section](#examples) below.
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].options %}
|
||||
{% if site.data[include.datafolder][include.datafile].inherited_options %}
|
||||
{% assign alloptions = site.data[include.datafolder][include.datafile].options | concat:site.data[include.datafolder][include.datafile].inherited_options %}
|
||||
{% if controller_data.options %}
|
||||
{% if controller_data.inherited_options %}
|
||||
{% assign alloptions = controller_data.options | concat:controller_data.inherited_options %}
|
||||
{% else %}
|
||||
{% assign alloptions = site.data[include.datafolder][include.datafile].options %}
|
||||
{% assign alloptions = controller_data.options %}
|
||||
{% endif %}
|
||||
## Options
|
||||
|
||||
|
@ -123,7 +125,7 @@ For example uses of this command, refer to the [examples section](#examples) bel
|
|||
{% capture deprecated-badge %}{% if option.deprecated %}<a href="/engine/deprecated.md" target="_blank" class="_"><span class="badge badge-danger" data-toggle="tooltip" title="Read the deprecation reference (in a new window).">deprecated</span></a>{% endif %}{% endcapture %}
|
||||
{% capture experimental-daemon-badge %}{% if option.experimental %}<a href="/engine/reference/commandline/dockerd.md#daemon-configuration-file" target="_blank" class="_"><span class="badge badge-warning" data-toggle="tooltip" title="Read about experimental daemon options (in a new window).">experimental (daemon)</span></a>{% endif %}{% endcapture %}
|
||||
{% capture experimental-cli-badge %}{% if option.experimentalcli %}<a href="/engine/reference/commandline/cli.md#configuration-files" target="_blank" class="_"><span class="badge badge-warning" data-toggle="tooltip" title="Read about experimental CLI options (in a new window).">experimental (CLI)</span></a>{% endif %}{% endcapture %}
|
||||
{% capture min-api %}{% if option.min_api_version %}<a href="/engine/api/v{{ option.min_api_version }}/" target="_blank" class="_"><span class="badge badge-info" data-toggle="tooltip" ttitle="Open the {{ site.data[include.datafolder][include.datafile].min_api_version }} API reference (in a new window)">API {{ option.min_api_version }}+</span></a>{% endif %}{%endcapture%}
|
||||
{% capture min-api %}{% if option.min_api_version %}<a href="/engine/api/v{{ option.min_api_version }}/" target="_blank" class="_"><span class="badge badge-info" data-toggle="tooltip" ttitle="Open the {{ controller_data.min_api_version }} API reference (in a new window)">API {{ option.min_api_version }}+</span></a>{% endif %}{%endcapture%}
|
||||
{% capture flag-orchestrator %}{% if option.swarm %}<span class="badge badge-info" data-toggle="tooltip" title="This option works for the Swarm orchestrator.">Swarm</span>{% endif %}{% if option.kubernetes %}<span class="badge badge-info" data-toggle="tooltip" title="This option works for the Kubernetes orchestrator.">Kubernetes</span>{% endif %}{% endcapture %}
|
||||
|
||||
{% capture all-badges %}{{ deprecated-badge }}{{ experimental-daemon-badge }}{{ experimental-cli-badge }}{{ min-api }}{{ flag-orchestrator }}{% endcapture %}
|
||||
|
@ -142,11 +144,11 @@ For example uses of this command, refer to the [examples section](#examples) bel
|
|||
|
||||
{% endif %} <!-- end if options -->
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].examples %}
|
||||
{% if controller_data.examples %}
|
||||
|
||||
## Examples
|
||||
|
||||
{{ site.data[include.datafolder][include.datafile].examples }}
|
||||
{{ controller_data.examples }}
|
||||
|
||||
{% endif %}
|
||||
{% else %}
|
||||
|
@ -155,15 +157,15 @@ The include.datafolder or include.datafile was not set.
|
|||
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].pname %}
|
||||
{% unless site.data[include.datafolder][include.datafile].pname == include.datafile %}
|
||||
{% if controller_data.pname %}
|
||||
{% unless controller_data.pname == include.datafile %}
|
||||
|
||||
## Parent command
|
||||
|
||||
{% capture parentfile %}{{ site.data[include.datafolder][include.datafile].plink | replace: ".yaml", "" | replace: "docker_","" }}{% endcapture %}
|
||||
{% capture parentdatafile %}{{ site.data[include.datafolder][include.datafile].plink | replace: ".yaml", "" }}{% endcapture %}
|
||||
{% capture parentfile %}{{ controller_data.plink | replace: ".yaml", "" | replace: "docker_","" }}{% endcapture %}
|
||||
{% capture parentdatafile %}{{ controller_data.plink | replace: ".yaml", "" }}{% endcapture %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].pname == "docker" %}
|
||||
{% if controller_data.pname == "docker" %}
|
||||
{% capture parentDesc %}{{ dockerBaseDesc }}{% endcapture %}
|
||||
{% else %}
|
||||
{% capture parentDesc %}{{ site.data[include.datafolder][parentdatafile].short }}{% endcapture %}
|
||||
|
@ -171,12 +173,12 @@ The include.datafolder or include.datafile was not set.
|
|||
|
||||
| Command | Description |
|
||||
| ------- | ----------- |
|
||||
| [{{ site.data[include.datafolder][include.datafile].pname }}]({{ parentfile }}) | {{ parentDesc }}|
|
||||
| [{{ controller_data.pname }}]({{ parentfile }}) | {{ parentDesc }}|
|
||||
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
|
||||
{% if site.data[include.datafolder][include.datafile].cname %}
|
||||
{% if controller_data.cname %}
|
||||
|
||||
## Child commands
|
||||
|
||||
|
@ -188,7 +190,7 @@ The include.datafolder or include.datafile was not set.
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for command in site.data[include.datafolder][include.datafile].cname %}
|
||||
{% for command in controller_data.cname %}
|
||||
{% capture dataFileName %}{{ command | strip | replace: " ","_" }}{% endcapture %}
|
||||
<tr>
|
||||
<td markdown="span">[{{ command }}]({{ dataFileName | replace: "docker_","" }}/)</td>
|
||||
|
@ -199,7 +201,7 @@ The include.datafolder or include.datafile was not set.
|
|||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% unless site.data[include.datafolder][include.datafile].pname == "docker" or site.data[include.datafolder][include.datafile].pname == "dockerd" or include.datafile=="docker" %}
|
||||
{% unless controller_data.pname == "docker" or controller_data.pname == "dockerd" or include.datafile=="docker" %}
|
||||
|
||||
## Related commands
|
||||
|
||||
|
|
Loading…
Reference in New Issue