Skip to content

Commit 5e833ba

Browse files
committed
Document cargo doc --publish-dir
1 parent 6964145 commit 5e833ba

File tree

10 files changed

+98
-0
lines changed

10 files changed

+98
-0
lines changed

src/doc/man/cargo-doc.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ or use the [`doc.browser`](../reference/config.html#docbrowser) configuration
2727
option.
2828
{{/option}}
2929

30+
{{#option "`--publish-dir`" }}
31+
The generated documentation will be copied to the specified publish directory.
32+
This can be used to publish documentation straight into, for example, a
33+
directory that is being served up by a local web server already.
34+
This will override the corresponding
35+
[`doc.publish-dir`](../reference/config.html#docpublish-dir) configuration option and
36+
[`CARGO_DOC_PUBLISH_DIR`](../reference/environment-variables.html#configuration-environment-variables)
37+
environment variable.
38+
{{/option}}
39+
3040
{{#option "`--no-deps`" }}
3141
Do not build documentation for dependencies.
3242
{{/option}}

src/doc/man/cargo-rustdoc.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ or use the [`doc.browser`](../reference/config.html#docbrowser) configuration
3939
option.
4040
{{/option}}
4141

42+
{{#option "`--publish-dir`" }}
43+
The generated documentation will be copied to the specified publish directory.
44+
This can be used to publish documentation straight into, for example, a
45+
directory that is being served up by a local web server already.
46+
This will override the corresponding
47+
[`doc.publish-dir`](../reference/config.html#docpublish-dir) configuration option and
48+
[`CARGO_DOC_PUBLISH_DIR`](../reference/environment-variables.html#configuration-environment-variables)
49+
environment variable.
50+
{{/option}}
51+
4252
{{/options}}
4353

4454
{{> section-options-package }}

src/doc/man/generated_txt/cargo-doc.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ OPTIONS
1919
<https://doc.rust-lang.org/cargo/reference/config.html#docbrowser>
2020
configuration option.
2121

22+
--publish-dir
23+
The generated documentation will be copied to the specified publish
24+
directory. This can be used to publish documentation straight into,
25+
for example, a directory that is being served up by a local web
26+
server already. This will override the corresponding doc.publish-dir
27+
<https://doc.rust-lang.org/cargo/reference/config.html#docpublish-dir>
28+
configuration option and CARGO_DOC_PUBLISH_DIR
29+
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#configuration-environment-variables>
30+
environment variable.
31+
2232
--no-deps
2333
Do not build documentation for dependencies.
2434

src/doc/man/generated_txt/cargo-rustdoc.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ OPTIONS
3838
<https://doc.rust-lang.org/cargo/reference/config.html#docbrowser>
3939
configuration option.
4040

41+
--publish-dir
42+
The generated documentation will be copied to the specified publish
43+
directory. This can be used to publish documentation straight into,
44+
for example, a directory that is being served up by a local web
45+
server already. This will override the corresponding doc.publish-dir
46+
<https://doc.rust-lang.org/cargo/reference/config.html#docpublish-dir>
47+
configuration option and CARGO_DOC_PUBLISH_DIR
48+
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#configuration-environment-variables>
49+
environment variable.
50+
4151
Package Selection
4252
By default, the package in the current working directory is selected.
4353
The -p flag can be used to choose a different package in a workspace.

src/doc/src/commands/cargo-doc.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ or use the <a href="../reference/config.html#docbrowser"><code>doc.browser</code
2727
option.</dd>
2828

2929

30+
<dt class="option-term" id="option-cargo-doc---publish-dir"><a class="option-anchor" href="#option-cargo-doc---publish-dir"></a><code>--publish-dir</code></dt>
31+
<dd class="option-desc">The generated documentation will be copied to the specified publish directory.
32+
This can be used to publish documentation straight into, for example, a
33+
directory that is being served up by a local web server already.
34+
This will override the corresponding
35+
<a href="../reference/config.html#docpublish-dir"><code>doc.publish-dir</code></a> configuration option and
36+
<a href="../reference/environment-variables.html#configuration-environment-variables"><code>CARGO_DOC_PUBLISH_DIR</code></a>
37+
environment variable.</dd>
38+
39+
3040
<dt class="option-term" id="option-cargo-doc---no-deps"><a class="option-anchor" href="#option-cargo-doc---no-deps"></a><code>--no-deps</code></dt>
3141
<dd class="option-desc">Do not build documentation for dependencies.</dd>
3242

src/doc/src/commands/cargo-rustdoc.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ or use the <a href="../reference/config.html#docbrowser"><code>doc.browser</code
4343
option.</dd>
4444

4545

46+
<dt class="option-term" id="option-cargo-rustdoc---publish-dir"><a class="option-anchor" href="#option-cargo-rustdoc---publish-dir"></a><code>--publish-dir</code></dt>
47+
<dd class="option-desc">The generated documentation will be copied to the specified publish directory.
48+
This can be used to publish documentation straight into, for example, a
49+
directory that is being served up by a local web server already.
50+
This will override the corresponding
51+
<a href="../reference/config.html#docpublish-dir"><code>doc.publish-dir</code></a> configuration option and
52+
<a href="../reference/environment-variables.html#configuration-environment-variables"><code>CARGO_DOC_PUBLISH_DIR</code></a>
53+
environment variable.</dd>
54+
55+
4656
</dl>
4757

4858
### Package Selection

src/doc/src/reference/config.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ pipelining = true # rustc pipelining
7878
[doc]
7979
browser = "chromium" # browser to use with `cargo doc --open`,
8080
# overrides the `BROWSER` environment variable
81+
publish-dir = "/var/www/html" # directory to copy the generated documentation to
82+
# overrides the `CARGO_DOC_PUBLISH_DIR` environment variable
8183

8284
[env]
8385
# Set ENV_VAR_NAME=value for any process run by Cargo
@@ -458,6 +460,18 @@ This option sets the browser to be used by [`cargo doc`], overriding the
458460
`BROWSER` environment variable when opening documentation with the `--open`
459461
option.
460462

463+
##### `doc.publish-dir`
464+
465+
* Type: string
466+
* Default: `CARGO_DOC_PUBLISH_DIR` environment variable, or, if that is
467+
missing, documentation is not published.
468+
469+
This option is used by [`cargo doc`] as a directory to copy the generated
470+
documentation to, overriding the `CARGO_DOC_PUBLISH_DIR` environment variable.
471+
It can also be set with the `--publish-dir` CLI option.
472+
This can be used to publish documentation straight into, for example, a
473+
directory that is being served up by a local web server already.
474+
461475
#### `[cargo-new]`
462476

463477
The `[cargo-new]` table defines defaults for the [`cargo new`] command.

src/doc/src/reference/environment-variables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ supported environment variables are:
118118
* `CARGO_TERM_COLOR` — The default color mode, see [`term.color`].
119119
* `CARGO_TERM_PROGRESS_WHEN` — The default progress bar showing mode, see [`term.progress.when`].
120120
* `CARGO_TERM_PROGRESS_WIDTH` — The default progress bar width, see [`term.progress.width`].
121+
* `CARGO_DOC_PUBLISH_DIR` — Directory to copy the generated documentation to, see [`doc.publish-dir`] for more details.
121122

122123
[`cargo doc`]: ../commands/cargo-doc.md
123124
[`cargo install`]: ../commands/cargo-install.md
@@ -141,6 +142,7 @@ supported environment variables are:
141142
[`build.dep-info-basedir`]: config.md#builddep-info-basedir
142143
[`build.pipelining`]: config.md#buildpipelining
143144
[`doc.browser`]: config.md#docbrowser
145+
[`doc.publish-dir`]: config.md#docpublish-dir
144146
[`cargo-new.name`]: config.md#cargo-newname
145147
[`cargo-new.email`]: config.md#cargo-newemail
146148
[`cargo-new.vcs`]: config.md#cargo-newvcs

src/etc/man/cargo-doc.1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ or use the \fI\f(BIdoc.browser\fI\fR <https://doc.rust\-lang.org/cargo/reference
2121
option.
2222
.RE
2323
.sp
24+
\fB\-\-publish\-dir\fR
25+
.RS 4
26+
The generated documentation will be copied to the specified publish directory.
27+
This can be used to publish documentation straight into, for example, a
28+
directory that is being served up by a local web server already.
29+
This will override the corresponding
30+
\fI\f(BIdoc.publish\-dir\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#docpublish\-dir> configuration option and
31+
\fI\f(BICARGO_DOC_PUBLISH_DIR\fI\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html#configuration\-environment\-variables>
32+
environment variable.
33+
.RE
34+
.sp
2435
\fB\-\-no\-deps\fR
2536
.RS 4
2637
Do not build documentation for dependencies.

src/etc/man/cargo-rustdoc.1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ browser unless you define another one in the \fBBROWSER\fR environment variable
3636
or use the \fI\f(BIdoc.browser\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#docbrowser> configuration
3737
option.
3838
.RE
39+
.sp
40+
\fB\-\-publish\-dir\fR
41+
.RS 4
42+
The generated documentation will be copied to the specified publish directory.
43+
This can be used to publish documentation straight into, for example, a
44+
directory that is being served up by a local web server already.
45+
This will override the corresponding
46+
\fI\f(BIdoc.publish\-dir\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#docpublish\-dir> configuration option and
47+
\fI\f(BICARGO_DOC_PUBLISH_DIR\fI\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html#configuration\-environment\-variables>
48+
environment variable.
49+
.RE
3950
.SS "Package Selection"
4051
By default, the package in the current working directory is selected. The \fB\-p\fR
4152
flag can be used to choose a different package in a workspace.

0 commit comments

Comments
 (0)