Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ release: 1.17.0
LLVM version: 3.9
```

## `-o`/`--output`: output path
## `-o`/`--out-dir`: output directory path

Using this flag looks like this:

```bash
$ rustdoc src/lib.rs -o target/doc
$ rustdoc src/lib.rs --output target/doc
$ rustdoc src/lib.rs --out-dir target/doc
```

By default, `rustdoc`'s output appears in a directory named `doc` in
Expand Down
14 changes: 12 additions & 2 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,18 @@ impl Options {
return Err(1);
}

let output =
matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc"));
let out_dir = matches.opt_str("out-dir").map(|s| PathBuf::from(&s));
let output = matches.opt_str("output").map(|s| PathBuf::from(&s));
let output = match (out_dir, output) {
(Some(_), Some(_)) => {
diag.struct_err("cannot use both 'out-dir' and 'output' at once").emit();
return Err(1);
}
(Some(out_dir), None) => out_dir,
(None, Some(output)) => output,
(None, None) => PathBuf::from("doc"),
};

let cfgs = matches.opt_strs("cfg");

let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));
Expand Down
11 changes: 10 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,16 @@ fn opts() -> Vec<RustcOptGroup> {
o.optopt("r", "input-format", "the input type of the specified file", "[rust]")
}),
stable("w", |o| o.optopt("w", "output-format", "the output type to write", "[html]")),
stable("o", |o| o.optopt("o", "output", "where to place the output", "PATH")),
stable("output", |o| {
o.optopt(
"",
"output",
"Which directory to place the output. \
This option is deprecated, use --out-dir instead.",
"PATH",
)
}),
stable("o", |o| o.optopt("o", "out-dir", "which directory to place the output", "PATH")),
stable("crate-name", |o| {
o.optopt("", "crate-name", "specify the name of this crate", "NAME")
}),
Expand Down
8 changes: 8 additions & 0 deletions src/test/run-make/rustdoc-with-out-dir-option/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-include ../../run-make-fulldeps/tools.mk

OUTPUT_DIR := "$(TMPDIR)/rustdoc"

all:
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR)

$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
2 changes: 2 additions & 0 deletions src/test/run-make/rustdoc-with-out-dir-option/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @has foobar/fn.ok.html
pub fn ok() {}
8 changes: 8 additions & 0 deletions src/test/run-make/rustdoc-with-output-option/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-include ../../run-make-fulldeps/tools.mk

OUTPUT_DIR := "$(TMPDIR)/rustdoc"

all:
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR)

$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
2 changes: 2 additions & 0 deletions src/test/run-make/rustdoc-with-output-option/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @has foobar/fn.ok.html
pub fn ok() {}
8 changes: 8 additions & 0 deletions src/test/run-make/rustdoc-with-short-out-dir-option/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-include ../../run-make-fulldeps/tools.mk

OUTPUT_DIR := "$(TMPDIR)/rustdoc"

all:
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib -o $(OUTPUT_DIR)

$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @has foobar/fn.ok.html
pub fn ok() {}
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/use_both_out_dir_and_output_options.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// compile-flags: --output ./foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: cannot use both 'out-dir' and 'output' at once