mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
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/
This commit is contained in:
commit
bdd4046f01
3 changed files with 56 additions and 14 deletions
18
.github/deploy.sh
vendored
18
.github/deploy.sh
vendored
|
@ -8,26 +8,22 @@ rm -rf out/master/ || exit 0
|
||||||
echo "Making the docs for master"
|
echo "Making the docs for master"
|
||||||
mkdir out/master/
|
mkdir out/master/
|
||||||
cp util/gh-pages/index.html out/master
|
cp util/gh-pages/index.html out/master
|
||||||
python ./util/export.py out/master/lints.json
|
python3 ./util/export.py out/master/lints.json
|
||||||
|
|
||||||
if [[ -n $TAG_NAME ]]; then
|
if [[ -n $TAG_NAME ]]; then
|
||||||
echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it"
|
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
|
||||||
cp -r out/master "out/$TAG_NAME"
|
cp -r out/master "out/$TAG_NAME"
|
||||||
rm -f out/current
|
rm -f out/stable
|
||||||
ln -s "$TAG_NAME" out/current
|
ln -s "$TAG_NAME" out/stable
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate version index that is shown as root index page
|
# Generate version index that is shown as root index page
|
||||||
cp util/gh-pages/versions.html out/index.html
|
cp util/gh-pages/versions.html out/index.html
|
||||||
|
|
||||||
cd out
|
echo "Making the versions.json file"
|
||||||
cat <<-EOF | python - > versions.json
|
python3 ./util/versions.py out
|
||||||
import os, json
|
|
||||||
print json.dumps([
|
|
||||||
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
|
|
||||||
])
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
cd out
|
||||||
# Now let's go have some fun with the cloned repo
|
# Now let's go have some fun with the cloned repo
|
||||||
git config user.name "GHA CI"
|
git config user.name "GHA CI"
|
||||||
git config user.email "gha@ci.invalid"
|
git config user.email "gha@ci.invalid"
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
|
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
|
||||||
href="./{{version}}/index.html">
|
href="./{{version}}/index.html">
|
||||||
{{normalizeVersion(version)}}
|
{{normalizeVersionDisplay(version)}}
|
||||||
</a>
|
</a>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
@ -54,13 +54,17 @@
|
||||||
.controller('docVersions', function ($scope, $http) {
|
.controller('docVersions', function ($scope, $http) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
$scope.normalizeVersion = function(v) {
|
$scope.normalizeVersionDisplay = function(v) {
|
||||||
return v.replace(/^v/, '');
|
return v.replace(/^v/, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.normalizeVersion = function(v) {
|
||||||
|
return v.replace(/^v/, '').replace(/^rust-/, '');
|
||||||
|
};
|
||||||
|
|
||||||
$scope.versionOrder = function(v) {
|
$scope.versionOrder = function(v) {
|
||||||
if (v === 'master') { return Infinity; }
|
if (v === 'master') { return Infinity; }
|
||||||
if (v === 'current') { return Number.MAX_VALUE; }
|
if (v === 'stable') { return Number.MAX_VALUE; }
|
||||||
|
|
||||||
return $scope.normalizeVersion(v)
|
return $scope.normalizeVersion(v)
|
||||||
.split('.')
|
.split('.')
|
||||||
|
|
42
util/versions.py
Executable file
42
util/versions.py
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from lintlib import log
|
||||||
|
|
||||||
|
|
||||||
|
def key(v):
|
||||||
|
if v == 'master':
|
||||||
|
return float('inf')
|
||||||
|
if v == 'stable':
|
||||||
|
return sys.maxsize
|
||||||
|
|
||||||
|
v = v.replace('v', '').replace('rust-', '')
|
||||||
|
|
||||||
|
s = 0
|
||||||
|
for i, val in enumerate(v.split('.')[::-1]):
|
||||||
|
s += int(val) * 100**i
|
||||||
|
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Error: specify output directory")
|
||||||
|
return
|
||||||
|
|
||||||
|
outdir = sys.argv[1]
|
||||||
|
versions = [
|
||||||
|
dir for dir in os.listdir(outdir) if not dir.startswith(".") and os.path.isdir(os.path.join(outdir, dir))
|
||||||
|
]
|
||||||
|
versions.sort(key=key)
|
||||||
|
|
||||||
|
with open(os.path.join(outdir, "versions.json"), "w") as fp:
|
||||||
|
json.dump(versions, fp, indent=2)
|
||||||
|
log.info("wrote JSON for great justice")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue