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

Improve deployment and documentation #5171

Merged
merged 4 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 4 additions & 8 deletions .github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rm -rf out/master/ || exit 0
echo "Making the docs for master"
mkdir 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
echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it"
Expand All @@ -20,14 +20,10 @@ fi
# Generate version index that is shown as root index page
cp util/gh-pages/versions.html out/index.html

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

cd out
# Now let's go have some fun with the cloned repo
git config user.name "GHA CI"
git config user.email "gha@ci.invalid"
Expand Down
8 changes: 6 additions & 2 deletions util/gh-pages/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3 class="panel-title">
<ul class="list-group">
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
href="./{{version}}/index.html">
{{normalizeVersion(version)}}
{{normalizeVersionDisplay(version)}}
</a>
</ul>
</article>
Expand All @@ -54,10 +54,14 @@ <h3 class="panel-title">
.controller('docVersions', function ($scope, $http) {
$scope.loading = true;

$scope.normalizeVersion = function(v) {
$scope.normalizeVersionDisplay = function(v) {
return v.replace(/^v/, '');
};

$scope.normalizeVersion = function(v) {
return v.replace(/^v/, '').replace(/^rust-/, '');
};

$scope.versionOrder = function(v) {
if (v === 'master') { return Infinity; }
if (v === 'current') { return Number.MAX_VALUE; }
Expand Down
42 changes: 42 additions & 0 deletions util/versions.py
Original file line number Diff line number Diff line change
@@ -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 == 'current':
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()