Skip to content
Open
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
29 changes: 29 additions & 0 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,35 @@ When `rustdoc` receives this flag, it will print an extra "Version (version)" in
the crate root's docs. You can use this flag to differentiate between different versions of your
library's documentation.

## `--emit`: control the types of output for rustdoc to emit

This flag controls the types of output by rustdoc. It accepts a comma-separated
list of values, and may be specified multiple times. The valid emit kinds are:

- `unversioned-shared-resources` --- Current a no-op option.
- `toolchain-shared-resources` --- Generates shared static files that their
contents are tied to a specific toolchain version. These are written with a
filename that includes a hash of their contents, so they are safe to cache with the
change if the toolchain version or their contents change, so it is safe to
cache them wit the `Cache-Control: immutable` directive.
- `invocation-specific` --- Generates files based on the crate(s) being
documented. These file names need to be deterministic so there is no
content-hash in their file names.
- `dep-info` --- Generates a file with Makefile syntax that indicates all the
source files that were loaded to document the crate. The default output
filename is `CRATE_NAME.d`. This emit type can can optionally be followed by
`=` to specify an explicit output path.
For example, `--emit=dep-info=/path/to/foo.d`.
Comment on lines +459 to +461
Copy link
Member

@fmease fmease Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a bug: rustdoc's --emit=dep-info=- doesn't output to STDOUT unlike rustc's.

Edit: This ought to be addressed in a separate PR by someone. I'll probably open an issue later to track this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #147649 (blocking the stabilization IMO).


Using this flag looks like this:

```bash
$ rustdoc src/lib.rs --emit=toolchain-shared-resources,invocation-specific,dep-info=/path/too/build/cache/foo.d
```

If not specified, the default emit types would be
`--emit=toolchain-shared-resources,invocation-specific`.

## `-`: load source code from the standard input

If you specify `-` as the INPUT on the command line, then `rustdoc` will read the
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn opts() -> Vec<RustcOptGroup> {
"",
),
opt(
Unstable,
Stable,
Multi,
"",
"emit",
Expand Down
Loading