|
1 | 1 | import os |
2 | 2 | import re |
| 3 | +import subprocess |
| 4 | +import sys |
| 5 | +import mistune |
| 6 | + |
3 | 7 | CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) |
4 | 8 |
|
5 | 9 |
|
|
8 | 12 | get-started => Get Started |
9 | 13 | """ |
10 | 14 |
|
| 15 | +res = subprocess.check_output(["git", "branch"]) |
| 16 | +if "* master" not in res: |
| 17 | + print "you have to be on master to run this !" |
| 18 | + sys.exit(1) |
| 19 | + |
11 | 20 |
|
12 | 21 | def get_path(filename): |
13 | 22 | return os.path.join(CURRENT_DIRECTORY, "..", "docs", "%s.md" % filename) |
@@ -35,3 +44,31 @@ def get_path(filename): |
35 | 44 |
|
36 | 45 | with open(readme_path, 'w') as readme_file: |
37 | 46 | readme_file.write(readme) |
| 47 | + |
| 48 | +subprocess.call(["git", "add", "-p", "README.md"]) |
| 49 | +subprocess.call(["git", "commit"]) |
| 50 | + |
| 51 | +# II. index.html |
| 52 | +raw = "" |
| 53 | +for filename in ["index", "dashboard", "get-started"]: |
| 54 | + with open(get_path(filename), 'r') as f: |
| 55 | + raw += f.read() |
| 56 | + raw += "\n\n" |
| 57 | +subprocess.call(["git", "checkout", "gh-pages"]) |
| 58 | +html = mistune.markdown(raw) |
| 59 | + |
| 60 | +index_path = os.path.join("index.html") |
| 61 | + |
| 62 | +with open(index_path, 'r') as index_file: |
| 63 | + index = index_file.read() |
| 64 | +index = re.sub( |
| 65 | + r"(<div class=\"row marketing\">)(.*)(</div><!-- row marketing -->)", |
| 66 | + r"\1%s\3" % html, |
| 67 | + index, |
| 68 | + flags=re.MULTILINE | re.DOTALL |
| 69 | +) |
| 70 | +with open(index_path, 'w') as index_file: |
| 71 | + index_file.write(index) |
| 72 | +subprocess.call(["git", "add", "-p", "index.html"]) |
| 73 | +subprocess.call(["git", "commit"]) |
| 74 | +# subprocess.call(["git", "checkout", "master"]) |
0 commit comments