Skip to content

Commit 8f3b559

Browse files
Stabilize rustdoc --merge --parts-out-dir, and --include-parts-dir options
1 parent eeb94be commit 8f3b559

4 files changed

Lines changed: 73 additions & 75 deletions

File tree

src/doc/rustdoc/src/command-line-arguments.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,35 @@ command line options from it. These options are one per line; a blank line indic
453453
an empty option. The file can use Unix or Windows style line endings, and must be
454454
encoded as UTF-8.
455455

456+
## `--merge`, `--parts-out-dir` and `--include-parts-dir`: control how rustdoc handles files that combine data from multiple crates
457+
458+
By default, they act like `--merge=shared` is set, and `--parts-out-dir` and `--include-parts-dir`
459+
are turned off. The `--merge=shared` mode causes rustdoc to load the existing data in the out-dir,
460+
combine the new crate data into it, and write the result. This is very easy to use in scripts that
461+
manually invoke rustdoc, but it's also slow, because it performs O(crates) work on
462+
every crate, meaning it performs O(crates<sup>2</sup>) work.
463+
464+
```console
465+
$ rustdoc crate1.rs --out-dir=doc
466+
$ cat doc/search.index/crateNames/*
467+
rd_("fcrate1")
468+
$ rustdoc crate2.rs --out-dir=doc
469+
$ cat doc/search.index/crateNames/*
470+
rd_("fcrate1fcrate2")
471+
```
472+
473+
To delay shared-data merging until the end of a build, so that you only have to perform O(crates)
474+
work, use `--merge=none` on every crate except the last one, which will use `--merge=finalize`.
475+
476+
```console
477+
$ rustdoc +nightly crate1.rs --merge=none --parts-out-dir=crate1.d -Zunstable-options
478+
$ cat doc/search.index/crateNames/*
479+
cat: 'doc/search.index/crateNames/*': No such file or directory
480+
$ rustdoc +nightly crate2.rs --merge=finalize --include-parts-dir=crate1.d -Zunstable-options
481+
$ cat doc/search.index/crateNames/*
482+
rd_("fcrate1fcrate2")
483+
```
484+
456485
## `--passes`: add more rustdoc passes
457486

458487
This flag is **deprecated**.

src/doc/rustdoc/src/unstable-features.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,37 +197,6 @@ themselves marked as unstable. To use any of these options, pass `-Z unstable-op
197197
the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the
198198
`RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command.
199199

200-
### `--merge`, `--parts-out-dir`, and `--include-parts-dir`
201-
202-
These options control how rustdoc handles files that combine data from multiple crates.
203-
204-
By default, they act like `--merge=shared` is set, and `--parts-out-dir` and `--include-parts-dir`
205-
are turned off. The `--merge=shared` mode causes rustdoc to load the existing data in the out-dir,
206-
combine the new crate data into it, and write the result. This is very easy to use in scripts that
207-
manually invoke rustdoc, but it's also slow, because it performs O(crates) work on
208-
every crate, meaning it performs O(crates<sup>2</sup>) work.
209-
210-
```console
211-
$ rustdoc crate1.rs --out-dir=doc
212-
$ cat doc/search.index/crateNames/*
213-
rd_("fcrate1")
214-
$ rustdoc crate2.rs --out-dir=doc
215-
$ cat doc/search.index/crateNames/*
216-
rd_("fcrate1fcrate2")
217-
```
218-
219-
To delay shared-data merging until the end of a build, so that you only have to perform O(crates)
220-
work, use `--merge=none` on every crate except the last one, which will use `--merge=finalize`.
221-
222-
```console
223-
$ rustdoc +nightly crate1.rs --merge=none --parts-out-dir=crate1.d -Zunstable-options
224-
$ cat doc/search.index/crateNames/*
225-
cat: 'doc/search.index/crateNames/*': No such file or directory
226-
$ rustdoc +nightly crate2.rs --merge=finalize --include-parts-dir=crate1.d -Zunstable-options
227-
$ cat doc/search.index/crateNames/*
228-
rd_("fcrate1fcrate2")
229-
```
230-
231200
### `--document-hidden-items`: Show items that are `#[doc(hidden)]`
232201
<span id="document-hidden-items"></span>
233202

