diff options
| author | Will Crichton <wcrichto@cs.stanford.edu> | 2021-10-06 21:43:40 -0700 |
|---|---|---|
| committer | Will Crichton <wcrichto@cs.stanford.edu> | 2021-10-06 21:43:40 -0700 |
| commit | 5584c795975e9cc07884b479c7cb7aef2f47c231 (patch) | |
| tree | ed710152c2c54a982050c5e74eb0526a402294dd /src/doc/rustdoc | |
| parent | ed8e12fd242f2d35b4d1a72155c4f8f4eb05be43 (diff) | |
| download | rust-5584c795975e9cc07884b479c7cb7aef2f47c231.tar.gz rust-5584c795975e9cc07884b479c7cb7aef2f47c231.zip | |
Update to latest rustc and rustdoc styles
Diffstat (limited to 'src/doc/rustdoc')
| -rw-r--r-- | src/doc/rustdoc/src/unstable-features.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 91795997641..ea8589116b9 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -455,3 +455,17 @@ Calculating code examples follows these rules: * static * typedef 2. If one of the previously listed items has a code example, then it'll be counted. + +### `--with-examples`: include examples of uses of items as documentation + +This option, combined with `--scrape-examples-target-crate` and `--scrape-examples-output-path`, is used to implement the functionality in [RFC #3123](https://github.com/rust-lang/rfcs/pull/3123). Uses of an item (currently functions / call-sites) are found in a crate and its reverse-dependencies, and then the uses are included as documentation for that item. This feature is intended to be used via `cargo doc --scrape-examples`, but the rustdoc-only workflow looks like: + +```bash +$ rustdoc examples/ex.rs -Z unstable-options \ + --extern foobar=target/deps/libfoobar.rmeta + --scrape-examples-target-crate foobar \ + --scrape-examples-output-path output.calls +$ rustdoc src/lib.rs -Z unstable-options --with-examples output.calls +``` + +First, the library must be checked to generate an `rmeta`. Then a reverse-dependency like `examples/ex.rs` is given to rustdoc with the target crate being documented (`foobar`) and a path to output the calls (`output.calls`). Then, the generated calls file can be passed via `--with-examples` to the subsequent documentation of `foobar`. |
