Files
docker-docs/_includes/cli.md
Sebastiaan van Stijn 80c6d185e3 Only fix links on reference pages
The JavaScript "link fix" looks to be only needed for pages
where Markdown is included, and which contain relative links.

Now that we modified all local includes to use absolute links,
the only location where links are not properly generated, is
in the reference documentation.

If broken links are found elsewhere in the website, those links
are legitimately broken, and should be fixed in the markdown
source, not fixed-up afterwards.

This patch moves the javascript to the cli.md include, so that
the script is only run on the reference pages instead of on every
page.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-23 10:27:57 +02:00

11 KiB

{% capture tabChar %} {% endcapture %} {% assign controller_data = site.data[include.datafolder][include.datafile] %} {% assign parentPath = page.path | prepend: "/" | remove: page.name %}

Description

{{ controller_data.short }}

{% if controller_data.min_api_version %}

API {{ controller_data.min_api_version }}+  The client and daemon API must both be at least {{ controller_data.min_api_version }} to use this command. Use the docker version command on the client to check your client and daemon API versions.

{% endif %}

{% if controller_data.deprecated %}

This command is deprecated{: target="blank" class=""}.

It may be removed in a future Docker version. {: .warning }

{% endif %}

{% if page.enterprise_only == true %}

This command is only available on Docker Enterprise Edition.

Learn more about Docker Enterprise products{: target="blank" class=""}. {: .important }

{% endif %}

{% if controller_data.experimental %}

This command is experimental.

This command is experimental on the Docker daemon. It should not be used in production environments. To enable experimental features on the Docker daemon, edit the daemon.json and set experimental to true.

{% include experimental.md %}

{% endif %}

{% if controller_data.experimentalcli %}

This command is experimental on the Docker client.

It should not be used in production environments.

To enable experimental features in the Docker CLI, edit the config.json and set experimental to enabled. You can go here for more information. {: .important }

{% endif %}

{% capture command-orchestrator %} {% if controller_data.swarm %}

Swarm This command works with the Swarm orchestrator.

{% endif %} {% if controller_data.kubernetes %}

Kubernetes This command works with the Kubernetes orchestrator.

{% endif %} {% endcapture %}{{ command-orchestrator }}

{% if controller_data.usage %}

Usage

{{ controller_data.usage | replace: tabChar, "" | strip }}{% if controller_data.cname %} COMMAND{% endif %}

{% endif %} {% unless controller_data.long == controller_data.short %}

Extended description

{{ controller_data.long }}

{% endunless %}

{% if controller_data.examples %} For example uses of this command, refer to the examples section below. {% endif %}

{% if controller_data.options %} {% if controller_data.inherited_options %} {% assign alloptions = controller_data.options | concat:controller_data.inherited_options %} {% else %} {% assign alloptions = controller_data.options %} {% endif %}

Options

{% for option in alloptions %} {% capture deprecated-badge %}{% if option.deprecated %}deprecated{% endif %}{% endcapture %} {% capture experimental-daemon-badge %}{% if option.experimental %}experimental (daemon){% endif %}{% endcapture %} {% capture experimental-cli-badge %}{% if option.experimentalcli %}experimental (CLI){% endif %}{% endcapture %} {% capture min-api %}{% if option.min_api_version %}API {{ option.min_api_version }}+{% endif %}{%endcapture%} {% capture flag-orchestrator %}{% if option.swarm %}Swarm{% endif %}{% if option.kubernetes %}Kubernetes{% endif %}{% endcapture %} {% capture all-badges %}{{ deprecated-badge }}{{ experimental-daemon-badge }}{{ experimental-cli-badge }}{{ min-api }}{{ flag-orchestrator }}{% endcapture %} {% assign defaults-to-skip = "[],map[],false,0,0s,default,'',\"\"" | split: ',' %} {% capture option-default %}{% if option.default_value %}{% unless defaults-to-skip contains option.default_value or defaults-to-skip == blank %}`{{ option.default_value }}`{% endunless %}{% endif %}{% endcapture %} {% endfor %}
Name, shorthand Default Description
`--{{ option.option }}{% if option.shorthand %} , -{{ option.shorthand }}{% endif %}` {{ option-default }} {% if all-badges != '' %}{{ all-badges | strip }}
{% endif %}{{ option.description | strip }}
{% endif %}