src/librustdoc/lib.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -599,33 +599,6 @@ fn opts() -> Vec<RustcOptGroup> {
599599
"",
600600
"path to function call information (for displaying examples in the documentation)",
601601
),
602-
opt(
603-
Unstable,
604-
Opt,
605-
"",
606-
"merge",
607-
"Controls how rustdoc handles files from previously documented crates in the doc root\n\
608-
none = Do not write cross-crate information to the --out-dir\n\
609-
shared = Append current crate's info to files found in the --out-dir\n\
610-
finalize = Write current crate's info and --include-parts-dir info to the --out-dir, overwriting conflicting files",
611-
"none|shared|finalize",
612-
),
613-
opt(
614-
Unstable,
615-
Opt,
616-
"",
617-
"parts-out-dir",
618-
"Writes trait implementations and other info for the current crate to provided path. Only use with --merge=none",
619-
"path/to/doc.parts/<crate-name>",
620-
),
621-
opt(
622-
Unstable,
623-
Multi,
624-
"",
625-
"include-parts-dir",
626-
"Includes trait implementations and other crate info from provided path. Only use with --merge=finalize",
627-
"path/to/doc.parts/<crate-name>",
628-
),
629602
opt(Unstable, Flag, "", "html-no-source", "Disable HTML source code pages generation", ""),
630603
opt(
631604
Unstable,
@@ -692,6 +665,33 @@ fn opts() -> Vec<RustcOptGroup> {
692665
"removed, see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information",
693666
"[rust]",
694667
),
668+
opt(
669+
Stable,
670+
Opt,
671+
"",
672+
"merge",
673+
"Controls how rustdoc handles files from previously documented crates in the doc root\n\
674+
none = Do not write cross-crate information to the --out-dir\n\
675+
shared = Append current crate's info to files found in the --out-dir\n\
676+
finalize = Write current crate's info and --include-parts-dir info to the --out-dir, overwriting conflicting files",
677+
"none|shared|finalize",
678+
),
679+
opt(
680+
Stable,
681+
Opt,
682+
"",
683+
"parts-out-dir",
684+
"Writes trait implementations and other info for the current crate to provided path. Only use with --merge=none",
685+
"path/to/doc.parts/<crate-name>",
686+
),
687+
opt(
688+
Stable,
689+
Multi,
690+
"",
691+
"include-parts-dir",
692+
"Includes trait implementations and other crate info from provided path. Only use with --merge=finalize",
693+
"path/to/doc.parts/<crate-name>",
694+
),
695695
]
696696
}
697697

tests/run-make/rustdoc-default-output/output-default.stdout

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,6 @@ Options:
173173
--scrape-tests Include test code when scraping examples
174174
--with-examples path to function call information (for displaying examples in the documentation)
175175

176-
--merge none|shared|finalize
177-
Controls how rustdoc handles files from previously
178-
documented crates in the doc root
179-
none = Do not write cross-crate information to the
180-
--out-dir
181-
shared = Append current crate's info to files found in
182-
the --out-dir
183-
finalize = Write current crate's info and
184-
--include-parts-dir info to the --out-dir, overwriting
185-
conflicting files
186-
--parts-out-dir path/to/doc.parts/<crate-name>
187-
Writes trait implementations and other info for the
188-
current crate to provided path. Only use with
189-
--merge=none
190-
--include-parts-dir path/to/doc.parts/<crate-name>
191-
Includes trait implementations and other crate info
192-
from provided path. Only use with --merge=finalize
193176
--html-no-source
194177
Disable HTML source code pages generation
195178
--doctest-build-arg ARG
@@ -219,6 +202,23 @@ Options:
219202
removed, see issue #44136
220203
<https://github.com/rust-lang/rust/issues/44136> for
221204
more information
205+
--merge none|shared|finalize
206+
Controls how rustdoc handles files from previously
207+
documented crates in the doc root
208+
none = Do not write cross-crate information to the
209+
--out-dir
210+
shared = Append current crate's info to files found in
211+
the --out-dir
212+
finalize = Write current crate's info and
213+
--include-parts-dir info to the --out-dir, overwriting
214+
conflicting files
215+
--parts-out-dir path/to/doc.parts/<crate-name>
216+
Writes trait implementations and other info for the
217+
current crate to provided path. Only use with
218+
--merge=none
219+
--include-parts-dir path/to/doc.parts/<crate-name>
220+
Includes trait implementations and other crate info
221+
from provided path. Only use with --merge=finalize
222222

223223
@path Read newline separated options from `path`
224224

0 commit comments

Comments
 (0)