Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload exactly the shared files needed and give precedence to global files over local ones #1340

Merged
merged 3 commits into from
Apr 13, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 3, 2021

See rust-lang/rust#83784 for more info about the history of this PR (and the commits also have more information).

  • Use --emit=unversioned-files,toolchain-shared-files for generating the shared files
  • Use --emit=invocation-specific for building crates
  • Give precedence to global shared files over local ones

Fixes #1327. Fixes #294 (hopefully for real this time).

r? @Nemo157

This avoids false positives for the essential files. Previously, docs.rs
would copy any files with a resource suffix as an essential file, even
if it couldn't be shared between crates (such as search-index.js).
This avoids copying shared files for crates other than the empty
library. This
a) Allows removing `copy_doc_dir`, which allows crates to add their own custom CSS (with `--theme` or otherwise), and
b) Avoids unnecessary disk IO.

Here are the files generated for a build of regex 1.4.1:

```
cratesfyi=# select path from files where path like '%regex/1.4.1%' and path not like '%regex/1.4.1/%/%';
                                 path
-----------------------------------------------------------------------
 sources/regex/1.4.1/PERFORMANCE.md
 rustdoc/regex/1.4.1/.lock
 sources/regex/1.4.1/Cargo.toml
 sources/regex/1.4.1/.cargo_vcs_info.json
 sources/regex/1.4.1/LICENSE-APACHE
 rustdoc/regex/1.4.1/source-files-20210402-1.53.0-nightly-138fd56cf.js
 rustdoc/regex/1.4.1/settings.html
 rustdoc/regex/1.4.1/search-index-20210402-1.53.0-nightly-138fd56cf.js
 rustdoc/regex/1.4.1/crates-20210402-1.53.0-nightly-138fd56cf.js
 sources/regex/1.4.1/CHANGELOG.md
 sources/regex/1.4.1/LICENSE-MIT
 sources/regex/1.4.1/rustfmt.toml
 sources/regex/1.4.1/HACKING.md
 sources/regex/1.4.1/test
 sources/regex/1.4.1/Cargo.toml.orig
 sources/regex/1.4.1/UNICODE.md
 sources/regex/1.4.1/.gitignore
 sources/regex/1.4.1/Cargo.lock
 sources/regex/1.4.1/README.md
(19 rows)
```

Note in particular that search-index.js and crates.js are included, but
not shared files like `storage.js` or `rustdoc.css`.
This avoids broken docs for crates build with an old version of rustdoc
that didn't respect the shared static root.
Copy link
Member

@Nemo157 Nemo157 left a comment

Choose a reason for hiding this comment

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

Code looks good. Testing and deployment is blocked on a new nightly with rustfmt being released.

@jyn514 jyn514 added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Apr 13, 2021
@Nemo157
Copy link
Member

Nemo157 commented Apr 13, 2021

Tested locally now that we have a new nightly, appears to be working well.

@jyn514 jyn514 merged commit f3a3740 into rust-lang:master Apr 13, 2021
@jyn514 jyn514 deleted the shared-files branch April 13, 2021 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs for releases during 2018-{10-12} appear unstyled Preserve .css files in target/doc
2 participants