{% if controller_data.examples %}

Examples

{{ controller_data.examples }}

{% endif %}

{% if controller_data.pname %} {% unless controller_data.pname == include.datafile %}

Parent command

{% capture parentfile %}{{ controller_data.plink | remove_first: ".yaml" | remove_first: "docker_" }}{% endcapture %} {% capture parentdatafile %}{{ controller_data.plink | remove_first: ".yaml" }}{% endcapture %} {% capture parentDesc %}{{ site.data[include.datafolder][parentdatafile].short }}{% endcapture %}

Command Description
[{{ controller_data.pname }}]({{parentPath}}{{ parentfile }}/) {{ parentDesc }}

{% endunless %} {% endif %}

{% if controller_data.cname %}

Child commands

{% for command in controller_data.cname %} {% capture dataFileName %}{{ command | strip | replace: " ", "_" }}{% endcapture %} {% endfor %}
Command Description
[{{ command }}]({{ parentPath }}{{ dataFileName | remove_first: "docker_" }}/) {{ site.data[include.datafolder][dataFileName].short }}
{% endif %}

{% unless controller_data.pname == "docker" or controller_data.pname == "dockerd" or include.datafile=="docker" %}

{% for command in site.data[include.datafolder][parentdatafile].cname %} {% capture dataFileName %}{{ command | strip | replace: " ", "_" }}{% endcapture %} {% endfor %}
Command Description
[{{ command }}]({{ parentPath }}{{ dataFileName | remove_first: "docker_" }}/) {{ site.data[include.datafolder][dataFileName].short }}

{% endunless %}

<script> // This is a horrible hack, and cute little kittens are sacrificed every time it's run, so we // need to remove it as soon as possible. // // Fix up links to markdown pages that weren't resolved by Jekyll (or the "jekyll-relative-links" // plugin). This is a horrible hack, and should not rely on JavaScript (perhaps be re-implemented // using Liquid). We need this hack to work around two bugs in the "jekyll-relative-links" plugin; // 1. As reported in https://github.com/benbalter/jekyll-relative-links/issues/54, (relative) links // to markdown pages in includes are not processed by Jekyll. This means that (for example) our // reference pages (which use includes) contain broken links. We can work around this by modifying // the markdown for those pages to use "absolute" "html" links (/link/to/other/page/#some-anchor), // but doing so would render the links broken when viewed on GitHub. Instead, we're fixing them up // here, hoping the bug will be fixed, and it's only temporarily. // 2. As reported in https://github.com/benbalter/jekyll-relative-links/issues/61, (relative) links // to markdown pages are not resolved if the link's caption/title is wrapped. // Array.prototype.forEach.call(document.querySelectorAll("section.section a:not(.nomunge)"), function (el) { let href = el.getAttribute("href"); if (href.startsWith("/") || href.startsWith("#") || href.includes("://") || !href.includes('.md')) { // Don't modify anchor links, absolute links, links to external websites, // or links not pointing to a .md file; we assume those were // resolved successfully by Jekyll. return } if (href.startsWith("./")) { href = href.substr(2) } if ("{{ page.name }}" !== "index.md") { // For non-index pages, things are a bit hairy. For example, for /foo/bar/mypage.md, Jekyll // will generate a page named /foo/bar/mypage/index.html. This means that all links relative // to mypage.md expect those links to be relative to the /foo/bar/ directory, but end up // being relative to /foo/bar/mypage/. // // For files "next to", or "below" this file, such as "file.md" or "nested/dir/file.md" we // prepend the "parent-dir" to the URL. // // For links to files "up" the directory tree, we prepend // "../" to the URL and have the browser handle this. For example, "../file.md" and "../../file.md" // become "../../file.md" and "../../../file.md". if (href.startsWith("../")) { href = "../" + href } else { // Generate "parentPath" with Liquid, which is used below. Liquid's page.path (and page.dir) // are relative to the _generated_ HTML page, not the source page, so we have to remove the // last part of the path: // {% raw %}{% assign parentPath = page.path | prepend: "/" | remove: page.name %}{% endraw %} // {% assign parentPath = page.path | prepend: "/" | remove: page.name %} href = "{{ parentPath}}" + href } } // finally, we replace the .md extension for a slash, and update the link's href el.setAttribute("href", href.replace(".md", "/")) }); </script>