-
Notifications
You must be signed in to change notification settings - Fork 209
Refactor web::latest_version, move logic into CrateDetails #559
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
Conversation
… dinstinguish its meaning
…tdoc This commit manages to remove _a lot_ of code from src::web::mod. The removed code was intended to determine the latest version of a list of versions. Its only caller, rustdoc, passed a list of versions directly from CrateDetails. This could be simplified by moving this logic into CrateDetails, which already has a sorted list of versions.struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't run the code but I have a few initial comments.
@jyn514 I have simplified the code a bit, avoiding the need to call |
395 was a separate issue in |
About those issues mentioning yanked crates, I have another small-ish refactor coming up which would add a |
I noticed
web/mod.rs
contained a really complicatedlatest_version
function: https://github.com/rust-lang/docs.rs/blob/master/src/web/mod.rs#L316The bulk of the work was spent in converting the version strings into
semver::Version
, to sort the array. Something that is already done inCrateDetails
...The original
latest_version
would return:None
ifreq_version
was an invalid function or ifreq_version
is the latest versionSome(version)
if this crate has a more recent versionI have split what this function does in two functions:
CrateDetails::is_latest_version
--> check if this is the most recent releaseCrateDetails::latest_version
--> grab the most recent releaseI like how it is much easier to reason about now 😊
These changes should be easy to follow commit-by-commit. The real changes happen in the second commit: 309ea7a