@@ -1154,15 +1154,44 @@ path = "src/main.rs"
1154
1154
* RFC: [ #3123 ] ( https://github.com/rust-lang/rfcs/pull/3123 )
1155
1155
* Tracking Issue: [ #9910 ] ( https://github.com/rust-lang/cargo/issues/9910 )
1156
1156
1157
- The ` -Z rustdoc-scrape-examples ` argument tells Rustdoc to search crates in the current workspace
1158
- for calls to functions. Those call-sites are then included as documentation. The flag can take an
1159
- argument of ` all ` or ` examples ` which configures which crate in the workspace to analyze for examples.
1160
- For instance:
1157
+ The ` -Z rustdoc-scrape-examples ` flag tells Rustdoc to search crates in the current workspace
1158
+ for calls to functions. Those call-sites are then included as documentation. You can use the flag
1159
+ like this:
1161
1160
1162
1161
```
1163
- cargo doc -Z unstable-options -Z rustdoc-scrape-examples=examples
1162
+ cargo doc -Z unstable-options -Z rustdoc-scrape-examples
1163
+ ```
1164
+
1165
+ By default, Cargo will scrape from the packages that are being documented, as well as scrape from
1166
+ examples for the packages (i.e. those corresponding to the ` --examples ` flag). You can individually
1167
+ enable or disable targets from being scraped with the ` doc-scrape-examples ` flag, such as:
1168
+
1169
+ ``` toml
1170
+ # Disable scraping examples from a library
1171
+ [lib ]
1172
+ doc-scrape-examples = false
1173
+
1174
+ # Enable scraping examples from a binary
1175
+ [[bin ]]
1176
+ name = " my-bin"
1177
+ doc-scrape-examples = true
1164
1178
```
1165
1179
1180
+ ** Note on tests:** enabling ` doc-scrape-examples ` on test targets will not currently have any effect. Scraping
1181
+ examples from tests is a work-in-progress.
1182
+
1183
+ ** Note on dev-dependencies:** documenting a library does not normally require the crate's dev-dependencies. However,
1184
+ example units do require dev-deps. For backwards compatibility, ` -Z rustdoc-scrape-examples ` will * not* introduce a
1185
+ dev-deps requirement for ` cargo doc ` . Therefore examples will * not* be scraped from example targets under the
1186
+ following conditions:
1187
+
1188
+ 1 . No target being documented requires dev-deps, AND
1189
+ 2 . At least one crate being documented requires dev-deps, AND
1190
+ 3 . The ` doc-scrape-examples ` parameter is unset for ` [[example]] ` targets.
1191
+
1192
+ If you want examples to be scraped from example targets, then you must not satisfy one of the above conditions.
1193
+
1194
+
1166
1195
### check-cfg
1167
1196
1168
1197
* RFC: [ #3013 ] ( https://github.com/rust-lang/rfcs/pull/3013 )
0 commit comments