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

docs: pull latest version from tags instead of releases in docs page #6487

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 19 additions & 29 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
</div>
<script>
const RustfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
const RustfmtLatestUrl = 'https://api.github.com/repos/rust-lang/rustfmt/releases/latest';
const UrlHash = window.location.hash.replace(/^#/, '');
const queryParams = new URLSearchParams(window.location.search);
const searchParam = queryParams.get('search');
Expand All @@ -134,18 +133,25 @@
scrolledOnce: false,
},
asyncComputed: {
async updateVersion() {
let latest;
try {
latest = (await axios.get(RustfmtLatestUrl)).data;
} catch(err) {
console.log(err);
return;
}
if (versionParam == null) {
this.viewVersion = latest.name;
}
},
async pullTags() {
let tags;
try {
tags = (await axios.get(RustfmtTagsUrl)).data;
} catch(e) {
this.handleReqFailure(e);
return;
}

const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);

const tagOptions = tags
.map(tag => tag.name)
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));

const latestRelease = tagOptions.find(tag => !tag.includes('rc'));
this.viewVersion = latestRelease;
this.versionOptions = this.versionOptions.concat(tagOptions);
},
async outputHtml() {
if (this.viewVersion !== this.oldViewVersion) {
const ConfigurationMdUrl =
Expand Down Expand Up @@ -207,22 +213,6 @@
});
}
},
created: async function() {
let tags;
try {
tags = (await axios.get(RustfmtTagsUrl)).data;
} catch(e) {
this.handleReqFailure(e);
return;
}

const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);

const tagOptions = tags
.map(tag => tag.name)
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));
this.versionOptions = this.versionOptions.concat(tagOptions);
},
updated() {
if (UrlHash === '') return;
this.$nextTick(() => {
Expand Down
Loading