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

serve all in-crate js files #329

Merged

Conversation

QuietMisdreavus
Copy link
Member

Starting with rust-lang/rust#59776, the search index, aliases, and source file list are getting the resource suffix added to their file names. This means we can't route them from a static path any more.

Since we always check the static file router first, this will still allow serving main.js for rustdoc versions prior to the addition of --static-root-path, and also allows rustdoc to add per-crate javascript files without requiring docs.rs to update to handle it.

(It also allows us to start hosting things other than rustdoc output as docs - e.g. mdbook output - in the future without changing the routing table massively.)

WARNING: Do not merge/deploy until rust-lang/rust#59776 is in nightly rustdoc. Deploy with update-both-rustc-docsrs script to ensure that docs.rs doesn't use the wrong rustdoc to build/serve docs!

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Thanks! :)

@QuietMisdreavus
Copy link
Member Author

I had a chance to test this on my dev server and it unfortunately does not work. I'll probably need to change the redirection logic to make the new search index work.

(...also we missed sidebar-items.js 😓)

starting with rust-lang/rust#59776, the search index, aliases, and
source file list are getting the resource suffix added to their file
names. this means we can't route them from a static path any more.

since we always check the static file router first, this will still
allow serving `main.js` for rustdoc versions prior to the addition of
`--static-root-path`, and also allows rustdoc to add per-crate
javascript files without requiring docs.rs to update to handle it.

(it also allows us to start hosting things *other* than rustdoc output
as docs - e.g. mdbook output - in the future without changing the
routing table massively.)
@QuietMisdreavus
Copy link
Member Author

I had a chance to look at it again, and it seems like the /:crate/:version/*.js route i added wasn't getting hit at all - it seemed to be hitting the /:crate/:version/:target one first, which made it redirect those files to the crate root docs instead. In the last commit i pushed, i took advantage of that to just inspect the file from that handler and defer to the proper handler if it was hit with a JS file. (This could be extended in the future for CSS files, if necessary, but for now i just kept it to JS files.)

@QuietMisdreavus QuietMisdreavus merged commit a31865e into rust-lang:master Apr 29, 2019
@QuietMisdreavus QuietMisdreavus deleted the search-index-resource branch April 29, 2019 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants