|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +MAPPING = { |
| 4 | + "build-script.html": "https://doc.rust-lang.org/cargo/reference/build-scripts.html", |
| 5 | + "config.html": None, |
| 6 | + "crates-io.html": "https://doc.rust-lang.org/cargo/reference/publishing.html", |
| 7 | + "environment-variables.html": None, |
| 8 | + "external-tools.html": None, |
| 9 | + "faq.html": "https://doc.rust-lang.org/cargo/faq.html", |
| 10 | + "guide.html": "https://doc.rust-lang.org/cargo/guide/", |
| 11 | + "index.html": "https://doc.rust-lang.org/cargo/", |
| 12 | + "manifest.html": None, |
| 13 | + "pkgid-spec.html": None, |
| 14 | + "policies.html": "https://crates.io/policies", |
| 15 | + "source-replacement.html": None, |
| 16 | + "specifying-dependencies.html": None, |
| 17 | +} |
| 18 | + |
| 19 | +TEMPLATE = """\ |
| 20 | +<html> |
| 21 | +<head> |
| 22 | +<meta http-equiv="refresh" content="0; url={mapped}" /> |
| 23 | +<script> |
| 24 | +window.location.replace("{mapped}" + window.location.hash); |
| 25 | +</script> |
| 26 | +<title>Page Moved</title> |
| 27 | +</head> |
| 28 | +<body> |
| 29 | +This page has moved. Click <a href="{mapped}">here</a> to go to the new page. |
| 30 | +</body> |
| 31 | +</html> |
| 32 | +""" |
| 33 | + |
| 34 | +def main(): |
| 35 | + for name in sorted(MAPPING): |
| 36 | + with open(name, 'w') as f: |
| 37 | + mapped = MAPPING[name] |
| 38 | + if mapped is None: |
| 39 | + mapped = "https://doc.rust-lang.org/cargo/reference/{}".format(name) |
| 40 | + f.write(TEMPLATE.format(name=name, mapped=mapped)) |
| 41 | + |
| 42 | + with open('CNAME', 'w') as f: |
| 43 | + f.write('doc.crates.io') |
| 44 | + |
| 45 | +if __name__ == '__main__': |
| 46 | + main() |
0 commit comments