- let out_dir = builder.stage_out(compiler, Mode::Std).join(target.triple).join("doc");
- // `cargo` uses the same directory for both JSON docs and HTML docs.
- // This could lead to cross-contamination when copying files into the specified `out` directory.
- // For example:
- // ```bash
- // x doc std
- // x doc std --json
- // ```
- // could lead to HTML docs being copied into the JSON docs output directory.
- // To avoid this issue, we clean the doc folder before invoking `cargo`.
- if out_dir.exists() {
- builder.remove_dir(&out_dir);
- }