Skip to content

Commit bdd4046

Browse files
committed
Auto merge of #5171 - flip1995:deploy, r=Manishearth
Improve deployment and documentation **This should be merged shortly after** #5172 This extracts the python code that generated the `versions.json` file and now sorts the versions. in addition to that it improves the order on the website, respecting the new `rust-*` directories. The new appearance of the documentation site can be previewed here: https://flip1995.github.io/rust-clippy/ changelog: Add documentation for Clippy stable releases at https://rust-lang.github.io/rust-clippy/
2 parents 41d90d3 + 0f79182 commit bdd4046

File tree

3 files changed

+56
-14
lines changed

3 files changed

+56
-14
lines changed

.github/deploy.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ rm -rf out/master/ || exit 0
88
echo "Making the docs for master"
99
mkdir out/master/
1010
cp util/gh-pages/index.html out/master
11-
python ./util/export.py out/master/lints.json
11+
python3 ./util/export.py out/master/lints.json
1212

1313
if [[ -n $TAG_NAME ]]; then
14-
echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it"
14+
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
1515
cp -r out/master "out/$TAG_NAME"
16-
rm -f out/current
17-
ln -s "$TAG_NAME" out/current
16+
rm -f out/stable
17+
ln -s "$TAG_NAME" out/stable
1818
fi
1919

2020
# Generate version index that is shown as root index page
2121
cp util/gh-pages/versions.html out/index.html
2222

23-
cd out
24-
cat <<-EOF | python - > versions.json
25-
import os, json
26-
print json.dumps([
27-
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
28-
])
29-
EOF
23+
echo "Making the versions.json file"
24+
python3 ./util/versions.py out
3025

26+
cd out
3127
# Now let's go have some fun with the cloned repo
3228
git config user.name "GHA CI"
3329
git config user.email "[email protected]"

util/gh-pages/versions.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h3 class="panel-title">
3636
<ul class="list-group">
3737
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
3838
href="./{{version}}/index.html">
39-
{{normalizeVersion(version)}}
39+
{{normalizeVersionDisplay(version)}}
4040
</a>
4141
</ul>
4242
</article>
@@ -54,13 +54,17 @@ <h3 class="panel-title">
5454
.controller('docVersions', function ($scope, $http) {
5555
$scope.loading = true;
5656

57-
$scope.normalizeVersion = function(v) {
57+
$scope.normalizeVersionDisplay = function(v) {
5858
return v.replace(/^v/, '');
5959
};
6060

61+
$scope.normalizeVersion = function(v) {
62+
return v.replace(/^v/, '').replace(/^rust-/, '');
63+
};
64+
6165
$scope.versionOrder = function(v) {
6266
if (v === 'master') { return Infinity; }
63-
if (v === 'current') { return Number.MAX_VALUE; }
67+
if (v === 'stable') { return Number.MAX_VALUE; }
6468

6569
return $scope.normalizeVersion(v)
6670
.split('.')

util/versions.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
3+
import json
4+
import os
5+
import sys
6+
7+
from lintlib import log
8+
9+
10+
def key(v):
11+
if v == 'master':
12+
return float('inf')
13+
if v == 'stable':
14+
return sys.maxsize
15+
16+
v = v.replace('v', '').replace('rust-', '')
17+
18+
s = 0
19+
for i, val in enumerate(v.split('.')[::-1]):
20+
s += int(val) * 100**i
21+
22+
return s
23+
24+
25+
def main():
26+
if len(sys.argv) < 2:
27+
print("Error: specify output directory")
28+
return
29+
30+
outdir = sys.argv[1]
31+
versions = [
32+
dir for dir in os.listdir(outdir) if not dir.startswith(".") and os.path.isdir(os.path.join(outdir, dir))
33+
]
34+
versions.sort(key=key)
35+
36+
with open(os.path.join(outdir, "versions.json"), "w") as fp:
37+
json.dump(versions, fp, indent=2)
38+
log.info("wrote JSON for great justice")
39+
40+
41+
if __name__ == "__main__":
42+
main()

0 commit comments

Comments
 (0)