refactor & centralize rustdoc parameter handling & url generation #2966
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So, this is a long-time in progress refactor, partially to reduce a bunch of duplication & inconsistencies around how we handle paths from the URL, but also as preparation for #1853 (subdomain per crate).
parameter parsing
We now have one central axum extractor that can handle everything from very broad routes (just with crate name), to very specific ones (with name, version, target, path), including special-casing needed for static suffixes in routes (like we do for
settings.html).output
Generally I tried to also convert all the places where we had manual url generation in the templates, into using the new methods.
plan with subdomains
when we later have the subdomain-per-crates, I can "just" change what the extractor looks at, and also provide new target URLs that include the subdomain. And all the generated URLs in all the templates will point to the correct places.
semantic / breaking changes
For that looking at changed tests is best.
mainly:
/index.htmlfor folders in the URL any moreimplementation notes:
PageKindthing in the params, but also didn't have a nicer design idea. I was reluctant to introduce new structs for each kind and then wrap the different behaviour. Taking any recommendations :)RustdocParamsbuilder & parsing structure, specifically when unsetting certain attributes again. I feel like this is still a good state to start with and doesn't hurt the usability, the way the params are used right now.