fix: ensure the versions are sorted

This commit is contained in:
Jose Diaz-Gonzalez
2022-09-05 20:41:40 -04:00
parent 4c9deedba9
commit 344d2e83ad
2 changed files with 39 additions and 0 deletions

View File

@@ -105,6 +105,7 @@ main() {
done
done
python contrib/sort-mkdocs-versions
rm -rf docs
mv docs-main docs
git checkout -- mkdocs.yml docs

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python
import json
def main():
version_file = "tmp/docs-build/versions.json"
data = []
with open(version_file) as f:
data = json.load(f)
versions = []
for info in data:
if info["title"] == "latest":
continue
versions.append(info["title"].removeprefix("v"))
versions.sort(key=lambda x: list(map(int, x.split('.'))), reverse=True)
data = [
{
"aliases": [],
"title": "latest",
"version": "docs",
}
]
for version in versions:
data.append({
"aliases": [],
"title": f"v{version}",
"version": f"docs~v{version}",
})
with open(version_file, "w") as f:
json.dump(data, f, indent=4)
if __name__ == "__main__":
main()