mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
Generate versions HTML directly
This commit is contained in:
parent
903293b199
commit
d2305ff634
3 changed files with 87 additions and 84 deletions
9
.github/deploy.sh
vendored
9
.github/deploy.sh
vendored
|
@ -25,16 +25,15 @@ if [[ $BETA = "true" ]]; then
|
||||||
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
|
python3 ./util/versions.py ./util/gh-pages/versions.html out
|
||||||
|
|
||||||
echo "Making the versions.json file"
|
|
||||||
python3 ./util/versions.py out
|
|
||||||
|
|
||||||
# Now let's go have some fun with the cloned repo
|
# Now let's go have some fun with the cloned repo
|
||||||
cd out
|
cd out
|
||||||
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"
|
||||||
|
|
||||||
|
git status
|
||||||
|
|
||||||
if [[ -n $TAG_NAME ]]; then
|
if [[ -n $TAG_NAME ]]; then
|
||||||
# track files, so that the following check works
|
# track files, so that the following check works
|
||||||
git add --intent-to-add "$TAG_NAME"
|
git add --intent-to-add "$TAG_NAME"
|
||||||
|
@ -46,8 +45,6 @@ if [[ -n $TAG_NAME ]]; then
|
||||||
git add "$TAG_NAME"
|
git add "$TAG_NAME"
|
||||||
# Update the symlink
|
# Update the symlink
|
||||||
git add stable
|
git add stable
|
||||||
# Update versions file
|
|
||||||
git add versions.json
|
|
||||||
git commit -m "Add documentation for ${TAG_NAME} release: ${SHA}"
|
git commit -m "Add documentation for ${TAG_NAME} release: ${SHA}"
|
||||||
elif [[ $BETA = "true" ]]; then
|
elif [[ $BETA = "true" ]]; then
|
||||||
if git diff --exit-code --quiet -- beta/; then
|
if git diff --exit-code --quiet -- beta/; then
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Expanded by util/versions.py into the HTML file seen at https://rust-lang.github.io/rust-clippy/ -->
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
|
@ -7,26 +8,15 @@
|
||||||
<title>Clippy lints documentation</title>
|
<title>Clippy lints documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
|
||||||
<style>
|
|
||||||
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container" ng-app="clippy" ng-controller="docVersions">
|
<div class="container">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Clippy lints documentation</h1>
|
<h1>Clippy lints documentation</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-cloak>
|
<div>
|
||||||
<div class="alert alert-info" role="alert" ng-if="loading">
|
<article class="panel panel-default">
|
||||||
Loading…
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger" role="alert" ng-if="error">
|
|
||||||
Error loading versions!<br/>
|
|
||||||
You can always try to get <a href="master/index.html">the master branch docs</a>.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article class="panel panel-default" ng-show="data">
|
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
Available versions
|
Available versions
|
||||||
|
@ -34,55 +24,70 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
|
$list
|
||||||
href="./{{version}}/index.html">
|
|
||||||
{{version}}
|
|
||||||
</a>
|
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="https://github.com/rust-lang/rust-clippy">
|
<a
|
||||||
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"/>
|
aria-label="View source on GitHub"
|
||||||
</a>
|
class="github-corner"
|
||||||
|
href="https://github.com/rust-lang/rust-clippy"
|
||||||
|
rel="noopener noreferrer"
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
|
target="_blank"
|
||||||
<script>
|
>
|
||||||
angular.module('clippy', [])
|
<svg
|
||||||
.controller('docVersions', function ($scope, $http) {
|
width="80"
|
||||||
$scope.loading = true;
|
height="80"
|
||||||
|
viewBox="0 0 250 250"
|
||||||
$scope.normalizeVersion = function(v) {
|
style="position: absolute; top: 0; border: 0; right: 0"
|
||||||
return v.replace(/^rust-/, '');
|
aria-hidden="true"
|
||||||
};
|
>
|
||||||
|
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" fill="var(--theme-color)"></path>
|
||||||
$scope.versionOrder = function(v) {
|
<path
|
||||||
if (v === 'master') { return Infinity; }
|
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
|
||||||
if (v === 'stable') { return Number.MAX_VALUE; }
|
fill="currentColor"
|
||||||
if (v === 'beta') { return Number.MAX_VALUE - 1; }
|
style="transform-origin: 130px 106px"
|
||||||
if (v === 'pre-1.29.0') { return Number.MIN_VALUE; }
|
class="octo-arm"
|
||||||
|
></path>
|
||||||
return $scope.normalizeVersion(v)
|
<path
|
||||||
.split('.')
|
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
|
||||||
.reverse()
|
fill="currentColor"
|
||||||
.reduce(function(acc, val, index) {
|
class="octo-body"
|
||||||
return acc + (val * Math.pow(100, index));
|
></path>
|
||||||
}, 0);
|
</svg>
|
||||||
|
<style>
|
||||||
|
.github-corner svg {
|
||||||
|
fill: black;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
.github-corner:hover .octo-arm {
|
||||||
$http.get('./versions.json')
|
animation: octocat-wave 560ms ease-in-out;
|
||||||
.success(function (data) {
|
}
|
||||||
$scope.data = data;
|
@keyframes octocat-wave {
|
||||||
$scope.loading = false;
|
0%,
|
||||||
})
|
100% {
|
||||||
.error(function (data) {
|
transform: rotate(0);
|
||||||
$scope.error = data;
|
}
|
||||||
$scope.loading = false;
|
20%,
|
||||||
});
|
60% {
|
||||||
})
|
transform: rotate(-25deg);
|
||||||
;
|
}
|
||||||
</script>
|
40%,
|
||||||
|
80% {
|
||||||
|
transform: rotate(10deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: 500px) {
|
||||||
|
.github-corner:hover .octo-arm {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
.github-corner .octo-arm {
|
||||||
|
animation: octocat-wave 560ms ease-in-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from string import Template
|
||||||
|
import argparse
|
||||||
import json
|
import json
|
||||||
import logging as log
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
log.basicConfig(level=log.INFO, format="%(levelname)s: %(message)s")
|
|
||||||
|
|
||||||
|
|
||||||
def key(v):
|
def key(v):
|
||||||
if v == "master":
|
if v == "master":
|
||||||
return float("inf")
|
|
||||||
if v == "stable":
|
|
||||||
return sys.maxsize
|
return sys.maxsize
|
||||||
if v == "beta":
|
if v == "stable":
|
||||||
return sys.maxsize - 1
|
return sys.maxsize - 1
|
||||||
|
if v == "beta":
|
||||||
|
return sys.maxsize - 2
|
||||||
if v == "pre-1.29.0":
|
if v == "pre-1.29.0":
|
||||||
return -1
|
return -1
|
||||||
|
if not v.startswith("rust-"):
|
||||||
|
return None
|
||||||
|
|
||||||
v = v.replace("rust-", "")
|
v = v.replace("rust-", "")
|
||||||
|
|
||||||
|
@ -26,26 +26,27 @@ def key(v):
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
parser = argparse.ArgumentParser()
|
||||||
log.error("specify output directory")
|
parser.add_argument("input", help="path to the versions.html template", type=argparse.FileType("r"))
|
||||||
return
|
parser.add_argument("outdir", help="path to write the output HTML")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
outdir = sys.argv[1]
|
|
||||||
versions = [
|
versions = [
|
||||||
dir
|
dir
|
||||||
for dir in os.listdir(outdir)
|
for dir in os.listdir(args.outdir)
|
||||||
if not dir.startswith(".")
|
if key(dir) is not None
|
||||||
and not dir.startswith("v")
|
|
||||||
and os.path.isdir(os.path.join(outdir, dir))
|
|
||||||
]
|
]
|
||||||
versions.sort(key=key)
|
versions.sort(key=key, reverse=True)
|
||||||
|
links = [f'<a class="list-group-item" href="./{version}/index.html">{version}</a>' for version in versions]
|
||||||
|
|
||||||
with open(os.path.join(outdir, "versions.json"), "w") as fp:
|
template = Template(args.input.read())
|
||||||
json.dump(versions, fp, indent=2)
|
html = template.substitute(list="\n".join(links))
|
||||||
log.info("wrote JSON for great justice")
|
|
||||||
|
|
||||||
|
path = os.path.join(args.outdir, "index.html")
|
||||||
|
with open(path, "w") as out:
|
||||||
|
out.write(html)
|
||||||
|
print(f"wrote HTML to {path}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue