summaryrefslogtreecommitdiffstats
path: root/front_end/templates/install.rs.html
blob: 64707cb716e7f73c227a548347de6a08884c3991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@use crate::templates::base;
@use crate::install_page::InstallPage;
@use crate::Urler;
@use rich_crate::Origin;

@(url: &Urler, c: &InstallPage)

@:base(&c.page(), {
  <header id="package" @if c.ver.is_yanked() {class="yanked"} else {@if c.ver.is_nightly() {class="nightly"}}>
    <div class="inner-col">
    <div class="breadcrumbs">
    <h1>
      <a href="/"><span>Lib</span>.rs</a>
    </h1><a href="@url.krate(&c.ver)" rel="up">@c.ver.capitalized_name()</a>
     › Install
    </div>
    <nav><ul>
        <li class=active>Instructions</li>
      @if let Some(url) = url.crates_io_crate(c.ver.origin()) {
        <li><a href="@url">crates.io page</a></li>
      }
    </ul></nav>
    </div>
  </header>
  <main>
    <div class="inner-col">
        @if c.ver.is_yanked() {
            <p>This crate is yanked (soft-deleted), so it can't be installed any more.</p>
        } else {
        @if c.ver.is_nightly() {
            <p>This crate requires a nightly (unstable, experimental) compiler version. To switch to it, you must have Rust installed via <a href="https://rustup.rs">Rustup</a>, and run:</p>
            <pre class="to-copy"><code>rustup default <b>nightly</b></code></pre>
            <p>Run <code>rustup default stable</code> to switch back.</p>
        }
        @if c.ver.has_bin() && c.ver.has_lib() {
            <p>@c.ver.capitalized_name() is both an executable binary that can be run, and a library that can be used in Rust programs.</p>
        }
        @if c.ver.is_proc_macro() {
            <p>@c.ver.capitalized_name() is a procedural macro. It will run at compile time and transform your program's source code.</p>
        }
        @if c.ver.has_bin() {
            @if let Some(bins) = Some(c.ver.bin_names()) {
                @if bins.len() == 1 {
                    <h2>Installing the @if bins[0] == c.ver.short_name() {command-line} else {<code>@bins[0]</code>} executable</h2>
                } else {
                    <h2>Installing @for bin in &bins {<code>@bin</code> } executables</h2>
                }
                <p>Assuming you have <a href="https://www.rust-lang.org/tools/install">Rust/Cargo installed</a>, run this command in a terminal:</p>
                @if let Origin::CratesIo(_) = c.ver.origin() {
                    <pre class="to-copy"><code><b>cargo install</b> -f @c.ver.short_name()</code></pre>
                }
                @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                    <pre class="to-copy"><code><b>cargo install</b> -f @package --git @repo.canonical_git_url().unwrap()</code></pre>
                }
                <p>It will make @if bins.len()==1 {the } @for bin in &bins {<code>@bin</code> } command@if bins.len()>1 {s} available in your <code>PATH</code> if you've allowed the <code>PATH</code> to be modified when <a href="https://www.rust-lang.org/tools/install">installing Rust</a>. <code>cargo uninstall @c.ver.short_name()</code> uninstalls.</p>
            }
        }
        @if c.ver.has_lib() {
            <h2>Adding <code>@c.ver.lib_name()</code> library as a dependency</h2>
            @if c.ver.short_name() != "cargo-edit" {
            <p>If you have <a href='@url.install(&Origin::from_crates_io_name("cargo-edit"))'>cargo-edit installed</a>, run this command in a terminal, in your project's directory:</p>
            @if c.is_build {
                @if let Origin::CratesIo(name) = c.ver.origin() {
                    <pre class="to-copy"><code><b>cargo add</b> --build @name</code></pre>
                }
                @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                    <pre class="to-copy"><code><b>cargo add</b> --build @package --git @repo.canonical_git_url().unwrap()</code></pre>
                }
                <p>to add <code>@c.ver.lib_name()</code> as a build-time dependency. To add it as a run-time dependency, run:</p>
            } else {@if c.is_dev {
                @if let Origin::CratesIo(name) = c.ver.origin() {
                    <pre class="to-copy"><code><b>cargo add</b> --dev @name</code></pre>
                }
                @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                    <pre class="to-copy"><code><b>cargo add</b> --dev @package --git @repo.canonical_git_url().unwrap()</code></pre>
                }
                <p>to add it a dev dependency (if it's used only in tests, not in the final product). To add it as a regular run-time dependency, run:</p>
            }}
            @if let Origin::CratesIo(name) = c.ver.origin() {
                <pre class="to-copy"><code><b>cargo add</b> @name</code></pre>
            }
            @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                <pre class="to-copy"><code><b>cargo add</b> @package --git @repo.canonical_git_url().unwrap()</code></pre>
            }
            }
            <p>To add it manually, edit your project's <code>Cargo.toml</code> file and add to the @if c.is_build {<code>[build-dependencies]</code> or} <code>[dependencies]</code> section:</p>
            @if let Origin::CratesIo(_) = c.ver.origin() {
                <pre class="to-copy"><code>@c.ver.short_name() = "@c.ver.version()"</code></pre>
            }
            @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                <pre class="to-copy"><code>@package = @"{" git = "@repo.canonical_git_url().unwrap()" @"}"</code></pre>
            }
            <p>The <code>@c.ver.lib_name()</code> library will automatically available globally.
            @if let Some(url) = c.api_reference_url() {
                Read the <a href="@url"><code>@c.ver.lib_name()</code> library documentation</a>.
            }</p>
        }
        @if c.ver.is_proc_macro() && !c.ver.has_lib() {
            <h2>Adding <code>@c.ver.short_name()</code> macro(s) as a dependency</h2>
            <p>If you have <a href='@url.install(&Origin::from_crates_io_name("cargo-edit"))'>cargo-edit installed</a>, run this command in a terminal, in your project's directory:</p>
            @if let Origin::CratesIo(name) = c.ver.origin() {
                <pre class="to-copy"><code><b>cargo add</b> @name</code></pre>
            }
            @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                <pre class="to-copy"><code><b>cargo add</b> @package --git @repo.canonical_git_url().unwrap()</code></pre>
            }
            <p>To add it manually, edit your project's <code>Cargo.toml</code> file and add to the <code>[dependencies]</code> section:</p>
            @if let Origin::CratesIo(_) = c.ver.origin() {
                <pre class="to-copy"><code>@c.ver.short_name() = "@c.ver.version()"</code></pre>
            }
            @if let Some((repo, package)) = c.ver.origin().clone().into_repo() {
                <pre class="to-copy"><code>@package = @"{" git = "@repo.canonical_git_url().unwrap()" @"}"</code></pre>
            }
            <p>You may need to import the macro(s) with <code>use @c.ver.lib_name()<tt>::*</tt></code>.</p>
            @if let Some(url) = c.api_reference_url() {
                Read the <a href="@url"><code>@c.ver.lib_name()</code> documentation</a>.
            }</p>
        }}
        <p><a href="@url.krate(&c.ver)" rel="up">Back to the crate overview</a>.</p>
        <hr>
        @if let Some(readme) = c.ver.readme() {
          <section id=readme class="readme" vocab=""><aside><h2>Readme</h2>
            @c.render_readme(readme)
          </aside></section>
        }
    </div>
  </main>

  <footer>
    <div class="inner-col">
        <p>Back to <a href="@url.krate(&c.ver)" rel="up">@c.ver.capitalized_name()</a>.</p>
    </div>
  </footer>
})